Passed
Pull Request — master (#57)
by Kiran
04:16
created
includes/class-wpinv-item.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 class WPInv_Item {
6 6
     public $ID = 0;
@@ -33,26 +33,26 @@  discard block
 block discarded – undo
33 33
     public $filter;
34 34
 
35 35
 
36
-    public function __construct( $_id = false, $_args = array() ) {
37
-        $item = WP_Post::get_instance( $_id );
38
-        return $this->setup_item( $item );
36
+    public function __construct($_id = false, $_args = array()) {
37
+        $item = WP_Post::get_instance($_id);
38
+        return $this->setup_item($item);
39 39
     }
40 40
 
41
-    private function setup_item( $item ) {
42
-        if( ! is_object( $item ) ) {
41
+    private function setup_item($item) {
42
+        if (!is_object($item)) {
43 43
             return false;
44 44
         }
45 45
 
46
-        if( ! is_a( $item, 'WP_Post' ) ) {
46
+        if (!is_a($item, 'WP_Post')) {
47 47
             return false;
48 48
         }
49 49
 
50
-        if( 'wpi_item' !== $item->post_type ) {
50
+        if ('wpi_item' !== $item->post_type) {
51 51
             return false;
52 52
         }
53 53
 
54
-        foreach ( $item as $key => $value ) {
55
-            switch ( $key ) {
54
+        foreach ($item as $key => $value) {
55
+            switch ($key) {
56 56
                 default:
57 57
                     $this->$key = $value;
58 58
                     break;
@@ -62,38 +62,38 @@  discard block
 block discarded – undo
62 62
         return true;
63 63
     }
64 64
 
65
-    public function __get( $key ) {
66
-        if ( method_exists( $this, 'get_' . $key ) ) {
67
-            return call_user_func( array( $this, 'get_' . $key ) );
65
+    public function __get($key) {
66
+        if (method_exists($this, 'get_' . $key)) {
67
+            return call_user_func(array($this, 'get_' . $key));
68 68
         } else {
69
-            return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
69
+            return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
70 70
         }
71 71
     }
72 72
 
73
-    public function create( $data = array(), $wp_error = false ) {
74
-        if ( $this->ID != 0 ) {
73
+    public function create($data = array(), $wp_error = false) {
74
+        if ($this->ID != 0) {
75 75
             return false;
76 76
         }
77 77
 
78 78
         $defaults = array(
79 79
             'post_type'   => 'wpi_item',
80 80
             'post_status' => 'draft',
81
-            'post_title'  => __( 'New Invoice Item', 'invoicing' )
81
+            'post_title'  => __('New Invoice Item', 'invoicing')
82 82
         );
83 83
 
84
-        $args = wp_parse_args( $data, $defaults );
84
+        $args = wp_parse_args($data, $defaults);
85 85
 
86
-        do_action( 'wpinv_item_pre_create', $args );
86
+        do_action('wpinv_item_pre_create', $args);
87 87
 
88
-        $id = wp_insert_post( $args, $wp_error );
88
+        $id = wp_insert_post($args, $wp_error);
89 89
         if ($wp_error && is_wp_error($id)) {
90 90
             return $id;
91 91
         }
92
-        if ( !$id ) {
92
+        if (!$id) {
93 93
             return false;
94 94
         }
95 95
         
96
-        $item = WP_Post::get_instance( $id );
96
+        $item = WP_Post::get_instance($id);
97 97
         
98 98
         if (!empty($item) && !empty($data['meta'])) {
99 99
             $this->ID = $item->ID;
@@ -101,47 +101,47 @@  discard block
 block discarded – undo
101 101
         }
102 102
         
103 103
         // Set custom id if not set.
104
-        if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) {
105
-            $this->save_metas( array( 'custom_id' => $id ) );
104
+        if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) {
105
+            $this->save_metas(array('custom_id' => $id));
106 106
         }
107 107
 
108
-        do_action( 'wpinv_item_create', $id, $args );
108
+        do_action('wpinv_item_create', $id, $args);
109 109
 
110
-        return $this->setup_item( $item );
110
+        return $this->setup_item($item);
111 111
     }
112 112
     
113
-    public function update( $data = array(), $wp_error = false ) {
114
-        if ( !$this->ID > 0 ) {
113
+    public function update($data = array(), $wp_error = false) {
114
+        if (!$this->ID > 0) {
115 115
             return false;
116 116
         }
117 117
         
118 118
         $data['ID'] = $this->ID;
119 119
 
120
-        do_action( 'wpinv_item_pre_update', $data );
120
+        do_action('wpinv_item_pre_update', $data);
121 121
         
122
-        $id = wp_update_post( $data, $wp_error );
122
+        $id = wp_update_post($data, $wp_error);
123 123
         if ($wp_error && is_wp_error($id)) {
124 124
             return $id;
125 125
         }
126 126
         
127
-        if ( !$id ) {
127
+        if (!$id) {
128 128
             return false;
129 129
         }
130 130
 
131
-        $item = WP_Post::get_instance( $id );
131
+        $item = WP_Post::get_instance($id);
132 132
         if (!empty($item) && !empty($data['meta'])) {
133 133
             $this->ID = $item->ID;
134 134
             $this->save_metas($data['meta']);
135 135
         }
136 136
         
137 137
         // Set custom id if not set.
138
-        if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) {
139
-            $this->save_metas( array( 'custom_id' => $id ) );
138
+        if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) {
139
+            $this->save_metas(array('custom_id' => $id));
140 140
         }
141 141
 
142
-        do_action( 'wpinv_item_update', $id, $data );
142
+        do_action('wpinv_item_update', $id, $data);
143 143
 
144
-        return $this->setup_item( $item );
144
+        return $this->setup_item($item);
145 145
     }
146 146
 
147 147
     public function get_ID() {
@@ -149,105 +149,105 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     public function get_name() {
152
-        return get_the_title( $this->ID );
152
+        return get_the_title($this->ID);
153 153
     }
154 154
     
155 155
     public function get_summary() {
156
-        return get_the_excerpt( $this->ID );
156
+        return get_the_excerpt($this->ID);
157 157
     }
158 158
 
159 159
     public function get_price() {
160
-        if ( ! isset( $this->price ) ) {
161
-            $this->price = get_post_meta( $this->ID, '_wpinv_price', true );
160
+        if (!isset($this->price)) {
161
+            $this->price = get_post_meta($this->ID, '_wpinv_price', true);
162 162
             
163
-            if ( $this->price ) {
164
-                $this->price = wpinv_sanitize_amount( $this->price );
163
+            if ($this->price) {
164
+                $this->price = wpinv_sanitize_amount($this->price);
165 165
             } else {
166 166
                 $this->price = 0;
167 167
             }
168 168
         }
169 169
         
170
-        return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID );
170
+        return apply_filters('wpinv_get_item_price', $this->price, $this->ID);
171 171
     }
172 172
     
173 173
     public function get_the_price() {
174
-        $item_price = wpinv_price( wpinv_format_amount( $this->price ) );
174
+        $item_price = wpinv_price(wpinv_format_amount($this->price));
175 175
         
176
-        return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID );
176
+        return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID);
177 177
     }
178 178
     
179 179
     public function get_vat_rule() {
180 180
         global $wpinv_euvat;
181 181
         
182
-        if( !isset( $this->vat_rule ) ) {
183
-            $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true );
182
+        if (!isset($this->vat_rule)) {
183
+            $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true);
184 184
 
185
-            if ( empty( $this->vat_rule ) ) {        
185
+            if (empty($this->vat_rule)) {        
186 186
                 $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical';
187 187
             }
188 188
         }
189 189
         
190
-        return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID );
190
+        return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID);
191 191
     }
192 192
     
193 193
     public function get_vat_class() {
194
-        if( !isset( $this->vat_class ) ) {
195
-            $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true );
194
+        if (!isset($this->vat_class)) {
195
+            $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true);
196 196
 
197
-            if ( empty( $this->vat_class ) ) {        
197
+            if (empty($this->vat_class)) {        
198 198
                 $this->vat_class = '_standard';
199 199
             }
200 200
         }
201 201
         
202
-        return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID );
202
+        return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID);
203 203
     }
204 204
 
205 205
     public function get_type() {
206
-        if( ! isset( $this->type ) ) {
207
-            $this->type = get_post_meta( $this->ID, '_wpinv_type', true );
206
+        if (!isset($this->type)) {
207
+            $this->type = get_post_meta($this->ID, '_wpinv_type', true);
208 208
 
209
-            if ( empty( $this->type ) ) {
209
+            if (empty($this->type)) {
210 210
                 $this->type = 'custom';
211 211
             }
212 212
         }
213 213
 
214
-        return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID );
214
+        return apply_filters('wpinv_get_item_type', $this->type, $this->ID);
215 215
     }
216 216
     
217 217
     public function get_custom_id() {
218
-        $custom_id = get_post_meta( $this->ID, '_wpinv_custom_id', true );
218
+        $custom_id = get_post_meta($this->ID, '_wpinv_custom_id', true);
219 219
 
220
-        return apply_filters( 'wpinv_get_item_custom_id', $custom_id, $this->ID );
220
+        return apply_filters('wpinv_get_item_custom_id', $custom_id, $this->ID);
221 221
     }
222 222
     
223 223
     public function get_custom_name() {
224
-        $custom_name = get_post_meta( $this->ID, '_wpinv_custom_name', true );
224
+        $custom_name = get_post_meta($this->ID, '_wpinv_custom_name', true);
225 225
 
226
-        return apply_filters( 'wpinv_get_item_custom_name', $custom_name, $this->ID );
226
+        return apply_filters('wpinv_get_item_custom_name', $custom_name, $this->ID);
227 227
     }
228 228
     
229 229
     public function get_custom_singular_name() {
230
-        $custom_singular_name = get_post_meta( $this->ID, '_wpinv_custom_singular_name', true );
230
+        $custom_singular_name = get_post_meta($this->ID, '_wpinv_custom_singular_name', true);
231 231
 
232
-        return apply_filters( 'wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID );
232
+        return apply_filters('wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID);
233 233
     }
234 234
     
235 235
     public function is_recurring() {
236
-        $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true );
236
+        $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true);
237 237
 
238
-        return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID );
238
+        return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID);
239 239
 
240 240
     }
241 241
     
242
-    public function get_recurring_period( $full = false ) {
243
-        $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true );
242
+    public function get_recurring_period($full = false) {
243
+        $period = get_post_meta($this->ID, '_wpinv_recurring_period', true);
244 244
         
245
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
245
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
246 246
             $period = 'D';
247 247
         }
248 248
         
249
-        if ( $full ) {
250
-            switch( $period ) {
249
+        if ($full) {
250
+            switch ($period) {
251 251
                 case 'D':
252 252
                     $period = 'day';
253 253
                 break;
@@ -263,45 +263,45 @@  discard block
 block discarded – undo
263 263
             }
264 264
         }
265 265
 
266
-        return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID );
266
+        return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID);
267 267
 
268 268
     }
269 269
     
270 270
     public function get_recurring_interval() {
271
-        $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true );
271
+        $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true);
272 272
         
273
-        if ( !$interval > 0 ) {
273
+        if (!$interval > 0) {
274 274
             $interval = 1;
275 275
         }
276 276
 
277
-        return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID );
277
+        return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID);
278 278
 
279 279
     }
280 280
     
281 281
     public function get_recurring_limit() {
282
-        $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true );
282
+        $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true);
283 283
 
284
-        return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID );
284
+        return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID);
285 285
 
286 286
     }
287 287
     
288 288
     public function has_free_trial() {
289
-        $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true );
290
-        $free_trial = $this->is_recurring() && !empty( $free_trial ) ? true : false;
289
+        $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true);
290
+        $free_trial = $this->is_recurring() && !empty($free_trial) ? true : false;
291 291
 
292
-        return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID );
292
+        return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID);
293 293
 
294 294
     }
295 295
     
296
-    public function get_trial_period( $full = false ) {
297
-        $period = get_post_meta( $this->ID, '_wpinv_trial_period', true );
296
+    public function get_trial_period($full = false) {
297
+        $period = get_post_meta($this->ID, '_wpinv_trial_period', true);
298 298
         
299
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
299
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
300 300
             $period = 'D';
301 301
         }
302 302
         
303
-        if ( $full ) {
304
-            switch( $period ) {
303
+        if ($full) {
304
+            switch ($period) {
305 305
                 case 'D':
306 306
                     $period = 'day';
307 307
                 break;
@@ -317,55 +317,55 @@  discard block
 block discarded – undo
317 317
             }
318 318
         }
319 319
 
320
-        return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID );
320
+        return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID);
321 321
 
322 322
     }
323 323
     
324 324
     public function get_trial_interval() {
325
-        $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) );
325
+        $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true));
326 326
         
327
-        if ( !$interval > 0 ) {
327
+        if (!$interval > 0) {
328 328
             $interval = 1;
329 329
         }
330 330
 
331
-        return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID );
331
+        return apply_filters('wpinv_item_trial_interval', $interval, $this->ID);
332 332
 
333 333
     }
334 334
 
335 335
     public function is_free() {
336 336
         $is_free = false;
337 337
         
338
-        $price = get_post_meta( $this->ID, '_wpinv_price', true );
338
+        $price = get_post_meta($this->ID, '_wpinv_price', true);
339 339
 
340
-        if ( (float)$price == 0 ) {
340
+        if ((float)$price == 0) {
341 341
             $is_free = true;
342 342
         }
343 343
 
344
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID );
344
+        return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID);
345 345
 
346 346
     }
347 347
     
348 348
     public function is_package() {
349 349
         $is_package = $this->get_type() == 'package' ? true : false;
350 350
 
351
-        return (bool) apply_filters( 'wpinv_is_package_item', $is_package, $this->ID );
351
+        return (bool)apply_filters('wpinv_is_package_item', $is_package, $this->ID);
352 352
 
353 353
     }
354 354
     
355 355
     public function is_editable() {
356
-        $editable = get_post_meta( $this->ID, '_wpinv_editable', true );
356
+        $editable = get_post_meta($this->ID, '_wpinv_editable', true);
357 357
 
358 358
         $is_editable = $editable === 0 || $editable === '0' ? false : true;
359 359
 
360
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID );
360
+        return (bool)apply_filters('wpinv_item_is_editable', $is_editable, $this->ID);
361 361
     }
362 362
     
363
-    public function save_metas( $metas = array() ) {
364
-        if ( empty( $metas ) ) {
363
+    public function save_metas($metas = array()) {
364
+        if (empty($metas)) {
365 365
             return false;
366 366
         }
367 367
         
368
-        foreach ( $metas as $meta_key => $meta_value ) {
368
+        foreach ($metas as $meta_key => $meta_value) {
369 369
             $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key;
370 370
             
371 371
             $this->update_meta($meta_key, $meta_value);
@@ -374,66 +374,66 @@  discard block
 block discarded – undo
374 374
         return true;
375 375
     }
376 376
 
377
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
378
-        if ( empty( $meta_key ) ) {
377
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
378
+        if (empty($meta_key)) {
379 379
             return false;
380 380
         }
381 381
         
382
-        $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID );
382
+        $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID);
383 383
 
384
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
384
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
385 385
     }
386 386
     
387
-    public function get_fees( $type = 'fee', $item_id = 0 ) {
387
+    public function get_fees($type = 'fee', $item_id = 0) {
388 388
         global $wpi_session;
389 389
         
390
-        $fees = $wpi_session->get( 'wpi_cart_fees' );
390
+        $fees = $wpi_session->get('wpi_cart_fees');
391 391
 
392
-        if ( ! wpinv_get_cart_contents() ) {
392
+        if (!wpinv_get_cart_contents()) {
393 393
             // We can only get item type fees when the cart is empty
394 394
             $type = 'custom';
395 395
         }
396 396
 
397
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
398
-            foreach( $fees as $key => $fee ) {
399
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
400
-                    unset( $fees[ $key ] );
397
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
398
+            foreach ($fees as $key => $fee) {
399
+                if (!empty($fee['type']) && $type != $fee['type']) {
400
+                    unset($fees[$key]);
401 401
                 }
402 402
             }
403 403
         }
404 404
 
405
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
405
+        if (!empty($fees) && !empty($item_id)) {
406 406
             // Remove fees that don't belong to the specified Item
407
-            foreach ( $fees as $key => $fee ) {
408
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
409
-                    unset( $fees[ $key ] );
407
+            foreach ($fees as $key => $fee) {
408
+                if ((int)$item_id !== (int)$fee['custom_id']) {
409
+                    unset($fees[$key]);
410 410
                 }
411 411
             }
412 412
         }
413 413
 
414
-        if ( ! empty( $fees ) ) {
414
+        if (!empty($fees)) {
415 415
             // Remove fees that belong to a specific item but are not in the cart
416
-            foreach( $fees as $key => $fee ) {
417
-                if( empty( $fee['custom_id'] ) ) {
416
+            foreach ($fees as $key => $fee) {
417
+                if (empty($fee['custom_id'])) {
418 418
                     continue;
419 419
                 }
420 420
 
421
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
422
-                    unset( $fees[ $key ] );
421
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
422
+                    unset($fees[$key]);
423 423
                 }
424 424
             }
425 425
         }
426 426
 
427
-        return ! empty( $fees ) ? $fees : array();
427
+        return !empty($fees) ? $fees : array();
428 428
     }
429 429
     
430 430
     public function can_purchase() {
431 431
         $can_purchase = true;
432 432
 
433
-        if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
433
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
434 434
             $can_purchase = false;
435 435
         }
436 436
 
437
-        return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
437
+        return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
438 438
     }
439 439
 }
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -7,195 +7,195 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_is_checkout() {
15 15
     global $wp_query;
16 16
 
17
-    $is_object_set    = isset( $wp_query->queried_object );
18
-    $is_object_id_set = isset( $wp_query->queried_object_id );
19
-    $is_checkout      = is_page( wpinv_get_option( 'checkout_page' ) );
17
+    $is_object_set    = isset($wp_query->queried_object);
18
+    $is_object_id_set = isset($wp_query->queried_object_id);
19
+    $is_checkout      = is_page(wpinv_get_option('checkout_page'));
20 20
 
21
-    if ( !$is_object_set ) {
22
-        unset( $wp_query->queried_object );
21
+    if (!$is_object_set) {
22
+        unset($wp_query->queried_object);
23 23
     }
24 24
 
25
-    if ( !$is_object_id_set ) {
26
-        unset( $wp_query->queried_object_id );
25
+    if (!$is_object_id_set) {
26
+        unset($wp_query->queried_object_id);
27 27
     }
28 28
 
29
-    return apply_filters( 'wpinv_is_checkout', $is_checkout );
29
+    return apply_filters('wpinv_is_checkout', $is_checkout);
30 30
 }
31 31
 
32 32
 function wpinv_can_checkout() {
33 33
 	$can_checkout = true; // Always true for now
34 34
 
35
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
35
+	return (bool)apply_filters('wpinv_can_checkout', $can_checkout);
36 36
 }
37 37
 
38 38
 function wpinv_get_success_page_uri() {
39
-	$page_id = wpinv_get_option( 'success_page', 0 );
40
-	$page_id = absint( $page_id );
39
+	$page_id = wpinv_get_option('success_page', 0);
40
+	$page_id = absint($page_id);
41 41
 
42
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
42
+	return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id));
43 43
 }
44 44
 
45 45
 function wpinv_get_history_page_uri() {
46
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
47
-	$page_id = absint( $page_id );
46
+	$page_id = wpinv_get_option('invoice_history_page', 0);
47
+	$page_id = absint($page_id);
48 48
 
49
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
49
+	return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id));
50 50
 }
51 51
 
52 52
 function wpinv_is_success_page() {
53
-	$is_success_page = wpinv_get_option( 'success_page', false );
54
-	$is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false;
53
+	$is_success_page = wpinv_get_option('success_page', false);
54
+	$is_success_page = isset($is_success_page) ? is_page($is_success_page) : false;
55 55
 
56
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
56
+	return apply_filters('wpinv_is_success_page', $is_success_page);
57 57
 }
58 58
 
59 59
 function wpinv_is_invoice_history_page() {
60
-	$ret = wpinv_get_option( 'invoice_history_page', false );
61
-	$ret = $ret ? is_page( $ret ) : false;
62
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
60
+	$ret = wpinv_get_option('invoice_history_page', false);
61
+	$ret = $ret ? is_page($ret) : false;
62
+	return apply_filters('wpinv_is_invoice_history_page', $ret);
63 63
 }
64 64
 
65
-function wpinv_send_to_success_page( $args = null ) {
65
+function wpinv_send_to_success_page($args = null) {
66 66
 	$redirect = wpinv_get_success_page_uri();
67 67
     
68
-    if ( !empty( $args ) ) {
68
+    if (!empty($args)) {
69 69
         // Check for backward compatibility
70
-        if ( is_string( $args ) )
71
-            $args = str_replace( '?', '', $args );
70
+        if (is_string($args))
71
+            $args = str_replace('?', '', $args);
72 72
 
73
-        $args = wp_parse_args( $args );
73
+        $args = wp_parse_args($args);
74 74
 
75
-        $redirect = add_query_arg( $args, $redirect );
75
+        $redirect = add_query_arg($args, $redirect);
76 76
     }
77 77
 
78
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
78
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
79 79
     
80
-    $redirect = apply_filters( 'wpinv_success_page_redirect', $redirect, $gateway, $args );
81
-    wp_redirect( $redirect );
80
+    $redirect = apply_filters('wpinv_success_page_redirect', $redirect, $gateway, $args);
81
+    wp_redirect($redirect);
82 82
     exit;
83 83
 }
84 84
 
85
-function wpinv_send_to_failed_page( $args = null ) {
85
+function wpinv_send_to_failed_page($args = null) {
86 86
 	$redirect = wpinv_get_failed_transaction_uri();
87 87
     
88
-    if ( !empty( $args ) ) {
88
+    if (!empty($args)) {
89 89
         // Check for backward compatibility
90
-        if ( is_string( $args ) )
91
-            $args = str_replace( '?', '', $args );
90
+        if (is_string($args))
91
+            $args = str_replace('?', '', $args);
92 92
 
93
-        $args = wp_parse_args( $args );
93
+        $args = wp_parse_args($args);
94 94
 
95
-        $redirect = add_query_arg( $args, $redirect );
95
+        $redirect = add_query_arg($args, $redirect);
96 96
     }
97 97
 
98
-    $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : '';
98
+    $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : '';
99 99
     
100
-    $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args );
101
-    wp_redirect( $redirect );
100
+    $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args);
101
+    wp_redirect($redirect);
102 102
     exit;
103 103
 }
104 104
 
105
-function wpinv_get_checkout_uri( $args = array() ) {
106
-	$uri = wpinv_get_option( 'checkout_page', false );
107
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
105
+function wpinv_get_checkout_uri($args = array()) {
106
+	$uri = wpinv_get_option('checkout_page', false);
107
+	$uri = isset($uri) ? get_permalink($uri) : NULL;
108 108
 
109
-	if ( !empty( $args ) ) {
109
+	if (!empty($args)) {
110 110
 		// Check for backward compatibility
111
-		if ( is_string( $args ) )
112
-			$args = str_replace( '?', '', $args );
111
+		if (is_string($args))
112
+			$args = str_replace('?', '', $args);
113 113
 
114
-		$args = wp_parse_args( $args );
114
+		$args = wp_parse_args($args);
115 115
 
116
-		$uri = add_query_arg( $args, $uri );
116
+		$uri = add_query_arg($args, $uri);
117 117
 	}
118 118
 
119
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
119
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
120 120
 
121
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
121
+	$ajax_url = admin_url('admin-ajax.php', $scheme);
122 122
 
123
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
124
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
123
+	if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) {
124
+		$uri = preg_replace('/^http:/', 'https:', $uri);
125 125
 	}
126 126
 
127
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
127
+	return apply_filters('wpinv_get_checkout_uri', $uri);
128 128
 }
129 129
 
130
-function wpinv_send_back_to_checkout( $args = array() ) {
130
+function wpinv_send_back_to_checkout($args = array()) {
131 131
 	$redirect = wpinv_get_checkout_uri();
132 132
 
133
-	if ( ! empty( $args ) ) {
133
+	if (!empty($args)) {
134 134
 		// Check for backward compatibility
135
-		if ( is_string( $args ) )
136
-			$args = str_replace( '?', '', $args );
135
+		if (is_string($args))
136
+			$args = str_replace('?', '', $args);
137 137
 
138
-		$args = wp_parse_args( $args );
138
+		$args = wp_parse_args($args);
139 139
 
140
-		$redirect = add_query_arg( $args, $redirect );
140
+		$redirect = add_query_arg($args, $redirect);
141 141
 	}
142 142
 
143
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
143
+	wp_redirect(apply_filters('wpinv_send_back_to_checkout', $redirect, $args));
144 144
 	exit;
145 145
 }
146 146
 
147
-function wpinv_get_success_page_url( $query_string = null ) {
148
-	$success_page = wpinv_get_option( 'success_page', 0 );
149
-	$success_page = get_permalink( $success_page );
147
+function wpinv_get_success_page_url($query_string = null) {
148
+	$success_page = wpinv_get_option('success_page', 0);
149
+	$success_page = get_permalink($success_page);
150 150
 
151
-	if ( $query_string )
151
+	if ($query_string)
152 152
 		$success_page .= $query_string;
153 153
 
154
-	return apply_filters( 'wpinv_success_page_url', $success_page );
154
+	return apply_filters('wpinv_success_page_url', $success_page);
155 155
 }
156 156
 
157
-function wpinv_get_failed_transaction_uri( $extras = false ) {
158
-	$uri = wpinv_get_option( 'failure_page', '' );
159
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
157
+function wpinv_get_failed_transaction_uri($extras = false) {
158
+	$uri = wpinv_get_option('failure_page', '');
159
+	$uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url();
160 160
 
161
-	if ( $extras )
161
+	if ($extras)
162 162
 		$uri .= $extras;
163 163
 
164
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
164
+	return apply_filters('wpinv_get_failed_transaction_uri', $uri);
165 165
 }
166 166
 
167 167
 function wpinv_is_failed_transaction_page() {
168
-	$ret = wpinv_get_option( 'failure_page', false );
169
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
168
+	$ret = wpinv_get_option('failure_page', false);
169
+	$ret = isset($ret) ? is_page($ret) : false;
170 170
 
171
-	return apply_filters( 'wpinv_is_failure_page', $ret );
171
+	return apply_filters('wpinv_is_failure_page', $ret);
172 172
 }
173 173
 
174
-function wpinv_transaction_query( $type = 'start' ) {
174
+function wpinv_transaction_query($type = 'start') {
175 175
     global $wpdb;
176 176
 
177 177
     $wpdb->hide_errors();
178 178
 
179
-    if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) {
180
-        define( 'WPINV_USE_TRANSACTIONS', true );
179
+    if (!defined('WPINV_USE_TRANSACTIONS')) {
180
+        define('WPINV_USE_TRANSACTIONS', true);
181 181
     }
182 182
 
183
-    if ( WPINV_USE_TRANSACTIONS ) {
184
-        switch ( $type ) {
183
+    if (WPINV_USE_TRANSACTIONS) {
184
+        switch ($type) {
185 185
             case 'commit' :
186
-                $wpdb->query( 'COMMIT' );
186
+                $wpdb->query('COMMIT');
187 187
                 break;
188 188
             case 'rollback' :
189
-                $wpdb->query( 'ROLLBACK' );
189
+                $wpdb->query('ROLLBACK');
190 190
                 break;
191 191
             default :
192
-                $wpdb->query( 'START TRANSACTION' );
192
+                $wpdb->query('START TRANSACTION');
193 193
             break;
194 194
         }
195 195
     }
196 196
 }
197 197
 
198
-function wpinv_create_invoice( $args = array(), $data = array(), $wp_error = false ) {
198
+function wpinv_create_invoice($args = array(), $data = array(), $wp_error = false) {
199 199
     $default_args = array(
200 200
         'status'        => '',
201 201
         'user_id'       => null,
@@ -205,63 +205,63 @@  discard block
 block discarded – undo
205 205
         'parent'        => 0
206 206
     );
207 207
 
208
-    $args           = wp_parse_args( $args, $default_args );
208
+    $args           = wp_parse_args($args, $default_args);
209 209
     $invoice_data   = array();
210 210
 
211
-    if ( $args['invoice_id'] > 0 ) {
212
-        $updating           = true;
211
+    if ($args['invoice_id'] > 0) {
212
+        $updating = true;
213 213
         $invoice_data['post_type']  = 'wpi_invoice';
214 214
         $invoice_data['ID']         = $args['invoice_id'];
215 215
     } else {
216 216
         $updating                       = false;
217 217
         $invoice_data['post_type']      = 'wpi_invoice';
218
-        $invoice_data['post_status']    = apply_filters( 'wpinv_default_invoice_status', 'pending' );
218
+        $invoice_data['post_status']    = apply_filters('wpinv_default_invoice_status', 'pending');
219 219
         $invoice_data['ping_status']    = 'closed';
220
-        $invoice_data['post_author']    = !empty( $args['user_id'] ) ? $args['user_id'] : get_current_user_id();
221
-        $invoice_data['post_title']     = wpinv_format_invoice_number( '0' );
222
-        $invoice_data['post_parent']    = absint( $args['parent'] );
223
-        if ( !empty( $args['created_date'] ) ) {
220
+        $invoice_data['post_author']    = !empty($args['user_id']) ? $args['user_id'] : get_current_user_id();
221
+        $invoice_data['post_title']     = wpinv_format_invoice_number('0');
222
+        $invoice_data['post_parent']    = absint($args['parent']);
223
+        if (!empty($args['created_date'])) {
224 224
             $invoice_data['post_date']      = $args['created_date'];
225
-            $invoice_data['post_date_gmt']  = get_gmt_from_date( $args['created_date'] );
225
+            $invoice_data['post_date_gmt']  = get_gmt_from_date($args['created_date']);
226 226
         }
227 227
     }
228 228
 
229
-    if ( $args['status'] ) {
230
-        if ( ! in_array( $args['status'], array_keys( wpinv_get_invoice_statuses() ) ) ) {
231
-            return new WP_Error( 'wpinv_invalid_invoice_status', wp_sprintf( __( 'Invalid invoice status: %s', 'invoicing' ), $args['status'] ) );
229
+    if ($args['status']) {
230
+        if (!in_array($args['status'], array_keys(wpinv_get_invoice_statuses()))) {
231
+            return new WP_Error('wpinv_invalid_invoice_status', wp_sprintf(__('Invalid invoice status: %s', 'invoicing'), $args['status']));
232 232
         }
233
-        $invoice_data['post_status']    = $args['status'];
233
+        $invoice_data['post_status'] = $args['status'];
234 234
     }
235 235
 
236
-    if ( ! is_null( $args['user_note'] ) ) {
237
-        $invoice_data['post_excerpt']   = $args['user_note'];
236
+    if (!is_null($args['user_note'])) {
237
+        $invoice_data['post_excerpt'] = $args['user_note'];
238 238
     }
239 239
 
240
-    if ( $updating ) {
241
-        $invoice_id = wp_update_post( $invoice_data, true );
240
+    if ($updating) {
241
+        $invoice_id = wp_update_post($invoice_data, true);
242 242
     } else {
243
-        $invoice_id = wp_insert_post( apply_filters( 'wpinv_new_invoice_data', $invoice_data ), true );
243
+        $invoice_id = wp_insert_post(apply_filters('wpinv_new_invoice_data', $invoice_data), true);
244 244
     }
245 245
 
246
-    if ( is_wp_error( $invoice_id ) ) {
246
+    if (is_wp_error($invoice_id)) {
247 247
         return $wp_error ? $invoice_id : 0;
248 248
     }
249 249
     
250
-    $invoice = wpinv_get_invoice( $invoice_id );
251
-
252
-    if ( !$updating ) {
253
-        update_post_meta( $invoice_id, '_wpinv_key', apply_filters( 'wpinv_generate_invoice_key', uniqid( 'wpinv_' ) ) );
254
-        update_post_meta( $invoice_id, '_wpinv_currency', wpinv_get_currency() );
255
-        update_post_meta( $invoice_id, '_wpinv_include_tax', get_option( 'wpinv_prices_include_tax' ) );
256
-        update_post_meta( $invoice_id, '_wpinv_user_ip', wpinv_get_ip() );
257
-        update_post_meta( $invoice_id, '_wpinv_user_agent', wpinv_get_user_agent() );
258
-        update_post_meta( $invoice_id, '_wpinv_created_via', sanitize_text_field( $args['created_via'] ) );
250
+    $invoice = wpinv_get_invoice($invoice_id);
251
+
252
+    if (!$updating) {
253
+        update_post_meta($invoice_id, '_wpinv_key', apply_filters('wpinv_generate_invoice_key', uniqid('wpinv_')));
254
+        update_post_meta($invoice_id, '_wpinv_currency', wpinv_get_currency());
255
+        update_post_meta($invoice_id, '_wpinv_include_tax', get_option('wpinv_prices_include_tax'));
256
+        update_post_meta($invoice_id, '_wpinv_user_ip', wpinv_get_ip());
257
+        update_post_meta($invoice_id, '_wpinv_user_agent', wpinv_get_user_agent());
258
+        update_post_meta($invoice_id, '_wpinv_created_via', sanitize_text_field($args['created_via']));
259 259
         
260 260
         // Add invoice note
261
-        $invoice->add_note( wp_sprintf( __( 'Invoice is created with status %s.', 'invoicing' ), wpinv_status_nicename( $invoice->status ) ) );
261
+        $invoice->add_note(wp_sprintf(__('Invoice is created with status %s.', 'invoicing'), wpinv_status_nicename($invoice->status)));
262 262
     }
263 263
 
264
-    update_post_meta( $invoice_id, '_wpinv_version', WPINV_VERSION );
264
+    update_post_meta($invoice_id, '_wpinv_version', WPINV_VERSION);
265 265
 
266 266
     return $invoice;
267 267
 }
@@ -269,118 +269,118 @@  discard block
 block discarded – undo
269 269
 function wpinv_get_prefix() {
270 270
     $invoice_prefix = 'INV-';
271 271
     
272
-    return apply_filters( 'wpinv_get_prefix', $invoice_prefix );
272
+    return apply_filters('wpinv_get_prefix', $invoice_prefix);
273 273
 }
274 274
 
275 275
 function wpinv_get_business_logo() {
276
-    $business_logo = wpinv_get_option( 'logo' );
277
-    return apply_filters( 'wpinv_get_business_logo', $business_logo );
276
+    $business_logo = wpinv_get_option('logo');
277
+    return apply_filters('wpinv_get_business_logo', $business_logo);
278 278
 }
279 279
 
280 280
 function wpinv_get_business_name() {
281 281
     $business_name = wpinv_get_option('store_name');
282
-    return apply_filters( 'wpinv_get_business_name', $business_name );
282
+    return apply_filters('wpinv_get_business_name', $business_name);
283 283
 }
284 284
 
285 285
 function wpinv_get_blogname() {
286
-    return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
286
+    return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
287 287
 }
288 288
 
289 289
 function wpinv_get_admin_email() {
290
-    $admin_email = get_option( 'admin_email' );
291
-    return apply_filters( 'wpinv_admin_email', $admin_email );
290
+    $admin_email = get_option('admin_email');
291
+    return apply_filters('wpinv_admin_email', $admin_email);
292 292
 }
293 293
 
294 294
 function wpinv_get_business_website() {
295
-    $business_website = home_url( '/' );
296
-    return apply_filters( 'wpinv_get_business_website', $business_website );
295
+    $business_website = home_url('/');
296
+    return apply_filters('wpinv_get_business_website', $business_website);
297 297
 }
298 298
 
299
-function wpinv_get_terms_text( $invoice_id = 0 ) {
299
+function wpinv_get_terms_text($invoice_id = 0) {
300 300
     $terms_text = '';
301
-    return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id );
301
+    return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id);
302 302
 }
303 303
 
304 304
 function wpinv_get_business_footer() {
305
-    $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>';
306
-    $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link );
307
-    return apply_filters( 'wpinv_get_business_footer', $business_footer );
305
+    $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>';
306
+    $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link);
307
+    return apply_filters('wpinv_get_business_footer', $business_footer);
308 308
 }
309 309
 
310 310
 function wpinv_checkout_required_fields() {
311 311
     $required_fields = array();
312 312
     
313 313
     // Let payment gateways and other extensions determine if address fields should be required
314
-    $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
314
+    $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes());
315 315
     
316
-    if ( $require_billing_details ) {
316
+    if ($require_billing_details) {
317 317
         ///$required_fields['email'] = array(
318 318
                 ///'error_id' => 'invalid_email',
319 319
                 ///'error_message' => __( 'Please enter a valid email address', 'invoicing' )
320 320
             ///);
321 321
         $required_fields['first_name'] = array(
322 322
                 'error_id' => 'invalid_first_name',
323
-                'error_message' => __( 'Please enter your first name', 'invoicing' )
323
+                'error_message' => __('Please enter your first name', 'invoicing')
324 324
             );
325 325
         $required_fields['address'] = array(
326 326
                 'error_id' => 'invalid_address',
327
-                'error_message' => __( 'Please enter your address', 'invoicing' )
327
+                'error_message' => __('Please enter your address', 'invoicing')
328 328
             );
329 329
         $required_fields['city'] = array(
330 330
                 'error_id' => 'invalid_city',
331
-                'error_message' => __( 'Please enter your billing city', 'invoicing' )
331
+                'error_message' => __('Please enter your billing city', 'invoicing')
332 332
             );
333 333
         $required_fields['state'] = array(
334 334
                 'error_id' => 'invalid_state',
335
-                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
335
+                'error_message' => __('Please enter billing state / province', 'invoicing')
336 336
             );
337 337
         $required_fields['country'] = array(
338 338
                 'error_id' => 'invalid_country',
339
-                'error_message' => __( 'Please select your billing country', 'invoicing' )
339
+                'error_message' => __('Please select your billing country', 'invoicing')
340 340
             );
341 341
     }
342 342
 
343
-    return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
343
+    return apply_filters('wpinv_checkout_required_fields', $required_fields);
344 344
 }
345 345
 
346 346
 function wpinv_is_ssl_enforced() {
347
-    $ssl_enforced = wpinv_get_option( 'enforce_ssl', false );
348
-    return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced );
347
+    $ssl_enforced = wpinv_get_option('enforce_ssl', false);
348
+    return (bool)apply_filters('wpinv_is_ssl_enforced', $ssl_enforced);
349 349
 }
350 350
 
351
-function wpinv_user_can_print_invoice( $post ) {
351
+function wpinv_user_can_print_invoice($post) {
352 352
     $allow = false;
353 353
     
354
-    if ( !( $user_id = get_current_user_id() ) ) {
354
+    if (!($user_id = get_current_user_id())) {
355 355
         return $allow;
356 356
     }
357 357
     
358
-    if ( is_int( $post ) ) {
359
-        $post = get_post( $post );
358
+    if (is_int($post)) {
359
+        $post = get_post($post);
360 360
     }
361 361
     
362 362
     // Allow to owner.
363
-    if ( is_object( $post ) && !empty( $post->post_author ) && $post->post_author == $user_id ) {
363
+    if (is_object($post) && !empty($post->post_author) && $post->post_author == $user_id) {
364 364
         $allow = true;
365 365
     }
366 366
     
367 367
     // Allow to admin user.
368
-    if ( current_user_can( 'manage_options' ) ) {
368
+    if (current_user_can('manage_options')) {
369 369
         $allow = true;
370 370
     }
371 371
     
372
-    return apply_filters( 'wpinv_can_print_invoice', $allow, $post );
372
+    return apply_filters('wpinv_can_print_invoice', $allow, $post);
373 373
 }
374 374
 
375 375
 function wpinv_schedule_events() {
376 376
     // hourly, daily and twicedaily
377
-    if ( !wp_next_scheduled( 'wpinv_register_schedule_event_twicedaily' ) ) {
378
-        wp_schedule_event( current_time( 'timestamp' ), 'twicedaily', 'wpinv_register_schedule_event_twicedaily' );
377
+    if (!wp_next_scheduled('wpinv_register_schedule_event_twicedaily')) {
378
+        wp_schedule_event(current_time('timestamp'), 'twicedaily', 'wpinv_register_schedule_event_twicedaily');
379 379
     }
380 380
 }
381
-add_action( 'wp', 'wpinv_schedule_events' );
381
+add_action('wp', 'wpinv_schedule_events');
382 382
 
383 383
 function wpinv_schedule_event_twicedaily() {
384 384
     wpinv_email_payment_reminders();
385 385
 }
386
-add_action( 'wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily' );
387 386
\ No newline at end of file
387
+add_action('wpinv_register_schedule_event_twicedaily', 'wpinv_schedule_event_twicedaily');
388 388
\ No newline at end of file
Please login to merge, or discard this patch.