@@ -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 | |
@@ -860,17 +860,17 @@ discard block |
||
860 | 860 | * Create an item. For backwards compatibilty. |
861 | 861 | * |
862 | 862 | * @deprecated |
863 | - * @return int item id |
|
863 | + * @return int item id |
|
864 | 864 | */ |
865 | 865 | public function create( $data = array() ) { |
866 | 866 | |
867 | - // Set the properties. |
|
868 | - if ( is_array( $data ) ) { |
|
869 | - $this->set_props( $data ); |
|
870 | - } |
|
867 | + // Set the properties. |
|
868 | + if ( is_array( $data ) ) { |
|
869 | + $this->set_props( $data ); |
|
870 | + } |
|
871 | 871 | |
872 | - // Save the item. |
|
873 | - return $this->save(); |
|
872 | + // Save the item. |
|
873 | + return $this->save(); |
|
874 | 874 | |
875 | 875 | } |
876 | 876 | |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | * Updates an item. For backwards compatibilty. |
879 | 879 | * |
880 | 880 | * @deprecated |
881 | - * @return int item id |
|
881 | + * @return int item id |
|
882 | 882 | */ |
883 | 883 | public function update( $data = array() ) { |
884 | 884 | return $this->create( $data ); |
@@ -894,84 +894,84 @@ discard block |
||
894 | 894 | */ |
895 | 895 | |
896 | 896 | /** |
897 | - * Checks whether the item has enabled dynamic pricing. |
|
898 | - * |
|
899 | - * @since 1.0.19 |
|
900 | - * @return bool |
|
901 | - */ |
|
902 | - public function user_can_set_their_price() { |
|
897 | + * Checks whether the item has enabled dynamic pricing. |
|
898 | + * |
|
899 | + * @since 1.0.19 |
|
900 | + * @return bool |
|
901 | + */ |
|
902 | + public function user_can_set_their_price() { |
|
903 | 903 | return (bool) $this->get_is_dynamic_pricing(); |
904 | - } |
|
904 | + } |
|
905 | 905 | |
906 | - /** |
|
907 | - * Checks whether the item is recurring. |
|
908 | - * |
|
909 | - * @since 1.0.19 |
|
910 | - * @return bool |
|
911 | - */ |
|
912 | - public function is_recurring() { |
|
906 | + /** |
|
907 | + * Checks whether the item is recurring. |
|
908 | + * |
|
909 | + * @since 1.0.19 |
|
910 | + * @return bool |
|
911 | + */ |
|
912 | + public function is_recurring() { |
|
913 | 913 | return (bool) $this->get_is_recurring(); |
914 | 914 | } |
915 | 915 | |
916 | 916 | /** |
917 | - * Checks whether the item has a free trial. |
|
918 | - * |
|
919 | - * @since 1.0.19 |
|
920 | - * @return bool |
|
921 | - */ |
|
917 | + * Checks whether the item has a free trial. |
|
918 | + * |
|
919 | + * @since 1.0.19 |
|
920 | + * @return bool |
|
921 | + */ |
|
922 | 922 | public function has_free_trial() { |
923 | 923 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
924 | 924 | return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
928 | - * Checks whether the item is free. |
|
929 | - * |
|
930 | - * @since 1.0.19 |
|
931 | - * @return bool |
|
932 | - */ |
|
928 | + * Checks whether the item is free. |
|
929 | + * |
|
930 | + * @since 1.0.19 |
|
931 | + * @return bool |
|
932 | + */ |
|
933 | 933 | public function is_free() { |
934 | 934 | $is_free = $this->get_price() == 0; |
935 | 935 | return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
939 | - * Checks the item status against a passed in status. |
|
940 | - * |
|
941 | - * @param array|string $status Status to check. |
|
942 | - * @return bool |
|
943 | - */ |
|
944 | - public function has_status( $status ) { |
|
945 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
946 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
939 | + * Checks the item status against a passed in status. |
|
940 | + * |
|
941 | + * @param array|string $status Status to check. |
|
942 | + * @return bool |
|
943 | + */ |
|
944 | + public function has_status( $status ) { |
|
945 | + $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
946 | + return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
950 | - * Checks the item type against a passed in types. |
|
951 | - * |
|
952 | - * @param array|string $type Type to check. |
|
953 | - * @return bool |
|
954 | - */ |
|
955 | - public function is_type( $type ) { |
|
956 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
957 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
958 | - } |
|
950 | + * Checks the item type against a passed in types. |
|
951 | + * |
|
952 | + * @param array|string $type Type to check. |
|
953 | + * @return bool |
|
954 | + */ |
|
955 | + public function is_type( $type ) { |
|
956 | + $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
957 | + return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
958 | + } |
|
959 | 959 | |
960 | 960 | /** |
961 | - * Checks whether the item is editable. |
|
962 | - * |
|
963 | - * @since 1.0.19 |
|
964 | - * @return bool |
|
965 | - */ |
|
961 | + * Checks whether the item is editable. |
|
962 | + * |
|
963 | + * @since 1.0.19 |
|
964 | + * @return bool |
|
965 | + */ |
|
966 | 966 | public function is_editable() { |
967 | 967 | $is_editable = $this->get_is_editable(); |
968 | 968 | return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
969 | - } |
|
969 | + } |
|
970 | 970 | |
971 | - /** |
|
972 | - * Returns an array of cart fees. |
|
973 | - */ |
|
974 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
971 | + /** |
|
972 | + * Returns an array of cart fees. |
|
973 | + */ |
|
974 | + public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
975 | 975 | global $wpi_session; |
976 | 976 | |
977 | 977 | $fees = $wpi_session->get( 'wpi_cart_fees' ); |
@@ -1015,11 +1015,11 @@ discard block |
||
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /** |
1018 | - * Checks whether the item is purchasable. |
|
1019 | - * |
|
1020 | - * @since 1.0.19 |
|
1021 | - * @return bool |
|
1022 | - */ |
|
1018 | + * Checks whether the item is purchasable. |
|
1019 | + * |
|
1020 | + * @since 1.0.19 |
|
1021 | + * @return bool |
|
1022 | + */ |
|
1023 | 1023 | public function can_purchase() { |
1024 | 1024 | $can_purchase = null !== $this->get_id(); |
1025 | 1025 | |
@@ -1031,11 +1031,11 @@ discard block |
||
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
1034 | - * Checks whether the item supports dynamic pricing. |
|
1035 | - * |
|
1036 | - * @since 1.0.19 |
|
1037 | - * @return bool |
|
1038 | - */ |
|
1034 | + * Checks whether the item supports dynamic pricing. |
|
1035 | + * |
|
1036 | + * @since 1.0.19 |
|
1037 | + * @return bool |
|
1038 | + */ |
|
1039 | 1039 | public function supports_dynamic_pricing() { |
1040 | 1040 | return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
1041 | 1041 | } |
@@ -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 | /** |
@@ -862,11 +862,11 @@ discard block |
||
862 | 862 | * @deprecated |
863 | 863 | * @return int item id |
864 | 864 | */ |
865 | - public function create( $data = array() ) { |
|
865 | + public function create($data = array()) { |
|
866 | 866 | |
867 | 867 | // Set the properties. |
868 | - if ( is_array( $data ) ) { |
|
869 | - $this->set_props( $data ); |
|
868 | + if (is_array($data)) { |
|
869 | + $this->set_props($data); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | // Save the item. |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @deprecated |
881 | 881 | * @return int item id |
882 | 882 | */ |
883 | - public function update( $data = array() ) { |
|
884 | - return $this->create( $data ); |
|
883 | + public function update($data = array()) { |
|
884 | + return $this->create($data); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /* |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | */ |
922 | 922 | public function has_free_trial() { |
923 | 923 | $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false; |
924 | - return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this ); |
|
924 | + return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | * @return bool |
932 | 932 | */ |
933 | 933 | public function is_free() { |
934 | - $is_free = $this->get_price() == 0; |
|
935 | - return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this ); |
|
934 | + $is_free = $this->get_price() == 0; |
|
935 | + return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -941,9 +941,9 @@ discard block |
||
941 | 941 | * @param array|string $status Status to check. |
942 | 942 | * @return bool |
943 | 943 | */ |
944 | - public function has_status( $status ) { |
|
945 | - $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status; |
|
946 | - return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status ); |
|
944 | + public function has_status($status) { |
|
945 | + $has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status; |
|
946 | + return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
@@ -952,9 +952,9 @@ discard block |
||
952 | 952 | * @param array|string $type Type to check. |
953 | 953 | * @return bool |
954 | 954 | */ |
955 | - public function is_type( $type ) { |
|
956 | - $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type; |
|
957 | - return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type ); |
|
955 | + public function is_type($type) { |
|
956 | + $is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type; |
|
957 | + return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type); |
|
958 | 958 | } |
959 | 959 | |
960 | 960 | /** |
@@ -965,53 +965,53 @@ discard block |
||
965 | 965 | */ |
966 | 966 | public function is_editable() { |
967 | 967 | $is_editable = $this->get_is_editable(); |
968 | - return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this ); |
|
968 | + return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | /** |
972 | 972 | * Returns an array of cart fees. |
973 | 973 | */ |
974 | - public function get_fees( $type = 'fee', $item_id = 0 ) { |
|
974 | + public function get_fees($type = 'fee', $item_id = 0) { |
|
975 | 975 | global $wpi_session; |
976 | 976 | |
977 | - $fees = $wpi_session->get( 'wpi_cart_fees' ); |
|
977 | + $fees = $wpi_session->get('wpi_cart_fees'); |
|
978 | 978 | |
979 | - if ( ! wpinv_get_cart_contents() ) { |
|
979 | + if (!wpinv_get_cart_contents()) { |
|
980 | 980 | // We can only get item type fees when the cart is empty |
981 | 981 | $type = 'custom'; |
982 | 982 | } |
983 | 983 | |
984 | - if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) { |
|
985 | - foreach( $fees as $key => $fee ) { |
|
986 | - if( ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
987 | - unset( $fees[ $key ] ); |
|
984 | + if (!empty($fees) && !empty($type) && 'all' !== $type) { |
|
985 | + foreach ($fees as $key => $fee) { |
|
986 | + if (!empty($fee['type']) && $type != $fee['type']) { |
|
987 | + unset($fees[$key]); |
|
988 | 988 | } |
989 | 989 | } |
990 | 990 | } |
991 | 991 | |
992 | - if ( ! empty( $fees ) && ! empty( $item_id ) ) { |
|
992 | + if (!empty($fees) && !empty($item_id)) { |
|
993 | 993 | // Remove fees that don't belong to the specified Item |
994 | - foreach ( $fees as $key => $fee ) { |
|
995 | - if ( (int) $item_id !== (int)$fee['custom_id'] ) { |
|
996 | - unset( $fees[ $key ] ); |
|
994 | + foreach ($fees as $key => $fee) { |
|
995 | + if ((int) $item_id !== (int) $fee['custom_id']) { |
|
996 | + unset($fees[$key]); |
|
997 | 997 | } |
998 | 998 | } |
999 | 999 | } |
1000 | 1000 | |
1001 | - if ( ! empty( $fees ) ) { |
|
1001 | + if (!empty($fees)) { |
|
1002 | 1002 | // Remove fees that belong to a specific item but are not in the cart |
1003 | - foreach( $fees as $key => $fee ) { |
|
1004 | - if( empty( $fee['custom_id'] ) ) { |
|
1003 | + foreach ($fees as $key => $fee) { |
|
1004 | + if (empty($fee['custom_id'])) { |
|
1005 | 1005 | continue; |
1006 | 1006 | } |
1007 | 1007 | |
1008 | - if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) { |
|
1009 | - unset( $fees[ $key ] ); |
|
1008 | + if (!wpinv_item_in_cart($fee['custom_id'])) { |
|
1009 | + unset($fees[$key]); |
|
1010 | 1010 | } |
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - return ! empty( $fees ) ? $fees : array(); |
|
1014 | + return !empty($fees) ? $fees : array(); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | /** |
@@ -1023,11 +1023,11 @@ discard block |
||
1023 | 1023 | public function can_purchase() { |
1024 | 1024 | $can_purchase = null !== $this->get_id(); |
1025 | 1025 | |
1026 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
1026 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
1027 | 1027 | $can_purchase = false; |
1028 | 1028 | } |
1029 | 1029 | |
1030 | - return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this ); |
|
1030 | + return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | /** |
@@ -1037,6 +1037,6 @@ discard block |
||
1037 | 1037 | * @return bool |
1038 | 1038 | */ |
1039 | 1039 | public function supports_dynamic_pricing() { |
1040 | - return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this ); |
|
1040 | + return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this); |
|
1041 | 1041 | } |
1042 | 1042 | } |
@@ -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,29 +10,29 @@ discard block |
||
10 | 10 | class GetPaid_Payment_Form 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 = 'payment_form'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'payment_form'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'payment_form'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Form Data array. This is the core form data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'status' => 'draft', |
|
34 | - 'version' => '', |
|
35 | - 'date_created' => null, |
|
27 | + * Form Data array. This is the core form data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'status' => 'draft', |
|
34 | + 'version' => '', |
|
35 | + 'date_created' => null, |
|
36 | 36 | 'date_modified' => null, |
37 | 37 | 'name' => '', |
38 | 38 | 'author' => 1, |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | ); |
42 | 42 | |
43 | 43 | /** |
44 | - * Stores meta in cache for future reads. |
|
45 | - * |
|
46 | - * A group must be set to to enable caching. |
|
47 | - * |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - protected $cache_group = 'getpaid_forms'; |
|
44 | + * Stores meta in cache for future reads. |
|
45 | + * |
|
46 | + * A group must be set to to enable caching. |
|
47 | + * |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + protected $cache_group = 'getpaid_forms'; |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Stores a reference to the original WP_Post object |
@@ -57,33 +57,33 @@ discard block |
||
57 | 57 | protected $post = null; |
58 | 58 | |
59 | 59 | /** |
60 | - * Get the item if ID is passed, otherwise the item is new and empty. |
|
61 | - * |
|
62 | - * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
63 | - */ |
|
64 | - public function __construct( $item = 0 ) { |
|
65 | - parent::__construct( $item ); |
|
66 | - |
|
67 | - if ( is_numeric( $item ) && $item > 0 ) { |
|
68 | - $this->set_id( $item ); |
|
69 | - } elseif ( $item instanceof self ) { |
|
70 | - $this->set_id( $item->get_id() ); |
|
71 | - } elseif ( ! empty( $item->ID ) ) { |
|
72 | - $this->set_id( $item->ID ); |
|
73 | - } else { |
|
74 | - $this->set_object_read( true ); |
|
75 | - } |
|
60 | + * Get the item if ID is passed, otherwise the item is new and empty. |
|
61 | + * |
|
62 | + * @param int|object|WPInv_Item|WP_Post $item Item to read. |
|
63 | + */ |
|
64 | + public function __construct( $item = 0 ) { |
|
65 | + parent::__construct( $item ); |
|
66 | + |
|
67 | + if ( is_numeric( $item ) && $item > 0 ) { |
|
68 | + $this->set_id( $item ); |
|
69 | + } elseif ( $item instanceof self ) { |
|
70 | + $this->set_id( $item->get_id() ); |
|
71 | + } elseif ( ! empty( $item->ID ) ) { |
|
72 | + $this->set_id( $item->ID ); |
|
73 | + } else { |
|
74 | + $this->set_object_read( true ); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | // Load the datastore. |
78 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
78 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
79 | 79 | |
80 | - if ( $this->get_id() > 0 ) { |
|
80 | + if ( $this->get_id() > 0 ) { |
|
81 | 81 | $this->post = get_post( $this->get_id() ); |
82 | 82 | $this->ID = $this->get_id(); |
83 | - $this->data_store->read( $this ); |
|
83 | + $this->data_store->read( $this ); |
|
84 | 84 | } |
85 | 85 | |
86 | - } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | /* |
89 | 89 | |-------------------------------------------------------------------------- |
@@ -101,190 +101,190 @@ discard block |
||
101 | 101 | */ |
102 | 102 | |
103 | 103 | /** |
104 | - * Get form status. |
|
105 | - * |
|
106 | - * @since 1.0.19 |
|
107 | - * @param string $context View or edit context. |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function get_status( $context = 'view' ) { |
|
111 | - return $this->get_prop( 'status', $context ); |
|
104 | + * Get form status. |
|
105 | + * |
|
106 | + * @since 1.0.19 |
|
107 | + * @param string $context View or edit context. |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function get_status( $context = 'view' ) { |
|
111 | + return $this->get_prop( 'status', $context ); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | - * Get plugin version when the form was created. |
|
116 | - * |
|
117 | - * @since 1.0.19 |
|
118 | - * @param string $context View or edit context. |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function get_version( $context = 'view' ) { |
|
122 | - return $this->get_prop( 'version', $context ); |
|
115 | + * Get plugin version when the form was created. |
|
116 | + * |
|
117 | + * @since 1.0.19 |
|
118 | + * @param string $context View or edit context. |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function get_version( $context = 'view' ) { |
|
122 | + return $this->get_prop( 'version', $context ); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Get date when the form was created. |
|
127 | - * |
|
128 | - * @since 1.0.19 |
|
129 | - * @param string $context View or edit context. |
|
130 | - * @return string |
|
131 | - */ |
|
132 | - public function get_date_created( $context = 'view' ) { |
|
133 | - return $this->get_prop( 'date_created', $context ); |
|
126 | + * Get date when the form was created. |
|
127 | + * |
|
128 | + * @since 1.0.19 |
|
129 | + * @param string $context View or edit context. |
|
130 | + * @return string |
|
131 | + */ |
|
132 | + public function get_date_created( $context = 'view' ) { |
|
133 | + return $this->get_prop( 'date_created', $context ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Get GMT date when the form was created. |
|
138 | - * |
|
139 | - * @since 1.0.19 |
|
140 | - * @param string $context View or edit context. |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function get_date_created_gmt( $context = 'view' ) { |
|
137 | + * Get GMT date when the form was created. |
|
138 | + * |
|
139 | + * @since 1.0.19 |
|
140 | + * @param string $context View or edit context. |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function get_date_created_gmt( $context = 'view' ) { |
|
144 | 144 | $date = $this->get_date_created( $context ); |
145 | 145 | |
146 | 146 | if ( $date ) { |
147 | 147 | $date = get_gmt_from_date( $date ); |
148 | 148 | } |
149 | - return $date; |
|
149 | + return $date; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | - * Get date when the form was last modified. |
|
154 | - * |
|
155 | - * @since 1.0.19 |
|
156 | - * @param string $context View or edit context. |
|
157 | - * @return string |
|
158 | - */ |
|
159 | - public function get_date_modified( $context = 'view' ) { |
|
160 | - return $this->get_prop( 'date_modified', $context ); |
|
153 | + * Get date when the form was last modified. |
|
154 | + * |
|
155 | + * @since 1.0.19 |
|
156 | + * @param string $context View or edit context. |
|
157 | + * @return string |
|
158 | + */ |
|
159 | + public function get_date_modified( $context = 'view' ) { |
|
160 | + return $this->get_prop( 'date_modified', $context ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
164 | - * Get GMT date when the form was last modified. |
|
165 | - * |
|
166 | - * @since 1.0.19 |
|
167 | - * @param string $context View or edit context. |
|
168 | - * @return string |
|
169 | - */ |
|
170 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
164 | + * Get GMT date when the form was last modified. |
|
165 | + * |
|
166 | + * @since 1.0.19 |
|
167 | + * @param string $context View or edit context. |
|
168 | + * @return string |
|
169 | + */ |
|
170 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
171 | 171 | $date = $this->get_date_modified( $context ); |
172 | 172 | |
173 | 173 | if ( $date ) { |
174 | 174 | $date = get_gmt_from_date( $date ); |
175 | 175 | } |
176 | - return $date; |
|
176 | + return $date; |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | - * Get the form name. |
|
181 | - * |
|
182 | - * @since 1.0.19 |
|
183 | - * @param string $context View or edit context. |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - public function get_name( $context = 'view' ) { |
|
187 | - return $this->get_prop( 'name', $context ); |
|
180 | + * Get the form name. |
|
181 | + * |
|
182 | + * @since 1.0.19 |
|
183 | + * @param string $context View or edit context. |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + public function get_name( $context = 'view' ) { |
|
187 | + return $this->get_prop( 'name', $context ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | - * Alias of self::get_name(). |
|
192 | - * |
|
193 | - * @since 1.0.19 |
|
194 | - * @param string $context View or edit context. |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function get_title( $context = 'view' ) { |
|
198 | - return $this->get_name( $context ); |
|
199 | - } |
|
191 | + * Alias of self::get_name(). |
|
192 | + * |
|
193 | + * @since 1.0.19 |
|
194 | + * @param string $context View or edit context. |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function get_title( $context = 'view' ) { |
|
198 | + return $this->get_name( $context ); |
|
199 | + } |
|
200 | 200 | |
201 | 201 | /** |
202 | - * Get the owner of the form. |
|
203 | - * |
|
204 | - * @since 1.0.19 |
|
205 | - * @param string $context View or edit context. |
|
206 | - * @return int |
|
207 | - */ |
|
208 | - public function get_author( $context = 'view' ) { |
|
209 | - return (int) $this->get_prop( 'author', $context ); |
|
202 | + * Get the owner of the form. |
|
203 | + * |
|
204 | + * @since 1.0.19 |
|
205 | + * @param string $context View or edit context. |
|
206 | + * @return int |
|
207 | + */ |
|
208 | + public function get_author( $context = 'view' ) { |
|
209 | + return (int) $this->get_prop( 'author', $context ); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | - * Get the elements that make up the form. |
|
214 | - * |
|
215 | - * @since 1.0.19 |
|
216 | - * @param string $context View or edit context. |
|
217 | - * @return array |
|
218 | - */ |
|
219 | - public function get_elements( $context = 'view' ) { |
|
220 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | - |
|
222 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
213 | + * Get the elements that make up the form. |
|
214 | + * |
|
215 | + * @since 1.0.19 |
|
216 | + * @param string $context View or edit context. |
|
217 | + * @return array |
|
218 | + */ |
|
219 | + public function get_elements( $context = 'view' ) { |
|
220 | + $elements = $this->get_prop( 'elements', $context ); |
|
221 | + |
|
222 | + if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
223 | 223 | return wpinv_get_data( 'sample-payment-form' ); |
224 | 224 | } |
225 | 225 | return $elements; |
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Get the items sold via the form. |
|
230 | - * |
|
231 | - * @since 1.0.19 |
|
232 | - * @param string $context View or edit context. |
|
233 | - * @return GetPaid_Form_Item[] |
|
234 | - */ |
|
235 | - public function get_items( $context = 'view' ) { |
|
236 | - $items = $this->get_prop( 'items', $context ); |
|
237 | - |
|
238 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Get the items sold via the form. |
|
230 | + * |
|
231 | + * @since 1.0.19 |
|
232 | + * @param string $context View or edit context. |
|
233 | + * @return GetPaid_Form_Item[] |
|
234 | + */ |
|
235 | + public function get_items( $context = 'view' ) { |
|
236 | + $items = $this->get_prop( 'items', $context ); |
|
237 | + |
|
238 | + if ( empty( $items ) || ! is_array( $items ) ) { |
|
239 | 239 | $items = wpinv_get_data( 'sample-payment-form-items' ); |
240 | 240 | } |
241 | 241 | |
242 | - // Convert the items. |
|
243 | - $prepared = array(); |
|
242 | + // Convert the items. |
|
243 | + $prepared = array(); |
|
244 | 244 | |
245 | - foreach ( $items as $key => $value ) { |
|
245 | + foreach ( $items as $key => $value ) { |
|
246 | 246 | |
247 | - // $item_id => $quantity |
|
248 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
249 | - $item = new GetPaid_Form_Item( $key ); |
|
247 | + // $item_id => $quantity |
|
248 | + if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
249 | + $item = new GetPaid_Form_Item( $key ); |
|
250 | 250 | |
251 | - if ( $item->can_purchase() ) { |
|
252 | - $item->set_quantity( $value ); |
|
253 | - $prepared[] = $item; |
|
254 | - } |
|
251 | + if ( $item->can_purchase() ) { |
|
252 | + $item->set_quantity( $value ); |
|
253 | + $prepared[] = $item; |
|
254 | + } |
|
255 | 255 | |
256 | - continue; |
|
257 | - } |
|
258 | - |
|
259 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
260 | - |
|
261 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
262 | - |
|
263 | - if ( ! $item->can_purchase() ) { |
|
264 | - continue; |
|
265 | - } |
|
266 | - |
|
267 | - // Cart items. |
|
268 | - if ( isset( $value['subtotal'] ) ) { |
|
269 | - $item->set_price( $value['subtotal'] ); |
|
270 | - $item->set_quantity( $value['quantity'] ); |
|
271 | - $prepared[] = $item; |
|
272 | - continue; |
|
273 | - } |
|
274 | - |
|
275 | - // Payment form item. |
|
276 | - $item->set_quantity( $value['quantity'] ); |
|
277 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
278 | - $item->set_is_required( $value['required'] ); |
|
279 | - $item->set_custom_description( $value['required'] ); |
|
280 | - $prepared[] = $item; |
|
281 | - continue; |
|
282 | - |
|
283 | - } |
|
284 | - } |
|
256 | + continue; |
|
257 | + } |
|
258 | + |
|
259 | + if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
260 | + |
|
261 | + $item = new GetPaid_Form_Item( $value['id'] ); |
|
262 | + |
|
263 | + if ( ! $item->can_purchase() ) { |
|
264 | + continue; |
|
265 | + } |
|
266 | + |
|
267 | + // Cart items. |
|
268 | + if ( isset( $value['subtotal'] ) ) { |
|
269 | + $item->set_price( $value['subtotal'] ); |
|
270 | + $item->set_quantity( $value['quantity'] ); |
|
271 | + $prepared[] = $item; |
|
272 | + continue; |
|
273 | + } |
|
274 | + |
|
275 | + // Payment form item. |
|
276 | + $item->set_quantity( $value['quantity'] ); |
|
277 | + $item->set_allow_quantities( $value['allow_quantities'] ); |
|
278 | + $item->set_is_required( $value['required'] ); |
|
279 | + $item->set_custom_description( $value['required'] ); |
|
280 | + $prepared[] = $item; |
|
281 | + continue; |
|
282 | + |
|
283 | + } |
|
284 | + } |
|
285 | 285 | |
286 | - return $prepared; |
|
287 | - } |
|
286 | + return $prepared; |
|
287 | + } |
|
288 | 288 | |
289 | 289 | /* |
290 | 290 | |-------------------------------------------------------------------------- |
@@ -297,40 +297,40 @@ discard block |
||
297 | 297 | */ |
298 | 298 | |
299 | 299 | /** |
300 | - * Sets item status. |
|
301 | - * |
|
302 | - * @since 1.0.19 |
|
303 | - * @param string $status New status. |
|
304 | - * @return array details of change. |
|
305 | - */ |
|
306 | - public function set_status( $status ) { |
|
300 | + * Sets item status. |
|
301 | + * |
|
302 | + * @since 1.0.19 |
|
303 | + * @param string $status New status. |
|
304 | + * @return array details of change. |
|
305 | + */ |
|
306 | + public function set_status( $status ) { |
|
307 | 307 | $old_status = $this->get_status(); |
308 | 308 | |
309 | 309 | $this->set_prop( 'status', $status ); |
310 | 310 | |
311 | - return array( |
|
312 | - 'from' => $old_status, |
|
313 | - 'to' => $status, |
|
314 | - ); |
|
311 | + return array( |
|
312 | + 'from' => $old_status, |
|
313 | + 'to' => $status, |
|
314 | + ); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | - * Set plugin version when the item was created. |
|
319 | - * |
|
320 | - * @since 1.0.19 |
|
321 | - */ |
|
322 | - public function set_version( $value ) { |
|
323 | - $this->set_prop( 'version', $value ); |
|
318 | + * Set plugin version when the item was created. |
|
319 | + * |
|
320 | + * @since 1.0.19 |
|
321 | + */ |
|
322 | + public function set_version( $value ) { |
|
323 | + $this->set_prop( 'version', $value ); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | - * Set date when the item was created. |
|
328 | - * |
|
329 | - * @since 1.0.19 |
|
330 | - * @param string $value Value to set. |
|
327 | + * Set date when the item was created. |
|
328 | + * |
|
329 | + * @since 1.0.19 |
|
330 | + * @param string $value Value to set. |
|
331 | 331 | * @return bool Whether or not the date was set. |
332 | - */ |
|
333 | - public function set_date_created( $value ) { |
|
332 | + */ |
|
333 | + public function set_date_created( $value ) { |
|
334 | 334 | $date = strtotime( $value ); |
335 | 335 | |
336 | 336 | if ( $date ) { |
@@ -343,13 +343,13 @@ discard block |
||
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
346 | - * Set date when the item was last modified. |
|
347 | - * |
|
348 | - * @since 1.0.19 |
|
349 | - * @param string $value Value to set. |
|
346 | + * Set date when the item was last modified. |
|
347 | + * |
|
348 | + * @since 1.0.19 |
|
349 | + * @param string $value Value to set. |
|
350 | 350 | * @return bool Whether or not the date was set. |
351 | - */ |
|
352 | - public function set_date_modified( $value ) { |
|
351 | + */ |
|
352 | + public function set_date_modified( $value ) { |
|
353 | 353 | $date = strtotime( $value ); |
354 | 354 | |
355 | 355 | if ( $date ) { |
@@ -362,71 +362,71 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
365 | - * Set the item name. |
|
366 | - * |
|
367 | - * @since 1.0.19 |
|
368 | - * @param string $value New name. |
|
369 | - */ |
|
370 | - public function set_name( $value ) { |
|
365 | + * Set the item name. |
|
366 | + * |
|
367 | + * @since 1.0.19 |
|
368 | + * @param string $value New name. |
|
369 | + */ |
|
370 | + public function set_name( $value ) { |
|
371 | 371 | $name = sanitize_text_field( $value ); |
372 | - $this->set_prop( 'name', $name ); |
|
372 | + $this->set_prop( 'name', $name ); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * Alias of self::set_name(). |
|
377 | - * |
|
378 | - * @since 1.0.19 |
|
379 | - * @param string $value New name. |
|
380 | - */ |
|
381 | - public function set_title( $value ) { |
|
382 | - $this->set_name( $value ); |
|
376 | + * Alias of self::set_name(). |
|
377 | + * |
|
378 | + * @since 1.0.19 |
|
379 | + * @param string $value New name. |
|
380 | + */ |
|
381 | + public function set_title( $value ) { |
|
382 | + $this->set_name( $value ); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
386 | - * Set the owner of the item. |
|
387 | - * |
|
388 | - * @since 1.0.19 |
|
389 | - * @param int $value New author. |
|
390 | - */ |
|
391 | - public function set_author( $value ) { |
|
392 | - $this->set_prop( 'author', (int) $value ); |
|
393 | - } |
|
386 | + * Set the owner of the item. |
|
387 | + * |
|
388 | + * @since 1.0.19 |
|
389 | + * @param int $value New author. |
|
390 | + */ |
|
391 | + public function set_author( $value ) { |
|
392 | + $this->set_prop( 'author', (int) $value ); |
|
393 | + } |
|
394 | 394 | |
395 | - /** |
|
396 | - * Set the form elements. |
|
397 | - * |
|
398 | - * @since 1.0.19 |
|
399 | - * @param array $elements Form elements. |
|
400 | - */ |
|
401 | - public function set_elements( $value ) { |
|
402 | - $this->set_prop( 'elements', $value ); |
|
403 | - } |
|
395 | + /** |
|
396 | + * Set the form elements. |
|
397 | + * |
|
398 | + * @since 1.0.19 |
|
399 | + * @param array $elements Form elements. |
|
400 | + */ |
|
401 | + public function set_elements( $value ) { |
|
402 | + $this->set_prop( 'elements', $value ); |
|
403 | + } |
|
404 | 404 | |
405 | - /** |
|
406 | - * Set the form items. |
|
407 | - * |
|
408 | - * @since 1.0.19 |
|
409 | - * @param array $elements Form elements. |
|
410 | - */ |
|
411 | - public function set_items( $value ) { |
|
412 | - $this->set_prop( 'items', $value ); |
|
405 | + /** |
|
406 | + * Set the form items. |
|
407 | + * |
|
408 | + * @since 1.0.19 |
|
409 | + * @param array $elements Form elements. |
|
410 | + */ |
|
411 | + public function set_items( $value ) { |
|
412 | + $this->set_prop( 'items', $value ); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
416 | 416 | * Create an item. For backwards compatibilty. |
417 | 417 | * |
418 | 418 | * @deprecated |
419 | - * @return int item id |
|
419 | + * @return int item id |
|
420 | 420 | */ |
421 | 421 | public function create( $data = array() ) { |
422 | 422 | |
423 | - // Set the properties. |
|
424 | - if ( is_array( $data ) ) { |
|
425 | - $this->set_props( $data ); |
|
426 | - } |
|
423 | + // Set the properties. |
|
424 | + if ( is_array( $data ) ) { |
|
425 | + $this->set_props( $data ); |
|
426 | + } |
|
427 | 427 | |
428 | - // Save the item. |
|
429 | - return $this->save(); |
|
428 | + // Save the item. |
|
429 | + return $this->save(); |
|
430 | 430 | |
431 | 431 | } |
432 | 432 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * Updates an item. For backwards compatibilty. |
435 | 435 | * |
436 | 436 | * @deprecated |
437 | - * @return int item id |
|
437 | + * @return int item id |
|
438 | 438 | */ |
439 | 439 | public function update( $data = array() ) { |
440 | 440 | return $this->create( $data ); |
@@ -450,22 +450,22 @@ discard block |
||
450 | 450 | */ |
451 | 451 | |
452 | 452 | /** |
453 | - * Checks whether this is the default payment form. |
|
454 | - * |
|
455 | - * @since 1.0.19 |
|
456 | - * @return bool |
|
457 | - */ |
|
453 | + * Checks whether this is the default payment form. |
|
454 | + * |
|
455 | + * @since 1.0.19 |
|
456 | + * @return bool |
|
457 | + */ |
|
458 | 458 | public function is_default() { |
459 | 459 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
460 | 460 | return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->ID, $this ); |
461 | - } |
|
461 | + } |
|
462 | 462 | |
463 | 463 | /** |
464 | - * Checks whether the form is active. |
|
465 | - * |
|
466 | - * @since 1.0.19 |
|
467 | - * @return bool |
|
468 | - */ |
|
464 | + * Checks whether the form is active. |
|
465 | + * |
|
466 | + * @since 1.0.19 |
|
467 | + * @return bool |
|
468 | + */ |
|
469 | 469 | public function is_active() { |
470 | 470 | $is_active = null !== $this->get_id(); |
471 | 471 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -61,26 +61,26 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param int|object|WPInv_Item|WP_Post $item Item to read. |
63 | 63 | */ |
64 | - public function __construct( $item = 0 ) { |
|
65 | - parent::__construct( $item ); |
|
66 | - |
|
67 | - if ( is_numeric( $item ) && $item > 0 ) { |
|
68 | - $this->set_id( $item ); |
|
69 | - } elseif ( $item instanceof self ) { |
|
70 | - $this->set_id( $item->get_id() ); |
|
71 | - } elseif ( ! empty( $item->ID ) ) { |
|
72 | - $this->set_id( $item->ID ); |
|
64 | + public function __construct($item = 0) { |
|
65 | + parent::__construct($item); |
|
66 | + |
|
67 | + if (is_numeric($item) && $item > 0) { |
|
68 | + $this->set_id($item); |
|
69 | + } elseif ($item instanceof self) { |
|
70 | + $this->set_id($item->get_id()); |
|
71 | + } elseif (!empty($item->ID)) { |
|
72 | + $this->set_id($item->ID); |
|
73 | 73 | } else { |
74 | - $this->set_object_read( true ); |
|
74 | + $this->set_object_read(true); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // Load the datastore. |
78 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
78 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
79 | 79 | |
80 | - if ( $this->get_id() > 0 ) { |
|
81 | - $this->post = get_post( $this->get_id() ); |
|
80 | + if ($this->get_id() > 0) { |
|
81 | + $this->post = get_post($this->get_id()); |
|
82 | 82 | $this->ID = $this->get_id(); |
83 | - $this->data_store->read( $this ); |
|
83 | + $this->data_store->read($this); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @param string $context View or edit context. |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public function get_status( $context = 'view' ) { |
|
111 | - return $this->get_prop( 'status', $context ); |
|
110 | + public function get_status($context = 'view') { |
|
111 | + return $this->get_prop('status', $context); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @param string $context View or edit context. |
119 | 119 | * @return string |
120 | 120 | */ |
121 | - public function get_version( $context = 'view' ) { |
|
122 | - return $this->get_prop( 'version', $context ); |
|
121 | + public function get_version($context = 'view') { |
|
122 | + return $this->get_prop('version', $context); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $context View or edit context. |
130 | 130 | * @return string |
131 | 131 | */ |
132 | - public function get_date_created( $context = 'view' ) { |
|
133 | - return $this->get_prop( 'date_created', $context ); |
|
132 | + public function get_date_created($context = 'view') { |
|
133 | + return $this->get_prop('date_created', $context); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @param string $context View or edit context. |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function get_date_created_gmt( $context = 'view' ) { |
|
144 | - $date = $this->get_date_created( $context ); |
|
143 | + public function get_date_created_gmt($context = 'view') { |
|
144 | + $date = $this->get_date_created($context); |
|
145 | 145 | |
146 | - if ( $date ) { |
|
147 | - $date = get_gmt_from_date( $date ); |
|
146 | + if ($date) { |
|
147 | + $date = get_gmt_from_date($date); |
|
148 | 148 | } |
149 | 149 | return $date; |
150 | 150 | } |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * @param string $context View or edit context. |
157 | 157 | * @return string |
158 | 158 | */ |
159 | - public function get_date_modified( $context = 'view' ) { |
|
160 | - return $this->get_prop( 'date_modified', $context ); |
|
159 | + public function get_date_modified($context = 'view') { |
|
160 | + return $this->get_prop('date_modified', $context); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | * @param string $context View or edit context. |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
171 | - $date = $this->get_date_modified( $context ); |
|
170 | + public function get_date_modified_gmt($context = 'view') { |
|
171 | + $date = $this->get_date_modified($context); |
|
172 | 172 | |
173 | - if ( $date ) { |
|
174 | - $date = get_gmt_from_date( $date ); |
|
173 | + if ($date) { |
|
174 | + $date = get_gmt_from_date($date); |
|
175 | 175 | } |
176 | 176 | return $date; |
177 | 177 | } |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * @param string $context View or edit context. |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - public function get_name( $context = 'view' ) { |
|
187 | - return $this->get_prop( 'name', $context ); |
|
186 | + public function get_name($context = 'view') { |
|
187 | + return $this->get_prop('name', $context); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | * @param string $context View or edit context. |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function get_title( $context = 'view' ) { |
|
198 | - return $this->get_name( $context ); |
|
197 | + public function get_title($context = 'view') { |
|
198 | + return $this->get_name($context); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | * @param string $context View or edit context. |
206 | 206 | * @return int |
207 | 207 | */ |
208 | - public function get_author( $context = 'view' ) { |
|
209 | - return (int) $this->get_prop( 'author', $context ); |
|
208 | + public function get_author($context = 'view') { |
|
209 | + return (int) $this->get_prop('author', $context); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | * @param string $context View or edit context. |
217 | 217 | * @return array |
218 | 218 | */ |
219 | - public function get_elements( $context = 'view' ) { |
|
220 | - $elements = $this->get_prop( 'elements', $context ); |
|
219 | + public function get_elements($context = 'view') { |
|
220 | + $elements = $this->get_prop('elements', $context); |
|
221 | 221 | |
222 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
223 | - return wpinv_get_data( 'sample-payment-form' ); |
|
222 | + if (empty($elements) || !is_array($elements)) { |
|
223 | + return wpinv_get_data('sample-payment-form'); |
|
224 | 224 | } |
225 | 225 | return $elements; |
226 | 226 | } |
@@ -232,51 +232,51 @@ discard block |
||
232 | 232 | * @param string $context View or edit context. |
233 | 233 | * @return GetPaid_Form_Item[] |
234 | 234 | */ |
235 | - public function get_items( $context = 'view' ) { |
|
236 | - $items = $this->get_prop( 'items', $context ); |
|
235 | + public function get_items($context = 'view') { |
|
236 | + $items = $this->get_prop('items', $context); |
|
237 | 237 | |
238 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
239 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
238 | + if (empty($items) || !is_array($items)) { |
|
239 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | // Convert the items. |
243 | 243 | $prepared = array(); |
244 | 244 | |
245 | - foreach ( $items as $key => $value ) { |
|
245 | + foreach ($items as $key => $value) { |
|
246 | 246 | |
247 | 247 | // $item_id => $quantity |
248 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
249 | - $item = new GetPaid_Form_Item( $key ); |
|
248 | + if (is_numeric($key) && is_numeric($value)) { |
|
249 | + $item = new GetPaid_Form_Item($key); |
|
250 | 250 | |
251 | - if ( $item->can_purchase() ) { |
|
252 | - $item->set_quantity( $value ); |
|
251 | + if ($item->can_purchase()) { |
|
252 | + $item->set_quantity($value); |
|
253 | 253 | $prepared[] = $item; |
254 | 254 | } |
255 | 255 | |
256 | 256 | continue; |
257 | 257 | } |
258 | 258 | |
259 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
259 | + if (is_array($value) && isset($value['id'])) { |
|
260 | 260 | |
261 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
261 | + $item = new GetPaid_Form_Item($value['id']); |
|
262 | 262 | |
263 | - if ( ! $item->can_purchase() ) { |
|
263 | + if (!$item->can_purchase()) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Cart items. |
268 | - if ( isset( $value['subtotal'] ) ) { |
|
269 | - $item->set_price( $value['subtotal'] ); |
|
270 | - $item->set_quantity( $value['quantity'] ); |
|
268 | + if (isset($value['subtotal'])) { |
|
269 | + $item->set_price($value['subtotal']); |
|
270 | + $item->set_quantity($value['quantity']); |
|
271 | 271 | $prepared[] = $item; |
272 | 272 | continue; |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Payment form item. |
276 | - $item->set_quantity( $value['quantity'] ); |
|
277 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
278 | - $item->set_is_required( $value['required'] ); |
|
279 | - $item->set_custom_description( $value['required'] ); |
|
276 | + $item->set_quantity($value['quantity']); |
|
277 | + $item->set_allow_quantities($value['allow_quantities']); |
|
278 | + $item->set_is_required($value['required']); |
|
279 | + $item->set_custom_description($value['required']); |
|
280 | 280 | $prepared[] = $item; |
281 | 281 | continue; |
282 | 282 | |
@@ -303,10 +303,10 @@ discard block |
||
303 | 303 | * @param string $status New status. |
304 | 304 | * @return array details of change. |
305 | 305 | */ |
306 | - public function set_status( $status ) { |
|
306 | + public function set_status($status) { |
|
307 | 307 | $old_status = $this->get_status(); |
308 | 308 | |
309 | - $this->set_prop( 'status', $status ); |
|
309 | + $this->set_prop('status', $status); |
|
310 | 310 | |
311 | 311 | return array( |
312 | 312 | 'from' => $old_status, |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | * |
320 | 320 | * @since 1.0.19 |
321 | 321 | */ |
322 | - public function set_version( $value ) { |
|
323 | - $this->set_prop( 'version', $value ); |
|
322 | + public function set_version($value) { |
|
323 | + $this->set_prop('version', $value); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -330,11 +330,11 @@ discard block |
||
330 | 330 | * @param string $value Value to set. |
331 | 331 | * @return bool Whether or not the date was set. |
332 | 332 | */ |
333 | - public function set_date_created( $value ) { |
|
334 | - $date = strtotime( $value ); |
|
333 | + public function set_date_created($value) { |
|
334 | + $date = strtotime($value); |
|
335 | 335 | |
336 | - if ( $date ) { |
|
337 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
336 | + if ($date) { |
|
337 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
338 | 338 | return true; |
339 | 339 | } |
340 | 340 | |
@@ -349,11 +349,11 @@ discard block |
||
349 | 349 | * @param string $value Value to set. |
350 | 350 | * @return bool Whether or not the date was set. |
351 | 351 | */ |
352 | - public function set_date_modified( $value ) { |
|
353 | - $date = strtotime( $value ); |
|
352 | + public function set_date_modified($value) { |
|
353 | + $date = strtotime($value); |
|
354 | 354 | |
355 | - if ( $date ) { |
|
356 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
355 | + if ($date) { |
|
356 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
357 | 357 | return true; |
358 | 358 | } |
359 | 359 | |
@@ -367,9 +367,9 @@ discard block |
||
367 | 367 | * @since 1.0.19 |
368 | 368 | * @param string $value New name. |
369 | 369 | */ |
370 | - public function set_name( $value ) { |
|
371 | - $name = sanitize_text_field( $value ); |
|
372 | - $this->set_prop( 'name', $name ); |
|
370 | + public function set_name($value) { |
|
371 | + $name = sanitize_text_field($value); |
|
372 | + $this->set_prop('name', $name); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @since 1.0.19 |
379 | 379 | * @param string $value New name. |
380 | 380 | */ |
381 | - public function set_title( $value ) { |
|
382 | - $this->set_name( $value ); |
|
381 | + public function set_title($value) { |
|
382 | + $this->set_name($value); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @since 1.0.19 |
389 | 389 | * @param int $value New author. |
390 | 390 | */ |
391 | - public function set_author( $value ) { |
|
392 | - $this->set_prop( 'author', (int) $value ); |
|
391 | + public function set_author($value) { |
|
392 | + $this->set_prop('author', (int) $value); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * @since 1.0.19 |
399 | 399 | * @param array $elements Form elements. |
400 | 400 | */ |
401 | - public function set_elements( $value ) { |
|
402 | - $this->set_prop( 'elements', $value ); |
|
401 | + public function set_elements($value) { |
|
402 | + $this->set_prop('elements', $value); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @since 1.0.19 |
409 | 409 | * @param array $elements Form elements. |
410 | 410 | */ |
411 | - public function set_items( $value ) { |
|
412 | - $this->set_prop( 'items', $value ); |
|
411 | + public function set_items($value) { |
|
412 | + $this->set_prop('items', $value); |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | * @deprecated |
419 | 419 | * @return int item id |
420 | 420 | */ |
421 | - public function create( $data = array() ) { |
|
421 | + public function create($data = array()) { |
|
422 | 422 | |
423 | 423 | // Set the properties. |
424 | - if ( is_array( $data ) ) { |
|
425 | - $this->set_props( $data ); |
|
424 | + if (is_array($data)) { |
|
425 | + $this->set_props($data); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | // Save the item. |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | * @deprecated |
437 | 437 | * @return int item id |
438 | 438 | */ |
439 | - public function update( $data = array() ) { |
|
440 | - return $this->create( $data ); |
|
439 | + public function update($data = array()) { |
|
440 | + return $this->create($data); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /* |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public function is_default() { |
459 | 459 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
460 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->ID, $this ); |
|
460 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->ID, $this); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | /** |
@@ -469,11 +469,11 @@ discard block |
||
469 | 469 | public function is_active() { |
470 | 470 | $is_active = null !== $this->get_id(); |
471 | 471 | |
472 | - if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) { |
|
472 | + if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') { |
|
473 | 473 | $is_active = false; |
474 | 474 | } |
475 | 475 | |
476 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
476 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | } |
@@ -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,32 +10,32 @@ discard block |
||
10 | 10 | class GetPaid_Form_Item extends WPInv_Item { |
11 | 11 | |
12 | 12 | /** |
13 | - * Stores a custom description for the item. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - protected $custom_description = ''; |
|
18 | - |
|
19 | - /** |
|
20 | - * Stores the item quantity. |
|
21 | - * |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - protected $quantity = 1; |
|
25 | - |
|
26 | - /** |
|
27 | - * Is this item required? |
|
28 | - * |
|
29 | - * @var int |
|
30 | - */ |
|
31 | - protected $is_required = true; |
|
32 | - |
|
33 | - /** |
|
34 | - * Are quantities allowed? |
|
35 | - * |
|
36 | - * @var int |
|
37 | - */ |
|
38 | - protected $allow_quantities = false; |
|
13 | + * Stores a custom description for the item. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + protected $custom_description = ''; |
|
18 | + |
|
19 | + /** |
|
20 | + * Stores the item quantity. |
|
21 | + * |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + protected $quantity = 1; |
|
25 | + |
|
26 | + /** |
|
27 | + * Is this item required? |
|
28 | + * |
|
29 | + * @var int |
|
30 | + */ |
|
31 | + protected $is_required = true; |
|
32 | + |
|
33 | + /** |
|
34 | + * Are quantities allowed? |
|
35 | + * |
|
36 | + * @var int |
|
37 | + */ |
|
38 | + protected $allow_quantities = false; |
|
39 | 39 | |
40 | 40 | /* |
41 | 41 | |-------------------------------------------------------------------------- |
@@ -53,90 +53,90 @@ discard block |
||
53 | 53 | */ |
54 | 54 | |
55 | 55 | /** |
56 | - * Get the item name. |
|
57 | - * |
|
58 | - * @since 1.0.19 |
|
59 | - * @param string $context View or edit context. |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function get_name( $context = 'view' ) { |
|
63 | - $name = parent::get_name( $context ); |
|
64 | - return $name . wpinv_get_item_suffix( $this ); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Get the item description. |
|
69 | - * |
|
70 | - * @since 1.0.19 |
|
71 | - * @param string $context View or edit context. |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function get_description( $context = 'view' ) { |
|
75 | - |
|
76 | - if ( ! empty( $this->custom_description ) ) { |
|
77 | - return $this->custom_description; |
|
78 | - } |
|
79 | - |
|
80 | - return parent::get_description( $context ); |
|
81 | - } |
|
56 | + * Get the item name. |
|
57 | + * |
|
58 | + * @since 1.0.19 |
|
59 | + * @param string $context View or edit context. |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function get_name( $context = 'view' ) { |
|
63 | + $name = parent::get_name( $context ); |
|
64 | + return $name . wpinv_get_item_suffix( $this ); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Get the item description. |
|
69 | + * |
|
70 | + * @since 1.0.19 |
|
71 | + * @param string $context View or edit context. |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function get_description( $context = 'view' ) { |
|
75 | + |
|
76 | + if ( ! empty( $this->custom_description ) ) { |
|
77 | + return $this->custom_description; |
|
78 | + } |
|
79 | + |
|
80 | + return parent::get_description( $context ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Get the item qantity. |
|
85 | - * |
|
86 | - * @since 1.0.19 |
|
87 | - * @param string $context View or edit context. |
|
88 | - * @return int |
|
89 | - */ |
|
90 | - public function get_qantity( $context = 'view' ) { |
|
91 | - $quantity = (int) $this->quantity; |
|
92 | - |
|
93 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
94 | - $quantity = 1; |
|
95 | - } |
|
96 | - |
|
97 | - if ( 'view' == $context ) { |
|
98 | - return apply_filters( 'getpaid_payment_form_item_quanity', $quantity, $this ); |
|
99 | - } |
|
100 | - |
|
101 | - return $quantity; |
|
102 | - |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Returns whether or not quantities are allowed. |
|
107 | - * |
|
108 | - * @since 1.0.19 |
|
109 | - * @param string $context View or edit context. |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function get_allow_quantities( $context = 'view' ) { |
|
113 | - $allow_quantities = (bool) $this->allow_quantities; |
|
114 | - |
|
115 | - if ( 'view' == $context ) { |
|
116 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
117 | - } |
|
118 | - |
|
119 | - return $allow_quantities; |
|
120 | - |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Returns whether or not the item is required. |
|
125 | - * |
|
126 | - * @since 1.0.19 |
|
127 | - * @param string $context View or edit context. |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function get_is_required( $context = 'view' ) { |
|
131 | - $is_required = (bool) $this->is_required; |
|
132 | - |
|
133 | - if ( 'view' == $context ) { |
|
134 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
135 | - } |
|
136 | - |
|
137 | - return $is_required; |
|
138 | - |
|
139 | - } |
|
83 | + /** |
|
84 | + * Get the item qantity. |
|
85 | + * |
|
86 | + * @since 1.0.19 |
|
87 | + * @param string $context View or edit context. |
|
88 | + * @return int |
|
89 | + */ |
|
90 | + public function get_qantity( $context = 'view' ) { |
|
91 | + $quantity = (int) $this->quantity; |
|
92 | + |
|
93 | + if ( empty( $quantity ) || 1 > $quantity ) { |
|
94 | + $quantity = 1; |
|
95 | + } |
|
96 | + |
|
97 | + if ( 'view' == $context ) { |
|
98 | + return apply_filters( 'getpaid_payment_form_item_quanity', $quantity, $this ); |
|
99 | + } |
|
100 | + |
|
101 | + return $quantity; |
|
102 | + |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Returns whether or not quantities are allowed. |
|
107 | + * |
|
108 | + * @since 1.0.19 |
|
109 | + * @param string $context View or edit context. |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function get_allow_quantities( $context = 'view' ) { |
|
113 | + $allow_quantities = (bool) $this->allow_quantities; |
|
114 | + |
|
115 | + if ( 'view' == $context ) { |
|
116 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
117 | + } |
|
118 | + |
|
119 | + return $allow_quantities; |
|
120 | + |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Returns whether or not the item is required. |
|
125 | + * |
|
126 | + * @since 1.0.19 |
|
127 | + * @param string $context View or edit context. |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function get_is_required( $context = 'view' ) { |
|
131 | + $is_required = (bool) $this->is_required; |
|
132 | + |
|
133 | + if ( 'view' == $context ) { |
|
134 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
135 | + } |
|
136 | + |
|
137 | + return $is_required; |
|
138 | + |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /* |
142 | 142 | |-------------------------------------------------------------------------- |
@@ -148,60 +148,60 @@ discard block |
||
148 | 148 | | object. |
149 | 149 | */ |
150 | 150 | |
151 | - /** |
|
152 | - * Set the item qantity. |
|
153 | - * |
|
154 | - * @since 1.0.19 |
|
155 | - * @param int $quantity The item quantity. |
|
156 | - */ |
|
157 | - public function set_quantity( $quantity ) { |
|
158 | - |
|
159 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
160 | - $quantity = 1; |
|
161 | - } |
|
162 | - |
|
163 | - $this->quantity = $quantity; |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * Set whether or not the quantities are allowed. |
|
169 | - * |
|
170 | - * @since 1.0.19 |
|
171 | - * @param bool $allow_quantities |
|
172 | - */ |
|
173 | - public function set_allow_quantities( $allow_quantities ) { |
|
174 | - $this->allow_quantities = (bool) $allow_quantities; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Set whether or not the item is required. |
|
179 | - * |
|
180 | - * @since 1.0.19 |
|
181 | - * @param bool $is_required |
|
182 | - */ |
|
183 | - public function set_is_required( $is_required ) { |
|
184 | - $this->is_required = (bool) $is_required; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Sets the custom item description. |
|
189 | - * |
|
190 | - * @since 1.0.19 |
|
191 | - * @param string $description |
|
192 | - */ |
|
193 | - public function set_custom_description( $description ) { |
|
194 | - $this->custom_description = $description; |
|
195 | - } |
|
151 | + /** |
|
152 | + * Set the item qantity. |
|
153 | + * |
|
154 | + * @since 1.0.19 |
|
155 | + * @param int $quantity The item quantity. |
|
156 | + */ |
|
157 | + public function set_quantity( $quantity ) { |
|
158 | + |
|
159 | + if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
160 | + $quantity = 1; |
|
161 | + } |
|
162 | + |
|
163 | + $this->quantity = $quantity; |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Set whether or not the quantities are allowed. |
|
169 | + * |
|
170 | + * @since 1.0.19 |
|
171 | + * @param bool $allow_quantities |
|
172 | + */ |
|
173 | + public function set_allow_quantities( $allow_quantities ) { |
|
174 | + $this->allow_quantities = (bool) $allow_quantities; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Set whether or not the item is required. |
|
179 | + * |
|
180 | + * @since 1.0.19 |
|
181 | + * @param bool $is_required |
|
182 | + */ |
|
183 | + public function set_is_required( $is_required ) { |
|
184 | + $this->is_required = (bool) $is_required; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Sets the custom item description. |
|
189 | + * |
|
190 | + * @since 1.0.19 |
|
191 | + * @param string $description |
|
192 | + */ |
|
193 | + public function set_custom_description( $description ) { |
|
194 | + $this->custom_description = $description; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * We do not want to save items to the database. |
199 | 199 | * |
200 | - * @return int item id |
|
200 | + * @return int item id |
|
201 | 201 | */ |
202 | 202 | public function save( $data = array() ) { |
203 | 203 | return $this->get_id(); |
204 | - } |
|
204 | + } |
|
205 | 205 | |
206 | 206 | /* |
207 | 207 | |-------------------------------------------------------------------------- |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | */ |
214 | 214 | |
215 | 215 | /** |
216 | - * Checks whether the item has enabled dynamic pricing. |
|
217 | - * |
|
218 | - * @since 1.0.19 |
|
219 | - * @return bool |
|
220 | - */ |
|
221 | - public function is_required() { |
|
216 | + * Checks whether the item has enabled dynamic pricing. |
|
217 | + * |
|
218 | + * @since 1.0.19 |
|
219 | + * @return bool |
|
220 | + */ |
|
221 | + public function is_required() { |
|
222 | 222 | return (bool) $this->get_is_required(); |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | 225 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @param string $context View or edit context. |
60 | 60 | * @return string |
61 | 61 | */ |
62 | - public function get_name( $context = 'view' ) { |
|
63 | - $name = parent::get_name( $context ); |
|
64 | - return $name . wpinv_get_item_suffix( $this ); |
|
62 | + public function get_name($context = 'view') { |
|
63 | + $name = parent::get_name($context); |
|
64 | + return $name . wpinv_get_item_suffix($this); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | * @param string $context View or edit context. |
72 | 72 | * @return string |
73 | 73 | */ |
74 | - public function get_description( $context = 'view' ) { |
|
74 | + public function get_description($context = 'view') { |
|
75 | 75 | |
76 | - if ( ! empty( $this->custom_description ) ) { |
|
76 | + if (!empty($this->custom_description)) { |
|
77 | 77 | return $this->custom_description; |
78 | 78 | } |
79 | 79 | |
80 | - return parent::get_description( $context ); |
|
80 | + return parent::get_description($context); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | * @param string $context View or edit context. |
88 | 88 | * @return int |
89 | 89 | */ |
90 | - public function get_qantity( $context = 'view' ) { |
|
90 | + public function get_qantity($context = 'view') { |
|
91 | 91 | $quantity = (int) $this->quantity; |
92 | 92 | |
93 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
93 | + if (empty($quantity) || 1 > $quantity) { |
|
94 | 94 | $quantity = 1; |
95 | 95 | } |
96 | 96 | |
97 | - if ( 'view' == $context ) { |
|
98 | - return apply_filters( 'getpaid_payment_form_item_quanity', $quantity, $this ); |
|
97 | + if ('view' == $context) { |
|
98 | + return apply_filters('getpaid_payment_form_item_quanity', $quantity, $this); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return $quantity; |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * @param string $context View or edit context. |
110 | 110 | * @return bool |
111 | 111 | */ |
112 | - public function get_allow_quantities( $context = 'view' ) { |
|
112 | + public function get_allow_quantities($context = 'view') { |
|
113 | 113 | $allow_quantities = (bool) $this->allow_quantities; |
114 | 114 | |
115 | - if ( 'view' == $context ) { |
|
116 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
115 | + if ('view' == $context) { |
|
116 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | return $allow_quantities; |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @param string $context View or edit context. |
128 | 128 | * @return bool |
129 | 129 | */ |
130 | - public function get_is_required( $context = 'view' ) { |
|
130 | + public function get_is_required($context = 'view') { |
|
131 | 131 | $is_required = (bool) $this->is_required; |
132 | 132 | |
133 | - if ( 'view' == $context ) { |
|
134 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
133 | + if ('view' == $context) { |
|
134 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $is_required; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * @since 1.0.19 |
155 | 155 | * @param int $quantity The item quantity. |
156 | 156 | */ |
157 | - public function set_quantity( $quantity ) { |
|
157 | + public function set_quantity($quantity) { |
|
158 | 158 | |
159 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
159 | + if (empty($quantity) || !is_numeric($quantity)) { |
|
160 | 160 | $quantity = 1; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @since 1.0.19 |
171 | 171 | * @param bool $allow_quantities |
172 | 172 | */ |
173 | - public function set_allow_quantities( $allow_quantities ) { |
|
173 | + public function set_allow_quantities($allow_quantities) { |
|
174 | 174 | $this->allow_quantities = (bool) $allow_quantities; |
175 | 175 | } |
176 | 176 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @since 1.0.19 |
181 | 181 | * @param bool $is_required |
182 | 182 | */ |
183 | - public function set_is_required( $is_required ) { |
|
183 | + public function set_is_required($is_required) { |
|
184 | 184 | $this->is_required = (bool) $is_required; |
185 | 185 | } |
186 | 186 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @since 1.0.19 |
191 | 191 | * @param string $description |
192 | 192 | */ |
193 | - public function set_custom_description( $description ) { |
|
193 | + public function set_custom_description($description) { |
|
194 | 194 | $this->custom_description = $description; |
195 | 195 | } |
196 | 196 | |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return int item id |
201 | 201 | */ |
202 | - public function save( $data = array() ) { |
|
202 | + public function save($data = array()) { |
|
203 | 203 | return $this->get_id(); |
204 | 204 | } |
205 | 205 |