@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,30 +10,30 @@ discard block |
||
10 | 10 | class WPInv_Item extends GetPaid_Data { |
11 | 11 | |
12 | 12 | /** |
13 | - * Which data store to load. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
13 | + * Which data store to load. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | protected $data_store_name = 'item'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'item'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'item'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Item Data array. This is the core item data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'parent_id' => 0, |
|
34 | - 'status' => 'draft', |
|
35 | - 'version' => '', |
|
36 | - 'date_created' => null, |
|
27 | + * Item Data array. This is the core item data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'parent_id' => 0, |
|
34 | + 'status' => 'draft', |
|
35 | + 'version' => '', |
|
36 | + 'date_created' => null, |
|
37 | 37 | 'date_modified' => null, |
38 | 38 | 'name' => '', |
39 | 39 | 'description' => '', |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | ); |
59 | 59 | |
60 | 60 | /** |
61 | - * Stores meta in cache for future reads. |
|
62 | - * |
|
63 | - * A group must be set to to enable caching. |
|
64 | - * |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - protected $cache_group = 'getpaid_items'; |
|
61 | + * Stores meta in cache for future reads. |
|
62 | + * |
|
63 | + * A group must be set to to enable caching. |
|
64 | + * |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + protected $cache_group = 'getpaid_items'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Stores a reference to the original WP_Post object |
@@ -74,33 +74,33 @@ discard block |
||
74 | 74 | protected $post = null; |
75 | 75 | |
76 | 76 | /** |
77 | - * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | - * |
|
79 | - * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | - */ |
|
81 | - public function __construct( $item = 0 ) { |
|
82 | - parent::__construct( $item ); |
|
83 | - |
|
84 | - if ( is_numeric( $item ) && $item > 0 ) { |
|
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 | - } else { |
|
91 | - $this->set_object_read( true ); |
|
92 | - } |
|
77 | + * Get the item if ID is passed, otherwise the item is new and empty. |
|
78 | + * |
|
79 | + * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
80 | + */ |
|
81 | + public function __construct( $item = 0 ) { |
|
82 | + parent::__construct( $item ); |
|
83 | + |
|
84 | + if ( is_numeric( $item ) && $item > 0 ) { |
|
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 | + } else { |
|
91 | + $this->set_object_read( true ); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | // Load the datastore. |
95 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
95 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
96 | 96 | |
97 | - if ( $this->get_id() > 0 ) { |
|
97 | + if ( $this->get_id() > 0 ) { |
|
98 | 98 | $this->post = get_post( $this->get_id() ); |
99 | 99 | $this->ID = $this->get_id(); |
100 | - $this->data_store->read( $this ); |
|
100 | + $this->data_store->read( $this ); |
|
101 | 101 | } |
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | 105 | /* |
106 | 106 | |-------------------------------------------------------------------------- |
@@ -118,176 +118,176 @@ discard block |
||
118 | 118 | */ |
119 | 119 | |
120 | 120 | /** |
121 | - * Get parent item ID. |
|
122 | - * |
|
123 | - * @since 1.0.19 |
|
124 | - * @param string $context View or edit context. |
|
125 | - * @return int |
|
126 | - */ |
|
127 | - public function get_parent_id( $context = 'view' ) { |
|
128 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
121 | + * Get parent item ID. |
|
122 | + * |
|
123 | + * @since 1.0.19 |
|
124 | + * @param string $context View or edit context. |
|
125 | + * @return int |
|
126 | + */ |
|
127 | + public function get_parent_id( $context = 'view' ) { |
|
128 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * Get item status. |
|
133 | - * |
|
134 | - * @since 1.0.19 |
|
135 | - * @param string $context View or edit context. |
|
136 | - * @return string |
|
137 | - */ |
|
138 | - public function get_status( $context = 'view' ) { |
|
139 | - return $this->get_prop( 'status', $context ); |
|
132 | + * Get item status. |
|
133 | + * |
|
134 | + * @since 1.0.19 |
|
135 | + * @param string $context View or edit context. |
|
136 | + * @return string |
|
137 | + */ |
|
138 | + public function get_status( $context = 'view' ) { |
|
139 | + return $this->get_prop( 'status', $context ); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
143 | - * Get plugin version when the item was created. |
|
144 | - * |
|
145 | - * @since 1.0.19 |
|
146 | - * @param string $context View or edit context. |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - public function get_version( $context = 'view' ) { |
|
150 | - return $this->get_prop( 'version', $context ); |
|
143 | + * Get plugin version when the item was created. |
|
144 | + * |
|
145 | + * @since 1.0.19 |
|
146 | + * @param string $context View or edit context. |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + public function get_version( $context = 'view' ) { |
|
150 | + return $this->get_prop( 'version', $context ); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Get date when the item was created. |
|
155 | - * |
|
156 | - * @since 1.0.19 |
|
157 | - * @param string $context View or edit context. |
|
158 | - * @return string |
|
159 | - */ |
|
160 | - public function get_date_created( $context = 'view' ) { |
|
161 | - return $this->get_prop( 'date_created', $context ); |
|
154 | + * Get date when the item was created. |
|
155 | + * |
|
156 | + * @since 1.0.19 |
|
157 | + * @param string $context View or edit context. |
|
158 | + * @return string |
|
159 | + */ |
|
160 | + public function get_date_created( $context = 'view' ) { |
|
161 | + return $this->get_prop( 'date_created', $context ); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | - * Get GMT date when the item was created. |
|
166 | - * |
|
167 | - * @since 1.0.19 |
|
168 | - * @param string $context View or edit context. |
|
169 | - * @return string |
|
170 | - */ |
|
171 | - public function get_date_created_gmt( $context = 'view' ) { |
|
165 | + * Get GMT date when the item was created. |
|
166 | + * |
|
167 | + * @since 1.0.19 |
|
168 | + * @param string $context View or edit context. |
|
169 | + * @return string |
|
170 | + */ |
|
171 | + public function get_date_created_gmt( $context = 'view' ) { |
|
172 | 172 | $date = $this->get_date_created( $context ); |
173 | 173 | |
174 | 174 | if ( $date ) { |
175 | 175 | $date = get_gmt_from_date( $date ); |
176 | 176 | } |
177 | - return $date; |
|
177 | + return $date; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | - * Get date when the item was last modified. |
|
182 | - * |
|
183 | - * @since 1.0.19 |
|
184 | - * @param string $context View or edit context. |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - public function get_date_modified( $context = 'view' ) { |
|
188 | - return $this->get_prop( 'date_modified', $context ); |
|
181 | + * Get date when the item was last modified. |
|
182 | + * |
|
183 | + * @since 1.0.19 |
|
184 | + * @param string $context View or edit context. |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + public function get_date_modified( $context = 'view' ) { |
|
188 | + return $this->get_prop( 'date_modified', $context ); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | - * Get GMT date when the item was last modified. |
|
193 | - * |
|
194 | - * @since 1.0.19 |
|
195 | - * @param string $context View or edit context. |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
192 | + * Get GMT date when the item was last modified. |
|
193 | + * |
|
194 | + * @since 1.0.19 |
|
195 | + * @param string $context View or edit context. |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
199 | 199 | $date = $this->get_date_modified( $context ); |
200 | 200 | |
201 | 201 | if ( $date ) { |
202 | 202 | $date = get_gmt_from_date( $date ); |
203 | 203 | } |
204 | - return $date; |
|
204 | + return $date; |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
208 | - * Get the item name. |
|
209 | - * |
|
210 | - * @since 1.0.19 |
|
211 | - * @param string $context View or edit context. |
|
212 | - * @return string |
|
213 | - */ |
|
214 | - public function get_name( $context = 'view' ) { |
|
215 | - return $this->get_prop( 'name', $context ); |
|
208 | + * Get the item name. |
|
209 | + * |
|
210 | + * @since 1.0.19 |
|
211 | + * @param string $context View or edit context. |
|
212 | + * @return string |
|
213 | + */ |
|
214 | + public function get_name( $context = 'view' ) { |
|
215 | + return $this->get_prop( 'name', $context ); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
219 | - * Alias of self::get_name(). |
|
220 | - * |
|
221 | - * @since 1.0.19 |
|
222 | - * @param string $context View or edit context. |
|
223 | - * @return string |
|
224 | - */ |
|
225 | - public function get_title( $context = 'view' ) { |
|
226 | - return $this->get_name( $context ); |
|
219 | + * Alias of self::get_name(). |
|
220 | + * |
|
221 | + * @since 1.0.19 |
|
222 | + * @param string $context View or edit context. |
|
223 | + * @return string |
|
224 | + */ |
|
225 | + public function get_title( $context = 'view' ) { |
|
226 | + return $this->get_name( $context ); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | - * Get the item description. |
|
231 | - * |
|
232 | - * @since 1.0.19 |
|
233 | - * @param string $context View or edit context. |
|
234 | - * @return string |
|
235 | - */ |
|
236 | - public function get_description( $context = 'view' ) { |
|
237 | - return $this->get_prop( 'description', $context ); |
|
230 | + * Get the item description. |
|
231 | + * |
|
232 | + * @since 1.0.19 |
|
233 | + * @param string $context View or edit context. |
|
234 | + * @return string |
|
235 | + */ |
|
236 | + public function get_description( $context = 'view' ) { |
|
237 | + return $this->get_prop( 'description', $context ); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | - * Alias of self::get_description(). |
|
242 | - * |
|
243 | - * @since 1.0.19 |
|
244 | - * @param string $context View or edit context. |
|
245 | - * @return string |
|
246 | - */ |
|
247 | - public function get_excerpt( $context = 'view' ) { |
|
248 | - return $this->get_description( $context ); |
|
241 | + * Alias of self::get_description(). |
|
242 | + * |
|
243 | + * @since 1.0.19 |
|
244 | + * @param string $context View or edit context. |
|
245 | + * @return string |
|
246 | + */ |
|
247 | + public function get_excerpt( $context = 'view' ) { |
|
248 | + return $this->get_description( $context ); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * Alias of self::get_description(). |
|
253 | - * |
|
254 | - * @since 1.0.19 |
|
255 | - * @param string $context View or edit context. |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - public function get_summary( $context = 'view' ) { |
|
259 | - return $this->get_description( $context ); |
|
252 | + * Alias of self::get_description(). |
|
253 | + * |
|
254 | + * @since 1.0.19 |
|
255 | + * @param string $context View or edit context. |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + public function get_summary( $context = 'view' ) { |
|
259 | + return $this->get_description( $context ); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | - * Get the owner of the item. |
|
264 | - * |
|
265 | - * @since 1.0.19 |
|
266 | - * @param string $context View or edit context. |
|
267 | - * @return string |
|
268 | - */ |
|
269 | - public function get_author( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'author', $context ); |
|
263 | + * Get the owner of the item. |
|
264 | + * |
|
265 | + * @since 1.0.19 |
|
266 | + * @param string $context View or edit context. |
|
267 | + * @return string |
|
268 | + */ |
|
269 | + public function get_author( $context = 'view' ) { |
|
270 | + return (int) $this->get_prop( 'author', $context ); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
274 | - * Get the price of the item. |
|
275 | - * |
|
276 | - * @since 1.0.19 |
|
277 | - * @param string $context View or edit context. |
|
278 | - * @return float |
|
279 | - */ |
|
280 | - public function get_price( $context = 'view' ) { |
|
274 | + * Get the price of the item. |
|
275 | + * |
|
276 | + * @since 1.0.19 |
|
277 | + * @param string $context View or edit context. |
|
278 | + * @return float |
|
279 | + */ |
|
280 | + public function get_price( $context = 'view' ) { |
|
281 | 281 | return (float) wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | - * Returns a formated price. |
|
286 | - * |
|
287 | - * @since 1.0.19 |
|
288 | - * @param string $context View or edit context. |
|
289 | - * @return string |
|
290 | - */ |
|
285 | + * Returns a formated price. |
|
286 | + * |
|
287 | + * @since 1.0.19 |
|
288 | + * @param string $context View or edit context. |
|
289 | + * @return string |
|
290 | + */ |
|
291 | 291 | public function get_the_price() { |
292 | 292 | $item_price = wpinv_price( wpinv_format_amount( $this->get_price() ) ); |
293 | 293 | |
@@ -295,134 +295,134 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | - * Get the VAT rule of the item. |
|
299 | - * |
|
300 | - * @since 1.0.19 |
|
301 | - * @param string $context View or edit context. |
|
302 | - * @return string |
|
303 | - */ |
|
304 | - public function get_vat_rule( $context = 'view' ) { |
|
298 | + * Get the VAT rule of the item. |
|
299 | + * |
|
300 | + * @since 1.0.19 |
|
301 | + * @param string $context View or edit context. |
|
302 | + * @return string |
|
303 | + */ |
|
304 | + public function get_vat_rule( $context = 'view' ) { |
|
305 | 305 | return $this->get_prop( 'vat_rule', $context ); |
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | - * Get the VAT class of the item. |
|
310 | - * |
|
311 | - * @since 1.0.19 |
|
312 | - * @param string $context View or edit context. |
|
313 | - * @return string |
|
314 | - */ |
|
315 | - public function get_vat_class( $context = 'view' ) { |
|
309 | + * Get the VAT class of the item. |
|
310 | + * |
|
311 | + * @since 1.0.19 |
|
312 | + * @param string $context View or edit context. |
|
313 | + * @return string |
|
314 | + */ |
|
315 | + public function get_vat_class( $context = 'view' ) { |
|
316 | 316 | return $this->get_prop( 'vat_class', $context ); |
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
320 | - * Get the type of the item. |
|
321 | - * |
|
322 | - * @since 1.0.19 |
|
323 | - * @param string $context View or edit context. |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - public function get_type( $context = 'view' ) { |
|
320 | + * Get the type of the item. |
|
321 | + * |
|
322 | + * @since 1.0.19 |
|
323 | + * @param string $context View or edit context. |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + public function get_type( $context = 'view' ) { |
|
327 | 327 | return $this->get_prop( 'type', $context ); |
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
331 | - * Get the custom id of the item. |
|
332 | - * |
|
333 | - * @since 1.0.19 |
|
334 | - * @param string $context View or edit context. |
|
335 | - * @return string |
|
336 | - */ |
|
337 | - public function get_custom_id( $context = 'view' ) { |
|
331 | + * Get the custom id of the item. |
|
332 | + * |
|
333 | + * @since 1.0.19 |
|
334 | + * @param string $context View or edit context. |
|
335 | + * @return string |
|
336 | + */ |
|
337 | + public function get_custom_id( $context = 'view' ) { |
|
338 | 338 | return $this->get_prop( 'custom_id', $context ); |
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
342 | - * Get the custom name of the item. |
|
343 | - * |
|
344 | - * @since 1.0.19 |
|
345 | - * @param string $context View or edit context. |
|
346 | - * @return string |
|
347 | - */ |
|
348 | - public function get_custom_name( $context = 'view' ) { |
|
342 | + * Get the custom name of the item. |
|
343 | + * |
|
344 | + * @since 1.0.19 |
|
345 | + * @param string $context View or edit context. |
|
346 | + * @return string |
|
347 | + */ |
|
348 | + public function get_custom_name( $context = 'view' ) { |
|
349 | 349 | return $this->get_prop( 'custom_name', $context ); |
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
353 | - * Get the custom singular name of the item. |
|
354 | - * |
|
355 | - * @since 1.0.19 |
|
356 | - * @param string $context View or edit context. |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - public function get_custom_singular_name( $context = 'view' ) { |
|
353 | + * Get the custom singular name of the item. |
|
354 | + * |
|
355 | + * @since 1.0.19 |
|
356 | + * @param string $context View or edit context. |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + public function get_custom_singular_name( $context = 'view' ) { |
|
360 | 360 | return $this->get_prop( 'custom_singular_name', $context ); |
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | - * Checks if an item is editable.. |
|
365 | - * |
|
366 | - * @since 1.0.19 |
|
367 | - * @param string $context View or edit context. |
|
368 | - * @return int |
|
369 | - */ |
|
370 | - public function get_is_editable( $context = 'view' ) { |
|
364 | + * Checks if an item is editable.. |
|
365 | + * |
|
366 | + * @since 1.0.19 |
|
367 | + * @param string $context View or edit context. |
|
368 | + * @return int |
|
369 | + */ |
|
370 | + public function get_is_editable( $context = 'view' ) { |
|
371 | 371 | return (int) $this->get_prop( 'is_editable', $context ); |
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
375 | - * Alias of self::get_is_editable(). |
|
376 | - * |
|
377 | - * @since 1.0.19 |
|
378 | - * @param string $context View or edit context. |
|
379 | - * @return int |
|
380 | - */ |
|
381 | - public function get_editable( $context = 'view' ) { |
|
382 | - return $this->get_is_editable( $context ); |
|
375 | + * Alias of self::get_is_editable(). |
|
376 | + * |
|
377 | + * @since 1.0.19 |
|
378 | + * @param string $context View or edit context. |
|
379 | + * @return int |
|
380 | + */ |
|
381 | + public function get_editable( $context = 'view' ) { |
|
382 | + return $this->get_is_editable( $context ); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | - * Checks if dynamic pricing is enabled. |
|
387 | - * |
|
388 | - * @since 1.0.19 |
|
389 | - * @param string $context View or edit context. |
|
390 | - * @return int |
|
391 | - */ |
|
392 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
386 | + * Checks if dynamic pricing is enabled. |
|
387 | + * |
|
388 | + * @since 1.0.19 |
|
389 | + * @param string $context View or edit context. |
|
390 | + * @return int |
|
391 | + */ |
|
392 | + public function get_is_dynamic_pricing( $context = 'view' ) { |
|
393 | 393 | return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
397 | - * Returns the minimum price if dynamic pricing is enabled. |
|
398 | - * |
|
399 | - * @since 1.0.19 |
|
400 | - * @param string $context View or edit context. |
|
401 | - * @return float |
|
402 | - */ |
|
403 | - public function get_minimum_price( $context = 'view' ) { |
|
397 | + * Returns the minimum price if dynamic pricing is enabled. |
|
398 | + * |
|
399 | + * @since 1.0.19 |
|
400 | + * @param string $context View or edit context. |
|
401 | + * @return float |
|
402 | + */ |
|
403 | + public function get_minimum_price( $context = 'view' ) { |
|
404 | 404 | return (float) wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Checks if this is a recurring item. |
|
409 | - * |
|
410 | - * @since 1.0.19 |
|
411 | - * @param string $context View or edit context. |
|
412 | - * @return int |
|
413 | - */ |
|
414 | - public function get_is_recurring( $context = 'view' ) { |
|
408 | + * Checks if this is a recurring item. |
|
409 | + * |
|
410 | + * @since 1.0.19 |
|
411 | + * @param string $context View or edit context. |
|
412 | + * @return int |
|
413 | + */ |
|
414 | + public function get_is_recurring( $context = 'view' ) { |
|
415 | 415 | return (int) $this->get_prop( 'is_recurring', $context ); |
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | - * Get the recurring period. |
|
420 | - * |
|
421 | - * @since 1.0.19 |
|
422 | - * @param bool $full Return abbreviation or in full. |
|
423 | - * @return string |
|
424 | - */ |
|
425 | - public function get_recurring_period( $full = false ) { |
|
419 | + * Get the recurring period. |
|
420 | + * |
|
421 | + * @since 1.0.19 |
|
422 | + * @param bool $full Return abbreviation or in full. |
|
423 | + * @return string |
|
424 | + */ |
|
425 | + public function get_recurring_period( $full = false ) { |
|
426 | 426 | $period = $this->get_prop( 'recurring_period', 'view' ); |
427 | 427 | |
428 | 428 | if ( $full && ! is_bool( $full ) ) { |
@@ -433,63 +433,63 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
436 | - * Get the recurring interval. |
|
437 | - * |
|
438 | - * @since 1.0.19 |
|
439 | - * @param string $context View or edit context. |
|
440 | - * @return int |
|
441 | - */ |
|
442 | - public function get_recurring_interval( $context = 'view' ) { |
|
443 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
436 | + * Get the recurring interval. |
|
437 | + * |
|
438 | + * @since 1.0.19 |
|
439 | + * @param string $context View or edit context. |
|
440 | + * @return int |
|
441 | + */ |
|
442 | + public function get_recurring_interval( $context = 'view' ) { |
|
443 | + $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
444 | 444 | |
445 | - if ( $interval < 1 ) { |
|
446 | - $interval = 1; |
|
447 | - } |
|
445 | + if ( $interval < 1 ) { |
|
446 | + $interval = 1; |
|
447 | + } |
|
448 | 448 | |
449 | 449 | return $interval; |
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
453 | - * Get the recurring limit. |
|
454 | - * |
|
455 | - * @since 1.0.19 |
|
456 | - * @param string $context View or edit context. |
|
457 | - * @return int |
|
458 | - */ |
|
459 | - public function get_recurring_limit( $context = 'view' ) { |
|
453 | + * Get the recurring limit. |
|
454 | + * |
|
455 | + * @since 1.0.19 |
|
456 | + * @param string $context View or edit context. |
|
457 | + * @return int |
|
458 | + */ |
|
459 | + public function get_recurring_limit( $context = 'view' ) { |
|
460 | 460 | return (int) $this->get_prop( 'recurring_limit', $context ); |
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
464 | - * Checks if we have a free trial. |
|
465 | - * |
|
466 | - * @since 1.0.19 |
|
467 | - * @param string $context View or edit context. |
|
468 | - * @return int |
|
469 | - */ |
|
470 | - public function get_is_free_trial( $context = 'view' ) { |
|
464 | + * Checks if we have a free trial. |
|
465 | + * |
|
466 | + * @since 1.0.19 |
|
467 | + * @param string $context View or edit context. |
|
468 | + * @return int |
|
469 | + */ |
|
470 | + public function get_is_free_trial( $context = 'view' ) { |
|
471 | 471 | return (int) $this->get_prop( 'is_free_trial', $context ); |
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
475 | - * Alias for self::get_is_free_trial(). |
|
476 | - * |
|
477 | - * @since 1.0.19 |
|
478 | - * @param string $context View or edit context. |
|
479 | - * @return int |
|
480 | - */ |
|
481 | - public function get_free_trial( $context = 'view' ) { |
|
475 | + * Alias for self::get_is_free_trial(). |
|
476 | + * |
|
477 | + * @since 1.0.19 |
|
478 | + * @param string $context View or edit context. |
|
479 | + * @return int |
|
480 | + */ |
|
481 | + public function get_free_trial( $context = 'view' ) { |
|
482 | 482 | return $this->get_is_free_trial( $context ); |
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
486 | - * Get the trial period. |
|
487 | - * |
|
488 | - * @since 1.0.19 |
|
489 | - * @param bool $full Return abbreviation or in full. |
|
490 | - * @return string |
|
491 | - */ |
|
492 | - public function get_trial_period( $full = false ) { |
|
486 | + * Get the trial period. |
|
487 | + * |
|
488 | + * @since 1.0.19 |
|
489 | + * @param bool $full Return abbreviation or in full. |
|
490 | + * @return string |
|
491 | + */ |
|
492 | + public function get_trial_period( $full = false ) { |
|
493 | 493 | $period = $this->get_prop( 'trial_period', 'view' ); |
494 | 494 | |
495 | 495 | if ( $full && ! is_bool( $full ) ) { |
@@ -500,13 +500,13 @@ discard block |
||
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
503 | - * Get the trial interval. |
|
504 | - * |
|
505 | - * @since 1.0.19 |
|
506 | - * @param string $context View or edit context. |
|
507 | - * @return int |
|
508 | - */ |
|
509 | - public function get_trial_interval( $context = 'view' ) { |
|
503 | + * Get the trial interval. |
|
504 | + * |
|
505 | + * @since 1.0.19 |
|
506 | + * @param string $context View or edit context. |
|
507 | + * @return int |
|
508 | + */ |
|
509 | + public function get_trial_interval( $context = 'view' ) { |
|
510 | 510 | return (int) $this->get_prop( 'trial_interval', $context ); |
511 | 511 | } |
512 | 512 | |
@@ -540,52 +540,52 @@ discard block |
||
540 | 540 | */ |
541 | 541 | |
542 | 542 | /** |
543 | - * Set parent order ID. |
|
544 | - * |
|
545 | - * @since 1.0.19 |
|
546 | - */ |
|
547 | - public function set_parent_id( $value ) { |
|
548 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
549 | - return; |
|
550 | - } |
|
551 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
552 | - } |
|
553 | - |
|
554 | - /** |
|
555 | - * Sets item status. |
|
556 | - * |
|
557 | - * @since 1.0.19 |
|
558 | - * @param string $status New status. |
|
559 | - * @return array details of change. |
|
560 | - */ |
|
561 | - public function set_status( $status ) { |
|
543 | + * Set parent order ID. |
|
544 | + * |
|
545 | + * @since 1.0.19 |
|
546 | + */ |
|
547 | + public function set_parent_id( $value ) { |
|
548 | + if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
549 | + return; |
|
550 | + } |
|
551 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
552 | + } |
|
553 | + |
|
554 | + /** |
|
555 | + * Sets item status. |
|
556 | + * |
|
557 | + * @since 1.0.19 |
|
558 | + * @param string $status New status. |
|
559 | + * @return array details of change. |
|
560 | + */ |
|
561 | + public function set_status( $status ) { |
|
562 | 562 | $old_status = $this->get_status(); |
563 | 563 | |
564 | 564 | $this->set_prop( 'status', $status ); |
565 | 565 | |
566 | - return array( |
|
567 | - 'from' => $old_status, |
|
568 | - 'to' => $status, |
|
569 | - ); |
|
566 | + return array( |
|
567 | + 'from' => $old_status, |
|
568 | + 'to' => $status, |
|
569 | + ); |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | /** |
573 | - * Set plugin version when the item was created. |
|
574 | - * |
|
575 | - * @since 1.0.19 |
|
576 | - */ |
|
577 | - public function set_version( $value ) { |
|
578 | - $this->set_prop( 'version', $value ); |
|
573 | + * Set plugin version when the item was created. |
|
574 | + * |
|
575 | + * @since 1.0.19 |
|
576 | + */ |
|
577 | + public function set_version( $value ) { |
|
578 | + $this->set_prop( 'version', $value ); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
582 | - * Set date when the item was created. |
|
583 | - * |
|
584 | - * @since 1.0.19 |
|
585 | - * @param string $value Value to set. |
|
582 | + * Set date when the item was created. |
|
583 | + * |
|
584 | + * @since 1.0.19 |
|
585 | + * @param string $value Value to set. |
|
586 | 586 | * @return bool Whether or not the date was set. |
587 | - */ |
|
588 | - public function set_date_created( $value ) { |
|
587 | + */ |
|
588 | + public function set_date_created( $value ) { |
|
589 | 589 | $date = strtotime( $value ); |
590 | 590 | |
591 | 591 | if ( $date ) { |
@@ -598,13 +598,13 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
601 | - * Set date when the item was last modified. |
|
602 | - * |
|
603 | - * @since 1.0.19 |
|
604 | - * @param string $value Value to set. |
|
601 | + * Set date when the item was last modified. |
|
602 | + * |
|
603 | + * @since 1.0.19 |
|
604 | + * @param string $value Value to set. |
|
605 | 605 | * @return bool Whether or not the date was set. |
606 | - */ |
|
607 | - public function set_date_modified( $value ) { |
|
606 | + */ |
|
607 | + public function set_date_modified( $value ) { |
|
608 | 608 | $date = strtotime( $value ); |
609 | 609 | |
610 | 610 | if ( $date ) { |
@@ -617,105 +617,105 @@ discard block |
||
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
620 | - * Set the item name. |
|
621 | - * |
|
622 | - * @since 1.0.19 |
|
623 | - * @param string $value New name. |
|
624 | - */ |
|
625 | - public function set_name( $value ) { |
|
620 | + * Set the item name. |
|
621 | + * |
|
622 | + * @since 1.0.19 |
|
623 | + * @param string $value New name. |
|
624 | + */ |
|
625 | + public function set_name( $value ) { |
|
626 | 626 | $name = sanitize_text_field( $value ); |
627 | - $this->set_prop( 'name', $name ); |
|
627 | + $this->set_prop( 'name', $name ); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
631 | - * Alias of self::set_name(). |
|
632 | - * |
|
633 | - * @since 1.0.19 |
|
634 | - * @param string $value New name. |
|
635 | - */ |
|
636 | - public function set_title( $value ) { |
|
637 | - $this->set_name( $value ); |
|
631 | + * Alias of self::set_name(). |
|
632 | + * |
|
633 | + * @since 1.0.19 |
|
634 | + * @param string $value New name. |
|
635 | + */ |
|
636 | + public function set_title( $value ) { |
|
637 | + $this->set_name( $value ); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
641 | - * Set the item description. |
|
642 | - * |
|
643 | - * @since 1.0.19 |
|
644 | - * @param string $value New description. |
|
645 | - */ |
|
646 | - public function set_description( $value ) { |
|
641 | + * Set the item description. |
|
642 | + * |
|
643 | + * @since 1.0.19 |
|
644 | + * @param string $value New description. |
|
645 | + */ |
|
646 | + public function set_description( $value ) { |
|
647 | 647 | $description = wp_kses_post( $value ); |
648 | - return $this->set_prop( 'description', $description ); |
|
648 | + return $this->set_prop( 'description', $description ); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
652 | - * Alias of self::set_description(). |
|
653 | - * |
|
654 | - * @since 1.0.19 |
|
655 | - * @param string $value New description. |
|
656 | - */ |
|
657 | - public function set_excerpt( $value ) { |
|
658 | - $this->set_description( $value ); |
|
652 | + * Alias of self::set_description(). |
|
653 | + * |
|
654 | + * @since 1.0.19 |
|
655 | + * @param string $value New description. |
|
656 | + */ |
|
657 | + public function set_excerpt( $value ) { |
|
658 | + $this->set_description( $value ); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
662 | - * Alias of self::set_description(). |
|
663 | - * |
|
664 | - * @since 1.0.19 |
|
665 | - * @param string $value New description. |
|
666 | - */ |
|
667 | - public function set_summary( $value ) { |
|
668 | - $this->set_description( $value ); |
|
662 | + * Alias of self::set_description(). |
|
663 | + * |
|
664 | + * @since 1.0.19 |
|
665 | + * @param string $value New description. |
|
666 | + */ |
|
667 | + public function set_summary( $value ) { |
|
668 | + $this->set_description( $value ); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
672 | - * Set the owner of the item. |
|
673 | - * |
|
674 | - * @since 1.0.19 |
|
675 | - * @param int $value New author. |
|
676 | - */ |
|
677 | - public function set_author( $value ) { |
|
678 | - $this->set_prop( 'author', (int) $value ); |
|
672 | + * Set the owner of the item. |
|
673 | + * |
|
674 | + * @since 1.0.19 |
|
675 | + * @param int $value New author. |
|
676 | + */ |
|
677 | + public function set_author( $value ) { |
|
678 | + $this->set_prop( 'author', (int) $value ); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | - * Set the price of the item. |
|
683 | - * |
|
684 | - * @since 1.0.19 |
|
685 | - * @param float $value New price. |
|
682 | + * Set the price of the item. |
|
683 | + * |
|
684 | + * @since 1.0.19 |
|
685 | + * @param float $value New price. |
|
686 | 686 | ] */ |
687 | - public function set_price( $value ) { |
|
687 | + public function set_price( $value ) { |
|
688 | 688 | $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
692 | - * Set the VAT rule of the item. |
|
693 | - * |
|
694 | - * @since 1.0.19 |
|
695 | - * @param string $value new rule. |
|
696 | - */ |
|
697 | - public function set_vat_rule( $value ) { |
|
692 | + * Set the VAT rule of the item. |
|
693 | + * |
|
694 | + * @since 1.0.19 |
|
695 | + * @param string $value new rule. |
|
696 | + */ |
|
697 | + public function set_vat_rule( $value ) { |
|
698 | 698 | $this->set_prop( 'vat_rule', $value ); |
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | - * Set the VAT class of the item. |
|
703 | - * |
|
704 | - * @since 1.0.19 |
|
705 | - * @param string $value new class. |
|
706 | - */ |
|
707 | - public function set_vat_class( $value ) { |
|
702 | + * Set the VAT class of the item. |
|
703 | + * |
|
704 | + * @since 1.0.19 |
|
705 | + * @param string $value new class. |
|
706 | + */ |
|
707 | + public function set_vat_class( $value ) { |
|
708 | 708 | $this->set_prop( 'vat_class', $value ); |
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
712 | - * Set the type of the item. |
|
713 | - * |
|
714 | - * @since 1.0.19 |
|
715 | - * @param string $value new item type. |
|
716 | - * @return string |
|
717 | - */ |
|
718 | - public function set_type( $value ) { |
|
712 | + * Set the type of the item. |
|
713 | + * |
|
714 | + * @since 1.0.19 |
|
715 | + * @param string $value new item type. |
|
716 | + * @return string |
|
717 | + */ |
|
718 | + public function set_type( $value ) { |
|
719 | 719 | |
720 | 720 | if ( empty( $value ) ) { |
721 | 721 | $value = 'custom'; |
@@ -725,134 +725,134 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
728 | - * Set the custom id of the item. |
|
729 | - * |
|
730 | - * @since 1.0.19 |
|
731 | - * @param string $value new custom id. |
|
732 | - */ |
|
733 | - public function set_custom_id( $value ) { |
|
728 | + * Set the custom id of the item. |
|
729 | + * |
|
730 | + * @since 1.0.19 |
|
731 | + * @param string $value new custom id. |
|
732 | + */ |
|
733 | + public function set_custom_id( $value ) { |
|
734 | 734 | $this->set_prop( 'custom_id', $value ); |
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
738 | - * Set the custom name of the item. |
|
739 | - * |
|
740 | - * @since 1.0.19 |
|
741 | - * @param string $value new custom name. |
|
742 | - */ |
|
743 | - public function set_custom_name( $value ) { |
|
738 | + * Set the custom name of the item. |
|
739 | + * |
|
740 | + * @since 1.0.19 |
|
741 | + * @param string $value new custom name. |
|
742 | + */ |
|
743 | + public function set_custom_name( $value ) { |
|
744 | 744 | $this->set_prop( 'custom_name', $value ); |
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
748 | - * Set the custom singular name of the item. |
|
749 | - * |
|
750 | - * @since 1.0.19 |
|
751 | - * @param string $value new custom singular name. |
|
752 | - */ |
|
753 | - public function set_custom_singular_name( $value ) { |
|
748 | + * Set the custom singular name of the item. |
|
749 | + * |
|
750 | + * @since 1.0.19 |
|
751 | + * @param string $value new custom singular name. |
|
752 | + */ |
|
753 | + public function set_custom_singular_name( $value ) { |
|
754 | 754 | $this->set_prop( 'custom_singular_name', $value ); |
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
758 | - * Sets if an item is editable.. |
|
759 | - * |
|
760 | - * @since 1.0.19 |
|
761 | - * @param int|bool $value whether or not the item is editable. |
|
762 | - */ |
|
763 | - public function set_is_editable( $value ) { |
|
764 | - if ( is_numeric( $value ) ) { |
|
765 | - $this->set_prop( 'is_editable', (int) $value ); |
|
766 | - } |
|
758 | + * Sets if an item is editable.. |
|
759 | + * |
|
760 | + * @since 1.0.19 |
|
761 | + * @param int|bool $value whether or not the item is editable. |
|
762 | + */ |
|
763 | + public function set_is_editable( $value ) { |
|
764 | + if ( is_numeric( $value ) ) { |
|
765 | + $this->set_prop( 'is_editable', (int) $value ); |
|
766 | + } |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
770 | - * Sets if dynamic pricing is enabled. |
|
771 | - * |
|
772 | - * @since 1.0.19 |
|
773 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
774 | - */ |
|
775 | - public function set_is_dynamic_pricing( $value ) { |
|
770 | + * Sets if dynamic pricing is enabled. |
|
771 | + * |
|
772 | + * @since 1.0.19 |
|
773 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
774 | + */ |
|
775 | + public function set_is_dynamic_pricing( $value ) { |
|
776 | 776 | $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
780 | - * Sets the minimum price if dynamic pricing is enabled. |
|
781 | - * |
|
782 | - * @since 1.0.19 |
|
783 | - * @param float $value minimum price. |
|
784 | - */ |
|
785 | - public function set_minimum_price( $value ) { |
|
780 | + * Sets the minimum price if dynamic pricing is enabled. |
|
781 | + * |
|
782 | + * @since 1.0.19 |
|
783 | + * @param float $value minimum price. |
|
784 | + */ |
|
785 | + public function set_minimum_price( $value ) { |
|
786 | 786 | $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
790 | - * Sets if this is a recurring item. |
|
791 | - * |
|
792 | - * @since 1.0.19 |
|
793 | - * @param int|bool $value whether or not dynamic pricing is allowed. |
|
794 | - */ |
|
795 | - public function set_is_recurring( $value ) { |
|
790 | + * Sets if this is a recurring item. |
|
791 | + * |
|
792 | + * @since 1.0.19 |
|
793 | + * @param int|bool $value whether or not dynamic pricing is allowed. |
|
794 | + */ |
|
795 | + public function set_is_recurring( $value ) { |
|
796 | 796 | $this->set_prop( 'is_recurring', (int) $value ); |
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
800 | - * Set the recurring period. |
|
801 | - * |
|
802 | - * @since 1.0.19 |
|
803 | - * @param string $value new period. |
|
804 | - */ |
|
805 | - public function set_recurring_period( $value ) { |
|
800 | + * Set the recurring period. |
|
801 | + * |
|
802 | + * @since 1.0.19 |
|
803 | + * @param string $value new period. |
|
804 | + */ |
|
805 | + public function set_recurring_period( $value ) { |
|
806 | 806 | $this->set_prop( 'recurring_period', $value ); |
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
810 | - * Set the recurring interval. |
|
811 | - * |
|
812 | - * @since 1.0.19 |
|
813 | - * @param int $value recurring interval. |
|
814 | - */ |
|
815 | - public function set_recurring_interval( $value ) { |
|
810 | + * Set the recurring interval. |
|
811 | + * |
|
812 | + * @since 1.0.19 |
|
813 | + * @param int $value recurring interval. |
|
814 | + */ |
|
815 | + public function set_recurring_interval( $value ) { |
|
816 | 816 | return $this->set_prop( 'recurring_interval', (int) $value ); |
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
820 | - * Get the recurring limit. |
|
821 | - * @since 1.0.19 |
|
822 | - * @param int $value The recurring limit. |
|
823 | - * @return int |
|
824 | - */ |
|
825 | - public function set_recurring_limit( $value ) { |
|
820 | + * Get the recurring limit. |
|
821 | + * @since 1.0.19 |
|
822 | + * @param int $value The recurring limit. |
|
823 | + * @return int |
|
824 | + */ |
|
825 | + public function set_recurring_limit( $value ) { |
|
826 | 826 | $this->set_prop( 'recurring_limit', (int) $value ); |
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
830 | - * Checks if we have a free trial. |
|
831 | - * |
|
832 | - * @since 1.0.19 |
|
833 | - * @param int|bool $value whether or not it has a free trial. |
|
834 | - */ |
|
835 | - public function set_is_free_trial( $value ) { |
|
830 | + * Checks if we have a free trial. |
|
831 | + * |
|
832 | + * @since 1.0.19 |
|
833 | + * @param int|bool $value whether or not it has a free trial. |
|
834 | + */ |
|
835 | + public function set_is_free_trial( $value ) { |
|
836 | 836 | $this->set_prop( 'is_free_trial', (int) $value ); |
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
840 | - * Set the trial period. |
|
841 | - * |
|
842 | - * @since 1.0.19 |
|
843 | - * @param string $value trial period. |
|
844 | - */ |
|
845 | - public function set_trial_period( $value ) { |
|
840 | + * Set the trial period. |
|
841 | + * |
|
842 | + * @since 1.0.19 |
|
843 | + * @param string $value trial period. |
|
844 | + */ |
|
845 | + public function set_trial_period( $value ) { |
|
846 | 846 | $this->set_prop( 'trial_period', $value ); |
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
850 | - * Set the trial interval. |
|
851 | - * |
|
852 | - * @since 1.0.19 |
|
853 | - * @param int $value trial interval. |
|
854 | - */ |
|
855 | - public function set_trial_interval( $value ) { |
|
850 | + * Set the trial interval. |
|
851 | + * |
|
852 | + * @since 1.0.19 |
|
853 | + * @param int $value trial interval. |
|
854 | + */ |
|
855 | + public function set_trial_interval( $value ) { |
|
856 | 856 | $this->set_prop( 'trial_interval', $value ); |
857 | 857 | } |
858 | 858 | |
@@ -863,15 +863,15 @@ discard block |
||
863 | 863 | */ |
864 | 864 | public function create( $data = array() ) { |
865 | 865 | |
866 | - // Set the properties. |
|
867 | - if ( is_array( $data ) ) { |
|
868 | - $this->set_props( $data ); |
|
869 | - } |
|
866 | + // Set the properties. |
|
867 | + if ( is_array( $data ) ) { |
|
868 | + $this->set_props( $data ); |
|
869 | + } |
|
870 | 870 | |
871 | - // Save the item. |
|
872 | - $this->save(); |
|
871 | + // Save the item. |
|
872 | + $this->save(); |
|
873 | 873 | |
874 | - return true; |
|
874 | + return true; |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /** |
@@ -893,84 +893,84 @@ discard block |
||
893 | 893 | */ |
894 | 894 | |
895 | 895 | /** |
896 | - * Checks whether the item has enabled dynamic pricing. |
|
897 | - * |
|
898 | - * @since 1.0.19 |
|
899 | - * @return bool |
|
900 | - */ |
|
901 | - public function user_can_set_their_price() { |
|
896 | + * Checks whether the item has enabled dynamic pricing. |
|
897 | + * |
|
898 | + * @since 1.0.19 |
|
899 | + * @return bool |
|
900 | + */ |
|
901 | + public function user_can_set_their_price() { |
|
902 | 902 | return (bool) $this->get_is_dynamic_pricing(); |
903 | - } |
|
903 | + } |
|
904 | 904 | |
905 | - /** |
|
906 | - * Checks whether the item is recurring. |
|
907 | - * |
|
908 | - * @since 1.0.19 |
|
909 | - * @return bool |
|
910 | - */ |
|
911 | - public function is_recurring() { |
|
905 | + /** |
|
906 | + * Checks whether the item is recurring. |
|
907 | + * |
|
908 | + * @since 1.0.19 |
|
909 | + * @return bool |
|
910 | + */ |
|
911 | + public function is_recurring() { |
|
912 | 912 | return (bool) $this->get_is_recurring(); |
913 | 913 | } |
914 | 914 | |
915 | 915 | /** |
916 | - * Checks whether the item has a free trial. |
|
917 | - * |
|
918 | - * @since 1.0.19 |
|
919 | - * @return bool |
|
920 | - */ |
|
916 | + * Checks whether the item has a free trial. |
|
917 | + * |
|
918 | + * @since 1.0.19 |
|
919 | + * @return bool |
|
920 | + */ |
|
921 | 921 | public function has_free_trial() { |
922 | 922 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
923 | 923 | return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
927 | - * Checks whether the item is free. |
|
928 | - * |
|
929 | - * @since 1.0.19 |
|
930 | - * @return bool |
|
931 | - */ |
|
927 | + * Checks whether the item is free. |
|
928 | + * |
|
929 | + * @since 1.0.19 |
|
930 | + * @return bool |
|
931 | + */ |
|
932 | 932 | public function is_free() { |
933 | 933 | $is_free = $this->get_price() == 0; |
934 | 934 | return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
938 | - * Checks the item status against a passed in status. |
|
939 | - * |
|
940 | - * @param array|string $status Status to check. |
|
941 | - * @return bool |
|
942 | - */ |
|
943 | - public function has_status( $status ) { |
|
944 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
945 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
938 | + * Checks the item status against a passed in status. |
|
939 | + * |
|
940 | + * @param array|string $status Status to check. |
|
941 | + * @return bool |
|
942 | + */ |
|
943 | + public function has_status( $status ) { |
|
944 | + $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
945 | + return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | /** |
949 | - * Checks the item type against a passed in types. |
|
950 | - * |
|
951 | - * @param array|string $type Type to check. |
|
952 | - * @return bool |
|
953 | - */ |
|
954 | - public function is_type( $type ) { |
|
955 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
956 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
957 | - } |
|
949 | + * Checks the item type against a passed in types. |
|
950 | + * |
|
951 | + * @param array|string $type Type to check. |
|
952 | + * @return bool |
|
953 | + */ |
|
954 | + public function is_type( $type ) { |
|
955 | + $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
956 | + return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
957 | + } |
|
958 | 958 | |
959 | 959 | /** |
960 | - * Checks whether the item is editable. |
|
961 | - * |
|
962 | - * @since 1.0.19 |
|
963 | - * @return bool |
|
964 | - */ |
|
960 | + * Checks whether the item is editable. |
|
961 | + * |
|
962 | + * @since 1.0.19 |
|
963 | + * @return bool |
|
964 | + */ |
|
965 | 965 | public function is_editable() { |
966 | 966 | $is_editable = $this->get_is_editable(); |
967 | 967 | return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
968 | - } |
|
968 | + } |
|
969 | 969 | |
970 | - /** |
|
971 | - * Returns an array of cart fees. |
|
972 | - */ |
|
973 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
970 | + /** |
|
971 | + * Returns an array of cart fees. |
|
972 | + */ |
|
973 | + public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
974 | 974 | global $wpi_session; |
975 | 975 | |
976 | 976 | $fees = $wpi_session->get( 'wpi_cart_fees' ); |
@@ -1014,11 +1014,11 @@ discard block |
||
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
1017 | - * Checks whether the item is purchasable. |
|
1018 | - * |
|
1019 | - * @since 1.0.19 |
|
1020 | - * @return bool |
|
1021 | - */ |
|
1017 | + * Checks whether the item is purchasable. |
|
1018 | + * |
|
1019 | + * @since 1.0.19 |
|
1020 | + * @return bool |
|
1021 | + */ |
|
1022 | 1022 | public function can_purchase() { |
1023 | 1023 | $can_purchase = null !== $this->get_id(); |
1024 | 1024 | |
@@ -1030,11 +1030,11 @@ discard block |
||
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
1033 | - * Checks whether the item supports dynamic pricing. |
|
1034 | - * |
|
1035 | - * @since 1.0.19 |
|
1036 | - * @return bool |
|
1037 | - */ |
|
1033 | + * Checks whether the item supports dynamic pricing. |
|
1034 | + * |
|
1035 | + * @since 1.0.19 |
|
1036 | + * @return bool |
|
1037 | + */ |
|
1038 | 1038 | public function supports_dynamic_pricing() { |
1039 | 1039 | return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
1040 | 1040 | } |
@@ -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,26 +78,26 @@ 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 ); |
|
81 | + public function __construct($item = 0) { |
|
82 | + parent::__construct($item); |
|
83 | 83 | |
84 | - if ( is_numeric( $item ) && $item > 0 ) { |
|
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 ); |
|
84 | + if (is_numeric($item) && $item > 0) { |
|
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 | 90 | } else { |
91 | - $this->set_object_read( true ); |
|
91 | + $this->set_object_read(true); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | // Load the datastore. |
95 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
95 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
96 | 96 | |
97 | - if ( $this->get_id() > 0 ) { |
|
98 | - $this->post = get_post( $this->get_id() ); |
|
97 | + if ($this->get_id() > 0) { |
|
98 | + $this->post = get_post($this->get_id()); |
|
99 | 99 | $this->ID = $this->get_id(); |
100 | - $this->data_store->read( $this ); |
|
100 | + $this->data_store->read($this); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | } |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * @param string $context View or edit context. |
125 | 125 | * @return int |
126 | 126 | */ |
127 | - public function get_parent_id( $context = 'view' ) { |
|
128 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
127 | + public function get_parent_id($context = 'view') { |
|
128 | + return (int) $this->get_prop('parent_id', $context); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -135,8 +135,8 @@ discard block |
||
135 | 135 | * @param string $context View or edit context. |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - public function get_status( $context = 'view' ) { |
|
139 | - return $this->get_prop( 'status', $context ); |
|
138 | + public function get_status($context = 'view') { |
|
139 | + return $this->get_prop('status', $context); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param string $context View or edit context. |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function get_version( $context = 'view' ) { |
|
150 | - return $this->get_prop( 'version', $context ); |
|
149 | + public function get_version($context = 'view') { |
|
150 | + return $this->get_prop('version', $context); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @param string $context View or edit context. |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function get_date_created( $context = 'view' ) { |
|
161 | - return $this->get_prop( 'date_created', $context ); |
|
160 | + public function get_date_created($context = 'view') { |
|
161 | + return $this->get_prop('date_created', $context); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $context View or edit context. |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function get_date_created_gmt( $context = 'view' ) { |
|
172 | - $date = $this->get_date_created( $context ); |
|
171 | + public function get_date_created_gmt($context = 'view') { |
|
172 | + $date = $this->get_date_created($context); |
|
173 | 173 | |
174 | - if ( $date ) { |
|
175 | - $date = get_gmt_from_date( $date ); |
|
174 | + if ($date) { |
|
175 | + $date = get_gmt_from_date($date); |
|
176 | 176 | } |
177 | 177 | return $date; |
178 | 178 | } |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @param string $context View or edit context. |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public function get_date_modified( $context = 'view' ) { |
|
188 | - return $this->get_prop( 'date_modified', $context ); |
|
187 | + public function get_date_modified($context = 'view') { |
|
188 | + return $this->get_prop('date_modified', $context); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | * @param string $context View or edit context. |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
199 | - $date = $this->get_date_modified( $context ); |
|
198 | + public function get_date_modified_gmt($context = 'view') { |
|
199 | + $date = $this->get_date_modified($context); |
|
200 | 200 | |
201 | - if ( $date ) { |
|
202 | - $date = get_gmt_from_date( $date ); |
|
201 | + if ($date) { |
|
202 | + $date = get_gmt_from_date($date); |
|
203 | 203 | } |
204 | 204 | return $date; |
205 | 205 | } |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | * @param string $context View or edit context. |
212 | 212 | * @return string |
213 | 213 | */ |
214 | - public function get_name( $context = 'view' ) { |
|
215 | - return $this->get_prop( 'name', $context ); |
|
214 | + public function get_name($context = 'view') { |
|
215 | + return $this->get_prop('name', $context); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -222,8 +222,8 @@ discard block |
||
222 | 222 | * @param string $context View or edit context. |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public function get_title( $context = 'view' ) { |
|
226 | - return $this->get_name( $context ); |
|
225 | + public function get_title($context = 'view') { |
|
226 | + return $this->get_name($context); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @param string $context View or edit context. |
234 | 234 | * @return string |
235 | 235 | */ |
236 | - public function get_description( $context = 'view' ) { |
|
237 | - return $this->get_prop( 'description', $context ); |
|
236 | + public function get_description($context = 'view') { |
|
237 | + return $this->get_prop('description', $context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return string |
246 | 246 | */ |
247 | - public function get_excerpt( $context = 'view' ) { |
|
248 | - return $this->get_description( $context ); |
|
247 | + public function get_excerpt($context = 'view') { |
|
248 | + return $this->get_description($context); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return string |
257 | 257 | */ |
258 | - public function get_summary( $context = 'view' ) { |
|
259 | - return $this->get_description( $context ); |
|
258 | + public function get_summary($context = 'view') { |
|
259 | + return $this->get_description($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function get_author( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'author', $context ); |
|
269 | + public function get_author($context = 'view') { |
|
270 | + return (int) $this->get_prop('author', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return float |
279 | 279 | */ |
280 | - public function get_price( $context = 'view' ) { |
|
281 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'price', $context ) ); |
|
280 | + public function get_price($context = 'view') { |
|
281 | + return (float) wpinv_sanitize_amount($this->get_prop('price', $context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -289,9 +289,9 @@ discard block |
||
289 | 289 | * @return string |
290 | 290 | */ |
291 | 291 | public function get_the_price() { |
292 | - $item_price = wpinv_price( wpinv_format_amount( $this->get_price() ) ); |
|
292 | + $item_price = wpinv_price(wpinv_format_amount($this->get_price())); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID ); |
|
294 | + return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_vat_rule( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'vat_rule', $context ); |
|
304 | + public function get_vat_rule($context = 'view') { |
|
305 | + return $this->get_prop('vat_rule', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public function get_vat_class( $context = 'view' ) { |
|
316 | - return $this->get_prop( 'vat_class', $context ); |
|
315 | + public function get_vat_class($context = 'view') { |
|
316 | + return $this->get_prop('vat_class', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return string |
325 | 325 | */ |
326 | - public function get_type( $context = 'view' ) { |
|
327 | - return $this->get_prop( 'type', $context ); |
|
326 | + public function get_type($context = 'view') { |
|
327 | + return $this->get_prop('type', $context); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | - public function get_custom_id( $context = 'view' ) { |
|
338 | - return $this->get_prop( 'custom_id', $context ); |
|
337 | + public function get_custom_id($context = 'view') { |
|
338 | + return $this->get_prop('custom_id', $context); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return string |
347 | 347 | */ |
348 | - public function get_custom_name( $context = 'view' ) { |
|
349 | - return $this->get_prop( 'custom_name', $context ); |
|
348 | + public function get_custom_name($context = 'view') { |
|
349 | + return $this->get_prop('custom_name', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_custom_singular_name( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'custom_singular_name', $context ); |
|
359 | + public function get_custom_singular_name($context = 'view') { |
|
360 | + return $this->get_prop('custom_singular_name', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return int |
369 | 369 | */ |
370 | - public function get_is_editable( $context = 'view' ) { |
|
371 | - return (int) $this->get_prop( 'is_editable', $context ); |
|
370 | + public function get_is_editable($context = 'view') { |
|
371 | + return (int) $this->get_prop('is_editable', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return int |
380 | 380 | */ |
381 | - public function get_editable( $context = 'view' ) { |
|
382 | - return $this->get_is_editable( $context ); |
|
381 | + public function get_editable($context = 'view') { |
|
382 | + return $this->get_is_editable($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @param string $context View or edit context. |
390 | 390 | * @return int |
391 | 391 | */ |
392 | - public function get_is_dynamic_pricing( $context = 'view' ) { |
|
393 | - return (int) $this->get_prop( 'is_dynamic_pricing', $context ); |
|
392 | + public function get_is_dynamic_pricing($context = 'view') { |
|
393 | + return (int) $this->get_prop('is_dynamic_pricing', $context); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return float |
402 | 402 | */ |
403 | - public function get_minimum_price( $context = 'view' ) { |
|
404 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) ); |
|
403 | + public function get_minimum_price($context = 'view') { |
|
404 | + return (float) wpinv_sanitize_amount($this->get_prop('minimum_price', $context)); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param string $context View or edit context. |
412 | 412 | * @return int |
413 | 413 | */ |
414 | - public function get_is_recurring( $context = 'view' ) { |
|
415 | - return (int) $this->get_prop( 'is_recurring', $context ); |
|
414 | + public function get_is_recurring($context = 'view') { |
|
415 | + return (int) $this->get_prop('is_recurring', $context); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | * @param bool $full Return abbreviation or in full. |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public function get_recurring_period( $full = false ) { |
|
426 | - $period = $this->get_prop( 'recurring_period', 'view' ); |
|
425 | + public function get_recurring_period($full = false) { |
|
426 | + $period = $this->get_prop('recurring_period', 'view'); |
|
427 | 427 | |
428 | - if ( $full && ! is_bool( $full ) ) { |
|
428 | + if ($full && !is_bool($full)) { |
|
429 | 429 | $full = false; |
430 | 430 | } |
431 | 431 | |
432 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
432 | + return getpaid_sanitize_recurring_period($period, $full); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | /** |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | * @param string $context View or edit context. |
440 | 440 | * @return int |
441 | 441 | */ |
442 | - public function get_recurring_interval( $context = 'view' ) { |
|
443 | - $interval = absint( $this->get_prop( 'recurring_interval', $context ) ); |
|
442 | + public function get_recurring_interval($context = 'view') { |
|
443 | + $interval = absint($this->get_prop('recurring_interval', $context)); |
|
444 | 444 | |
445 | - if ( $interval < 1 ) { |
|
445 | + if ($interval < 1) { |
|
446 | 446 | $interval = 1; |
447 | 447 | } |
448 | 448 | |
@@ -456,8 +456,8 @@ discard block |
||
456 | 456 | * @param string $context View or edit context. |
457 | 457 | * @return int |
458 | 458 | */ |
459 | - public function get_recurring_limit( $context = 'view' ) { |
|
460 | - return (int) $this->get_prop( 'recurring_limit', $context ); |
|
459 | + public function get_recurring_limit($context = 'view') { |
|
460 | + return (int) $this->get_prop('recurring_limit', $context); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | * @param string $context View or edit context. |
468 | 468 | * @return int |
469 | 469 | */ |
470 | - public function get_is_free_trial( $context = 'view' ) { |
|
471 | - return (int) $this->get_prop( 'is_free_trial', $context ); |
|
470 | + public function get_is_free_trial($context = 'view') { |
|
471 | + return (int) $this->get_prop('is_free_trial', $context); |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | /** |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $context View or edit context. |
479 | 479 | * @return int |
480 | 480 | */ |
481 | - public function get_free_trial( $context = 'view' ) { |
|
482 | - return $this->get_is_free_trial( $context ); |
|
481 | + public function get_free_trial($context = 'view') { |
|
482 | + return $this->get_is_free_trial($context); |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | /** |
@@ -489,14 +489,14 @@ discard block |
||
489 | 489 | * @param bool $full Return abbreviation or in full. |
490 | 490 | * @return string |
491 | 491 | */ |
492 | - public function get_trial_period( $full = false ) { |
|
493 | - $period = $this->get_prop( 'trial_period', 'view' ); |
|
492 | + public function get_trial_period($full = false) { |
|
493 | + $period = $this->get_prop('trial_period', 'view'); |
|
494 | 494 | |
495 | - if ( $full && ! is_bool( $full ) ) { |
|
495 | + if ($full && !is_bool($full)) { |
|
496 | 496 | $full = false; |
497 | 497 | } |
498 | 498 | |
499 | - return getpaid_sanitize_recurring_period( $period, $full ); |
|
499 | + return getpaid_sanitize_recurring_period($period, $full); |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -506,26 +506,26 @@ discard block |
||
506 | 506 | * @param string $context View or edit context. |
507 | 507 | * @return int |
508 | 508 | */ |
509 | - public function get_trial_interval( $context = 'view' ) { |
|
510 | - return (int) $this->get_prop( 'trial_interval', $context ); |
|
509 | + public function get_trial_interval($context = 'view') { |
|
510 | + return (int) $this->get_prop('trial_interval', $context); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
514 | 514 | * Margic method for retrieving a property. |
515 | 515 | */ |
516 | - public function __get( $key ) { |
|
516 | + public function __get($key) { |
|
517 | 517 | |
518 | 518 | // Check if we have a helper method for that. |
519 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
520 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
519 | + if (method_exists($this, 'get_' . $key)) { |
|
520 | + return call_user_func(array($this, 'get_' . $key)); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | // Check if the key is in the associated $post object. |
524 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
524 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
525 | 525 | return $this->post->$key; |
526 | 526 | } |
527 | 527 | |
528 | - return $this->get_prop( $key ); |
|
528 | + return $this->get_prop($key); |
|
529 | 529 | |
530 | 530 | } |
531 | 531 | |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @since 1.0.19 |
546 | 546 | */ |
547 | - public function set_parent_id( $value ) { |
|
548 | - if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) { |
|
547 | + public function set_parent_id($value) { |
|
548 | + if ($value && ($value === $this->get_id() || !get_post($value))) { |
|
549 | 549 | return; |
550 | 550 | } |
551 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
551 | + $this->set_prop('parent_id', absint($value)); |
|
552 | 552 | } |
553 | 553 | |
554 | 554 | /** |
@@ -558,10 +558,10 @@ discard block |
||
558 | 558 | * @param string $status New status. |
559 | 559 | * @return array details of change. |
560 | 560 | */ |
561 | - public function set_status( $status ) { |
|
561 | + public function set_status($status) { |
|
562 | 562 | $old_status = $this->get_status(); |
563 | 563 | |
564 | - $this->set_prop( 'status', $status ); |
|
564 | + $this->set_prop('status', $status); |
|
565 | 565 | |
566 | 566 | return array( |
567 | 567 | 'from' => $old_status, |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | * |
575 | 575 | * @since 1.0.19 |
576 | 576 | */ |
577 | - public function set_version( $value ) { |
|
578 | - $this->set_prop( 'version', $value ); |
|
577 | + public function set_version($value) { |
|
578 | + $this->set_prop('version', $value); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * @param string $value Value to set. |
586 | 586 | * @return bool Whether or not the date was set. |
587 | 587 | */ |
588 | - public function set_date_created( $value ) { |
|
589 | - $date = strtotime( $value ); |
|
588 | + public function set_date_created($value) { |
|
589 | + $date = strtotime($value); |
|
590 | 590 | |
591 | - if ( $date ) { |
|
592 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
591 | + if ($date) { |
|
592 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
593 | 593 | return true; |
594 | 594 | } |
595 | 595 | |
@@ -604,11 +604,11 @@ discard block |
||
604 | 604 | * @param string $value Value to set. |
605 | 605 | * @return bool Whether or not the date was set. |
606 | 606 | */ |
607 | - public function set_date_modified( $value ) { |
|
608 | - $date = strtotime( $value ); |
|
607 | + public function set_date_modified($value) { |
|
608 | + $date = strtotime($value); |
|
609 | 609 | |
610 | - if ( $date ) { |
|
611 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
610 | + if ($date) { |
|
611 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
612 | 612 | return true; |
613 | 613 | } |
614 | 614 | |
@@ -622,9 +622,9 @@ discard block |
||
622 | 622 | * @since 1.0.19 |
623 | 623 | * @param string $value New name. |
624 | 624 | */ |
625 | - public function set_name( $value ) { |
|
626 | - $name = sanitize_text_field( $value ); |
|
627 | - $this->set_prop( 'name', $name ); |
|
625 | + public function set_name($value) { |
|
626 | + $name = sanitize_text_field($value); |
|
627 | + $this->set_prop('name', $name); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -633,8 +633,8 @@ discard block |
||
633 | 633 | * @since 1.0.19 |
634 | 634 | * @param string $value New name. |
635 | 635 | */ |
636 | - public function set_title( $value ) { |
|
637 | - $this->set_name( $value ); |
|
636 | + public function set_title($value) { |
|
637 | + $this->set_name($value); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @since 1.0.19 |
644 | 644 | * @param string $value New description. |
645 | 645 | */ |
646 | - public function set_description( $value ) { |
|
647 | - $description = wp_kses_post( $value ); |
|
648 | - return $this->set_prop( 'description', $description ); |
|
646 | + public function set_description($value) { |
|
647 | + $description = wp_kses_post($value); |
|
648 | + return $this->set_prop('description', $description); |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | /** |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | * @since 1.0.19 |
655 | 655 | * @param string $value New description. |
656 | 656 | */ |
657 | - public function set_excerpt( $value ) { |
|
658 | - $this->set_description( $value ); |
|
657 | + public function set_excerpt($value) { |
|
658 | + $this->set_description($value); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | * @since 1.0.19 |
665 | 665 | * @param string $value New description. |
666 | 666 | */ |
667 | - public function set_summary( $value ) { |
|
668 | - $this->set_description( $value ); |
|
667 | + public function set_summary($value) { |
|
668 | + $this->set_description($value); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -674,8 +674,8 @@ discard block |
||
674 | 674 | * @since 1.0.19 |
675 | 675 | * @param int $value New author. |
676 | 676 | */ |
677 | - public function set_author( $value ) { |
|
678 | - $this->set_prop( 'author', (int) $value ); |
|
677 | + public function set_author($value) { |
|
678 | + $this->set_prop('author', (int) $value); |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
@@ -684,8 +684,8 @@ discard block |
||
684 | 684 | * @since 1.0.19 |
685 | 685 | * @param float $value New price. |
686 | 686 | ] */ |
687 | - public function set_price( $value ) { |
|
688 | - $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) ); |
|
687 | + public function set_price($value) { |
|
688 | + $this->set_prop('price', (float) wpinv_sanitize_amount($value)); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | /** |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | * @since 1.0.19 |
695 | 695 | * @param string $value new rule. |
696 | 696 | */ |
697 | - public function set_vat_rule( $value ) { |
|
698 | - $this->set_prop( 'vat_rule', $value ); |
|
697 | + public function set_vat_rule($value) { |
|
698 | + $this->set_prop('vat_rule', $value); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
@@ -704,8 +704,8 @@ discard block |
||
704 | 704 | * @since 1.0.19 |
705 | 705 | * @param string $value new class. |
706 | 706 | */ |
707 | - public function set_vat_class( $value ) { |
|
708 | - $this->set_prop( 'vat_class', $value ); |
|
707 | + public function set_vat_class($value) { |
|
708 | + $this->set_prop('vat_class', $value); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | /** |
@@ -715,13 +715,13 @@ discard block |
||
715 | 715 | * @param string $value new item type. |
716 | 716 | * @return string |
717 | 717 | */ |
718 | - public function set_type( $value ) { |
|
718 | + public function set_type($value) { |
|
719 | 719 | |
720 | - if ( empty( $value ) ) { |
|
720 | + if (empty($value)) { |
|
721 | 721 | $value = 'custom'; |
722 | 722 | } |
723 | 723 | |
724 | - $this->set_prop( 'type', $value ); |
|
724 | + $this->set_prop('type', $value); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @since 1.0.19 |
731 | 731 | * @param string $value new custom id. |
732 | 732 | */ |
733 | - public function set_custom_id( $value ) { |
|
734 | - $this->set_prop( 'custom_id', $value ); |
|
733 | + public function set_custom_id($value) { |
|
734 | + $this->set_prop('custom_id', $value); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -740,8 +740,8 @@ discard block |
||
740 | 740 | * @since 1.0.19 |
741 | 741 | * @param string $value new custom name. |
742 | 742 | */ |
743 | - public function set_custom_name( $value ) { |
|
744 | - $this->set_prop( 'custom_name', $value ); |
|
743 | + public function set_custom_name($value) { |
|
744 | + $this->set_prop('custom_name', $value); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | * @since 1.0.19 |
751 | 751 | * @param string $value new custom singular name. |
752 | 752 | */ |
753 | - public function set_custom_singular_name( $value ) { |
|
754 | - $this->set_prop( 'custom_singular_name', $value ); |
|
753 | + public function set_custom_singular_name($value) { |
|
754 | + $this->set_prop('custom_singular_name', $value); |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -760,9 +760,9 @@ discard block |
||
760 | 760 | * @since 1.0.19 |
761 | 761 | * @param int|bool $value whether or not the item is editable. |
762 | 762 | */ |
763 | - public function set_is_editable( $value ) { |
|
764 | - if ( is_numeric( $value ) ) { |
|
765 | - $this->set_prop( 'is_editable', (int) $value ); |
|
763 | + public function set_is_editable($value) { |
|
764 | + if (is_numeric($value)) { |
|
765 | + $this->set_prop('is_editable', (int) $value); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
@@ -772,8 +772,8 @@ discard block |
||
772 | 772 | * @since 1.0.19 |
773 | 773 | * @param int|bool $value whether or not dynamic pricing is allowed. |
774 | 774 | */ |
775 | - public function set_is_dynamic_pricing( $value ) { |
|
776 | - $this->set_prop( 'is_dynamic_pricing', (int) $value ); |
|
775 | + public function set_is_dynamic_pricing($value) { |
|
776 | + $this->set_prop('is_dynamic_pricing', (int) $value); |
|
777 | 777 | } |
778 | 778 | |
779 | 779 | /** |
@@ -782,8 +782,8 @@ discard block |
||
782 | 782 | * @since 1.0.19 |
783 | 783 | * @param float $value minimum price. |
784 | 784 | */ |
785 | - public function set_minimum_price( $value ) { |
|
786 | - $this->set_prop( 'minimum_price', (float) wpinv_sanitize_amount( $value ) ); |
|
785 | + public function set_minimum_price($value) { |
|
786 | + $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value)); |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | * @since 1.0.19 |
793 | 793 | * @param int|bool $value whether or not dynamic pricing is allowed. |
794 | 794 | */ |
795 | - public function set_is_recurring( $value ) { |
|
796 | - $this->set_prop( 'is_recurring', (int) $value ); |
|
795 | + public function set_is_recurring($value) { |
|
796 | + $this->set_prop('is_recurring', (int) $value); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | * @since 1.0.19 |
803 | 803 | * @param string $value new period. |
804 | 804 | */ |
805 | - public function set_recurring_period( $value ) { |
|
806 | - $this->set_prop( 'recurring_period', $value ); |
|
805 | + public function set_recurring_period($value) { |
|
806 | + $this->set_prop('recurring_period', $value); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | * @since 1.0.19 |
813 | 813 | * @param int $value recurring interval. |
814 | 814 | */ |
815 | - public function set_recurring_interval( $value ) { |
|
816 | - return $this->set_prop( 'recurring_interval', (int) $value ); |
|
815 | + public function set_recurring_interval($value) { |
|
816 | + return $this->set_prop('recurring_interval', (int) $value); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | /** |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | * @param int $value The recurring limit. |
823 | 823 | * @return int |
824 | 824 | */ |
825 | - public function set_recurring_limit( $value ) { |
|
826 | - $this->set_prop( 'recurring_limit', (int) $value ); |
|
825 | + public function set_recurring_limit($value) { |
|
826 | + $this->set_prop('recurring_limit', (int) $value); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @since 1.0.19 |
833 | 833 | * @param int|bool $value whether or not it has a free trial. |
834 | 834 | */ |
835 | - public function set_is_free_trial( $value ) { |
|
836 | - $this->set_prop( 'is_free_trial', (int) $value ); |
|
835 | + public function set_is_free_trial($value) { |
|
836 | + $this->set_prop('is_free_trial', (int) $value); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | * @since 1.0.19 |
843 | 843 | * @param string $value trial period. |
844 | 844 | */ |
845 | - public function set_trial_period( $value ) { |
|
846 | - $this->set_prop( 'trial_period', $value ); |
|
845 | + public function set_trial_period($value) { |
|
846 | + $this->set_prop('trial_period', $value); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
@@ -852,8 +852,8 @@ discard block |
||
852 | 852 | * @since 1.0.19 |
853 | 853 | * @param int $value trial interval. |
854 | 854 | */ |
855 | - public function set_trial_interval( $value ) { |
|
856 | - $this->set_prop( 'trial_interval', $value ); |
|
855 | + public function set_trial_interval($value) { |
|
856 | + $this->set_prop('trial_interval', $value); |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | /** |
@@ -861,11 +861,11 @@ discard block |
||
861 | 861 | * |
862 | 862 | * @deprecated |
863 | 863 | */ |
864 | - public function create( $data = array() ) { |
|
864 | + public function create($data = array()) { |
|
865 | 865 | |
866 | 866 | // Set the properties. |
867 | - if ( is_array( $data ) ) { |
|
868 | - $this->set_props( $data ); |
|
867 | + if (is_array($data)) { |
|
868 | + $this->set_props($data); |
|
869 | 869 | } |
870 | 870 | |
871 | 871 | // Save the item. |
@@ -879,8 +879,8 @@ discard block |
||
879 | 879 | * |
880 | 880 | * @deprecated |
881 | 881 | */ |
882 | - public function update( $data = array() ) { |
|
883 | - $this->create( $data ); |
|
882 | + public function update($data = array()) { |
|
883 | + $this->create($data); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /* |
@@ -920,7 +920,7 @@ discard block |
||
920 | 920 | */ |
921 | 921 | public function has_free_trial() { |
922 | 922 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
923 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
923 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
924 | 924 | } |
925 | 925 | |
926 | 926 | /** |
@@ -930,8 +930,8 @@ discard block |
||
930 | 930 | * @return bool |
931 | 931 | */ |
932 | 932 | public function is_free() { |
933 | - $is_free = $this->get_price() == 0; |
|
934 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
933 | + $is_free = $this->get_price() == 0; |
|
934 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | /** |
@@ -940,9 +940,9 @@ discard block |
||
940 | 940 | * @param array|string $status Status to check. |
941 | 941 | * @return bool |
942 | 942 | */ |
943 | - public function has_status( $status ) { |
|
944 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
945 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
943 | + public function has_status($status) { |
|
944 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
945 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | /** |
@@ -951,9 +951,9 @@ discard block |
||
951 | 951 | * @param array|string $type Type to check. |
952 | 952 | * @return bool |
953 | 953 | */ |
954 | - public function is_type( $type ) { |
|
955 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
956 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
954 | + public function is_type($type) { |
|
955 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
956 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
957 | 957 | } |
958 | 958 | |
959 | 959 | /** |
@@ -964,53 +964,53 @@ discard block |
||
964 | 964 | */ |
965 | 965 | public function is_editable() { |
966 | 966 | $is_editable = $this->get_is_editable(); |
967 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
967 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | /** |
971 | 971 | * Returns an array of cart fees. |
972 | 972 | */ |
973 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
973 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
974 | 974 | global $wpi_session; |
975 | 975 | |
976 | - $fees = $wpi_session->get( 'wpi_cart_fees' ); |
|
976 | + $fees = $wpi_session->get('wpi_cart_fees'); |
|
977 | 977 | |
978 | - if ( ! wpinv_get_cart_contents() ) { |
|
978 | + if (!wpinv_get_cart_contents()) { |
|
979 | 979 | // We can only get item type fees when the cart is empty |
980 | 980 | $type = 'custom'; |
981 | 981 | } |
982 | 982 | |
983 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
984 | - foreach( $fees as $key => $fee ) { |
|
985 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
986 | - unset( $fees[ $key ] ); |
|
983 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
984 | + foreach ($fees as $key => $fee) { |
|
985 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
986 | + unset($fees[$key]); |
|
987 | 987 | } |
988 | 988 | } |
989 | 989 | } |
990 | 990 | |
991 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
991 | + if (!empty($fees) && !empty($item_id)) { |
|
992 | 992 | // Remove fees that don't belong to the specified Item |
993 | - foreach ( $fees as $key => $fee ) { |
|
994 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
995 | - unset( $fees[ $key ] ); |
|
993 | + foreach ($fees as $key => $fee) { |
|
994 | + if ((int) $item_id !== (int) $fee['custom_id']) { |
|
995 | + unset($fees[$key]); |
|
996 | 996 | } |
997 | 997 | } |
998 | 998 | } |
999 | 999 | |
1000 | - if ( ! empty( $fees ) ) { |
|
1000 | + if (!empty($fees)) { |
|
1001 | 1001 | // Remove fees that belong to a specific item but are not in the cart |
1002 | - foreach( $fees as $key => $fee ) { |
|
1003 | - if( empty( $fee['custom_id'] ) ) { |
|
1002 | + foreach ($fees as $key => $fee) { |
|
1003 | + if (empty($fee['custom_id'])) { |
|
1004 | 1004 | continue; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
1008 | - unset( $fees[ $key ] ); |
|
1007 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
1008 | + unset($fees[$key]); |
|
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | |
1013 | - return ! empty( $fees ) ? $fees : array(); |
|
1013 | + return !empty($fees) ? $fees : array(); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | /** |
@@ -1022,11 +1022,11 @@ discard block |
||
1022 | 1022 | public function can_purchase() { |
1023 | 1023 | $can_purchase = null !== $this->get_id(); |
1024 | 1024 | |
1025 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1025 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1026 | 1026 | $can_purchase = false; |
1027 | 1027 | } |
1028 | 1028 | |
1029 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1029 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -1036,6 +1036,6 @@ discard block |
||
1036 | 1036 | * @return bool |
1037 | 1037 | */ |
1038 | 1038 | public function supports_dynamic_pricing() { |
1039 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1039 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1040 | 1040 | } |
1041 | 1041 | } |