Passed
Push — master ( 5bb76a...9b8253 )
by Brian
09:28 queued 05:23
created
includes/wpinv-item-functions.php 1 patch
Spacing   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  * 
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' == strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $field );
29
+    if ('id' == strtolower($field)) {
30
+        return wpinv_get_item_by_id($field);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57
-    $args = wp_parse_args( $args, array(
58
-        'status'         => array( 'publish' ),
59
-        'limit'          => get_option( 'posts_per_page' ),
57
+    $args = wp_parse_args($args, array(
58
+        'status'         => array('publish'),
59
+        'limit'          => get_option('posts_per_page'),
60 60
         'page'           => 1,
61 61
         'exclude'        => array(),
62 62
         'orderby'        => 'date',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         'meta_query'     => array(),
66 66
         'return'         => 'objects',
67 67
         'paginate'       => false,
68
-    ) );
68
+    ));
69 69
 
70 70
     $wp_query_args = array(
71 71
         'post_type'      => 'wpi_item',
@@ -75,26 +75,26 @@  discard block
 block discarded – undo
75 75
         'fields'         => 'ids',
76 76
         'orderby'        => $args['orderby'],
77 77
         'order'          => $args['order'],
78
-        'paged'          => absint( $args['page'] ),
78
+        'paged'          => absint($args['page']),
79 79
     );
80 80
 
81
-    if ( ! empty( $args['exclude'] ) ) {
82
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
81
+    if (!empty($args['exclude'])) {
82
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
83 83
     }
84 84
 
85
-    if ( ! $args['paginate' ] ) {
85
+    if (!$args['paginate']) {
86 86
         $wp_query_args['no_found_rows'] = true;
87 87
     }
88 88
 
89
-    if ( ! empty( $args['search'] ) ) {
89
+    if (!empty($args['search'])) {
90 90
         $wp_query_args['s'] = $args['search'];
91 91
     }
92 92
 
93
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
94
-        $types = wpinv_parse_list( $args['type'] );
93
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
94
+        $types = wpinv_parse_list($args['type']);
95 95
         $wp_query_args['meta_query'][] = array(
96 96
             'key'     => '_wpinv_type',
97
-            'value'   => implode( ',', $types ),
97
+            'value'   => implode(',', $types),
98 98
             'compare' => 'IN',
99 99
         );
100 100
     }
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
     $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
103 103
 
104 104
     // Get results.
105
-    $items = new WP_Query( $wp_query_args );
105
+    $items = new WP_Query($wp_query_args);
106 106
 
107
-    if ( 'objects' === $args['return'] ) {
108
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
109
-    } elseif ( 'self' === $args['return'] ) {
107
+    if ('objects' === $args['return']) {
108
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
109
+    } elseif ('self' === $args['return']) {
110 110
         return $items;
111 111
     } else {
112 112
         $return = $items->posts;
113 113
     }
114 114
 
115
-    if ( $args['paginate' ] ) {
115
+    if ($args['paginate']) {
116 116
         return (object) array(
117 117
             'items'      => $return,
118 118
             'total'         => $items->found_posts,
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 
125 125
 }
126 126
 
127
-function wpinv_is_free_item( $item_id = 0 ) {
128
-    if( empty( $item_id ) ) {
127
+function wpinv_is_free_item($item_id = 0) {
128
+    if (empty($item_id)) {
129 129
         return false;
130 130
     }
131 131
 
132
-    $item = new WPInv_Item( $item_id );
132
+    $item = new WPInv_Item($item_id);
133 133
     
134 134
     return $item->is_free();
135 135
 }
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
  * 
140 140
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
141 141
  */
142
-function wpinv_item_is_editable( $item = 0 ) {
142
+function wpinv_item_is_editable($item = 0) {
143 143
 
144 144
     // Fetch the item.
145
-    $item = new WPInv_Item( $item );
145
+    $item = new WPInv_Item($item);
146 146
 
147 147
     // Check if it is editable.
148 148
     return $item->is_editable();
149 149
 }
150 150
 
151
-function wpinv_get_item_price( $item_id = 0 ) {
152
-    if( empty( $item_id ) ) {
151
+function wpinv_get_item_price($item_id = 0) {
152
+    if (empty($item_id)) {
153 153
         return false;
154 154
     }
155 155
 
156
-    $item = new WPInv_Item( $item_id );
156
+    $item = new WPInv_Item($item_id);
157 157
     
158 158
     return $item->get_price();
159 159
 }
@@ -163,266 +163,266 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @param WPInv_Item|int $item
165 165
  */
166
-function wpinv_is_recurring_item( $item = 0 ) {
167
-    $item = new WPInv_Item( $item ); 
166
+function wpinv_is_recurring_item($item = 0) {
167
+    $item = new WPInv_Item($item); 
168 168
     return $item->is_recurring();
169 169
 }
170 170
 
171
-function wpinv_item_price( $item_id = 0 ) {
172
-    if( empty( $item_id ) ) {
171
+function wpinv_item_price($item_id = 0) {
172
+    if (empty($item_id)) {
173 173
         return false;
174 174
     }
175 175
 
176
-    $price = wpinv_get_item_price( $item_id );
177
-    $price = wpinv_price( wpinv_format_amount( $price ) );
176
+    $price = wpinv_get_item_price($item_id);
177
+    $price = wpinv_price(wpinv_format_amount($price));
178 178
     
179
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
179
+    return apply_filters('wpinv_item_price', $price, $item_id);
180 180
 }
181 181
 
182
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
183
-    if ( is_null( $amount_override ) ) {
184
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
182
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
183
+    if (is_null($amount_override)) {
184
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
185 185
     } else {
186 186
         $original_price = $amount_override;
187 187
     }
188 188
     
189 189
     $price = $original_price;
190 190
 
191
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
191
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
192 192
 }
193 193
 
194
-function wpinv_item_custom_singular_name( $item_id ) {
195
-    if( empty( $item_id ) ) {
194
+function wpinv_item_custom_singular_name($item_id) {
195
+    if (empty($item_id)) {
196 196
         return false;
197 197
     }
198 198
 
199
-    $item = new WPInv_Item( $item_id );
199
+    $item = new WPInv_Item($item_id);
200 200
     
201 201
     return $item->get_custom_singular_name();
202 202
 }
203 203
 
204 204
 function wpinv_get_item_types() {
205 205
     $item_types = array(
206
-            'custom'    => __( 'Standard', 'invoicing' ),
207
-            'fee'       => __( 'Fee', 'invoicing' ),
206
+            'custom'    => __('Standard', 'invoicing'),
207
+            'fee'       => __('Fee', 'invoicing'),
208 208
         );
209
-    return apply_filters( 'wpinv_get_item_types', $item_types );
209
+    return apply_filters('wpinv_get_item_types', $item_types);
210 210
 }
211 211
 
212 212
 function wpinv_item_types() {
213 213
     $item_types = wpinv_get_item_types();
214 214
     
215
-    return ( !empty( $item_types ) ? array_keys( $item_types ) : array() );
215
+    return (!empty($item_types) ? array_keys($item_types) : array());
216 216
 }
217 217
 
218
-function wpinv_get_item_type( $item_id ) {
219
-    if( empty( $item_id ) ) {
218
+function wpinv_get_item_type($item_id) {
219
+    if (empty($item_id)) {
220 220
         return false;
221 221
     }
222 222
 
223
-    $item = new WPInv_Item( $item_id );
223
+    $item = new WPInv_Item($item_id);
224 224
     
225 225
     return $item->get_type();
226 226
 }
227 227
 
228
-function wpinv_item_type( $item_id ) {
228
+function wpinv_item_type($item_id) {
229 229
     $item_types = wpinv_get_item_types();
230 230
     
231
-    $item_type = wpinv_get_item_type( $item_id );
231
+    $item_type = wpinv_get_item_type($item_id);
232 232
     
233
-    if ( empty( $item_type ) ) {
233
+    if (empty($item_type)) {
234 234
         $item_type = '-';
235 235
     }
236 236
     
237
-    $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' );
237
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
238 238
 
239
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
239
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
240 240
 }
241 241
 
242
-function wpinv_get_random_item( $post_ids = true ) {
243
-    wpinv_get_random_items( 1, $post_ids );
242
+function wpinv_get_random_item($post_ids = true) {
243
+    wpinv_get_random_items(1, $post_ids);
244 244
 }
245 245
 
246
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
247
-    if ( $post_ids ) {
248
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' );
246
+function wpinv_get_random_items($num = 3, $post_ids = true) {
247
+    if ($post_ids) {
248
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids');
249 249
     } else {
250
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num );
250
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num);
251 251
     }
252 252
     
253
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
253
+    $args = apply_filters('wpinv_get_random_items', $args);
254 254
     
255
-    return get_posts( $args );
255
+    return get_posts($args);
256 256
 }
257 257
 
258
-function wpinv_get_item_token( $url = '' ) {
258
+function wpinv_get_item_token($url = '') {
259 259
     $args    = array();
260
-    $hash    = apply_filters( 'wpinv_get_url_token_algorithm', 'sha256' );
261
-    $secret  = apply_filters( 'wpinv_get_url_token_secret', hash( $hash, wp_salt() ) );
260
+    $hash    = apply_filters('wpinv_get_url_token_algorithm', 'sha256');
261
+    $secret  = apply_filters('wpinv_get_url_token_secret', hash($hash, wp_salt()));
262 262
 
263
-    $parts   = parse_url( $url );
263
+    $parts   = parse_url($url);
264 264
     $options = array();
265 265
 
266
-    if ( isset( $parts['query'] ) ) {
267
-        wp_parse_str( $parts['query'], $query_args );
266
+    if (isset($parts['query'])) {
267
+        wp_parse_str($parts['query'], $query_args);
268 268
 
269
-        if ( ! empty( $query_args['o'] ) ) {
270
-            $options = explode( ':', rawurldecode( $query_args['o'] ) );
269
+        if (!empty($query_args['o'])) {
270
+            $options = explode(':', rawurldecode($query_args['o']));
271 271
 
272
-            if ( in_array( 'ip', $options ) ) {
272
+            if (in_array('ip', $options)) {
273 273
                 $args['ip'] = wpinv_get_ip();
274 274
             }
275 275
 
276
-            if ( in_array( 'ua', $options ) ) {
276
+            if (in_array('ua', $options)) {
277 277
                 $ua = wpinv_get_user_agent();
278
-                $args['user_agent'] = rawurlencode( $ua );
278
+                $args['user_agent'] = rawurlencode($ua);
279 279
             }
280 280
         }
281 281
     }
282 282
 
283
-    $args = apply_filters( 'wpinv_get_url_token_args', $args, $url, $options );
283
+    $args = apply_filters('wpinv_get_url_token_args', $args, $url, $options);
284 284
 
285 285
     $args['secret'] = $secret;
286 286
     $args['token']  = false;
287 287
 
288
-    $url   = add_query_arg( $args, $url );
289
-    $parts = parse_url( $url );
288
+    $url   = add_query_arg($args, $url);
289
+    $parts = parse_url($url);
290 290
 
291
-    if ( ! isset( $parts['path'] ) ) {
291
+    if (!isset($parts['path'])) {
292 292
         $parts['path'] = '';
293 293
     }
294 294
 
295
-    $token = md5( $parts['path'] . '?' . $parts['query'] );
295
+    $token = md5($parts['path'] . '?' . $parts['query']);
296 296
 
297 297
     return $token;
298 298
 }
299 299
 
300
-function wpinv_validate_url_token( $url = '' ) {
300
+function wpinv_validate_url_token($url = '') {
301 301
     $ret   = false;
302
-    $parts = parse_url( $url );
302
+    $parts = parse_url($url);
303 303
 
304
-    if ( isset( $parts['query'] ) ) {
305
-        wp_parse_str( $parts['query'], $query_args );
304
+    if (isset($parts['query'])) {
305
+        wp_parse_str($parts['query'], $query_args);
306 306
 
307
-        $allowed = apply_filters( 'wpinv_url_token_allowed_params', array(
307
+        $allowed = apply_filters('wpinv_url_token_allowed_params', array(
308 308
             'item',
309 309
             'ttl',
310 310
             'token'
311
-        ) );
311
+        ));
312 312
 
313 313
         $remove = array();
314 314
 
315
-        foreach( $query_args as $key => $value ) {
316
-            if( false === in_array( $key, $allowed ) ) {
315
+        foreach ($query_args as $key => $value) {
316
+            if (false === in_array($key, $allowed)) {
317 317
                 $remove[] = $key;
318 318
             }
319 319
         }
320 320
 
321
-        if( ! empty( $remove ) ) {
322
-            $url = remove_query_arg( $remove, $url );
321
+        if (!empty($remove)) {
322
+            $url = remove_query_arg($remove, $url);
323 323
         }
324 324
 
325
-        if ( isset( $query_args['ttl'] ) && current_time( 'timestamp' ) > $query_args['ttl'] ) {
326
-            wp_die( apply_filters( 'wpinv_item_link_expired_text', __( 'Sorry but your item link has expired.', 'invoicing' ) ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
325
+        if (isset($query_args['ttl']) && current_time('timestamp') > $query_args['ttl']) {
326
+            wp_die(apply_filters('wpinv_item_link_expired_text', __('Sorry but your item link has expired.', 'invoicing')), __('Error', 'invoicing'), array('response' => 403));
327 327
         }
328 328
 
329
-        if ( isset( $query_args['token'] ) && $query_args['token'] == wpinv_get_item_token( $url ) ) {
329
+        if (isset($query_args['token']) && $query_args['token'] == wpinv_get_item_token($url)) {
330 330
             $ret = true;
331 331
         }
332 332
 
333 333
     }
334 334
 
335
-    return apply_filters( 'wpinv_validate_url_token', $ret, $url, $query_args );
335
+    return apply_filters('wpinv_validate_url_token', $ret, $url, $query_args);
336 336
 }
337 337
 
338
-function wpinv_item_in_cart( $item_id = 0, $options = array() ) {
338
+function wpinv_item_in_cart($item_id = 0, $options = array()) {
339 339
     $cart_items = wpinv_get_cart_contents();
340 340
 
341 341
     $ret = false;
342 342
 
343
-    if ( is_array( $cart_items ) ) {
344
-        foreach ( $cart_items as $item ) {
345
-            if ( $item['id'] == $item_id ) {
343
+    if (is_array($cart_items)) {
344
+        foreach ($cart_items as $item) {
345
+            if ($item['id'] == $item_id) {
346 346
                 $ret = true;
347 347
                 break;
348 348
             }
349 349
         }
350 350
     }
351 351
 
352
-    return (bool) apply_filters( 'wpinv_item_in_cart', $ret, $item_id, $options );
352
+    return (bool) apply_filters('wpinv_item_in_cart', $ret, $item_id, $options);
353 353
 }
354 354
 
355
-function wpinv_get_cart_item_tax( $item_id = 0, $subtotal = '', $options = array() ) {
355
+function wpinv_get_cart_item_tax($item_id = 0, $subtotal = '', $options = array()) {
356 356
     $tax = 0;
357
-    if ( ! wpinv_item_is_tax_exclusive( $item_id ) ) {
358
-        $country = !empty( $_POST['country'] ) ? $_POST['country'] : false;
359
-        $state   = isset( $_POST['state'] ) ? $_POST['state'] : '';
357
+    if (!wpinv_item_is_tax_exclusive($item_id)) {
358
+        $country = !empty($_POST['country']) ? $_POST['country'] : false;
359
+        $state   = isset($_POST['state']) ? $_POST['state'] : '';
360 360
 
361
-        $tax = wpinv_calculate_tax( $subtotal, $country, $state, $item_id );
361
+        $tax = wpinv_calculate_tax($subtotal, $country, $state, $item_id);
362 362
     }
363 363
 
364
-    return apply_filters( 'wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options );
364
+    return apply_filters('wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options);
365 365
 }
366 366
 
367
-function wpinv_cart_item_price( $item, $currency = '' ) {
367
+function wpinv_cart_item_price($item, $currency = '') {
368 368
 
369
-    if( empty( $currency ) ) {
369
+    if (empty($currency)) {
370 370
         $currency = wpinv_get_currency();
371 371
     }
372 372
 
373
-    $item_id    = isset( $item['id'] ) ? $item['id'] : 0;
374
-    $price      = isset( $item['item_price'] ) ? wpinv_round_amount( $item['item_price'] ) : 0;
375
-    $tax        = wpinv_price( wpinv_format_amount( $item['tax'] ) );
373
+    $item_id    = isset($item['id']) ? $item['id'] : 0;
374
+    $price      = isset($item['item_price']) ? wpinv_round_amount($item['item_price']) : 0;
375
+    $tax        = wpinv_price(wpinv_format_amount($item['tax']));
376 376
     
377
-    if ( !wpinv_is_free_item( $item_id ) && !wpinv_item_is_tax_exclusive( $item_id ) ) {
378
-        if ( wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax() ) {
377
+    if (!wpinv_is_free_item($item_id) && !wpinv_item_is_tax_exclusive($item_id)) {
378
+        if (wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax()) {
379 379
             $price += $tax;
380 380
         }
381 381
         
382
-        if( !wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax() ) {
382
+        if (!wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax()) {
383 383
             $price -= $tax;
384 384
         }        
385 385
     }
386 386
 
387
-    $price = wpinv_price( wpinv_format_amount( $price ), $currency );
387
+    $price = wpinv_price(wpinv_format_amount($price), $currency);
388 388
 
389
-    return apply_filters( 'wpinv_cart_item_price_label', $price, $item );
389
+    return apply_filters('wpinv_cart_item_price_label', $price, $item);
390 390
 }
391 391
 
392
-function wpinv_cart_item_subtotal( $item, $currency = '' ) {
392
+function wpinv_cart_item_subtotal($item, $currency = '') {
393 393
 
394
-    if( empty( $currency ) ) {
394
+    if (empty($currency)) {
395 395
         $currency = wpinv_get_currency();
396 396
     }
397 397
 
398
-    $subtotal   = isset( $item['subtotal'] ) ? $item['subtotal'] : 0;
399
-    $subtotal   = wpinv_price( wpinv_format_amount( $subtotal ), $currency );
398
+    $subtotal   = isset($item['subtotal']) ? $item['subtotal'] : 0;
399
+    $subtotal   = wpinv_price(wpinv_format_amount($subtotal), $currency);
400 400
 
401
-    return apply_filters( 'wpinv_cart_item_subtotal_label', $subtotal, $item );
401
+    return apply_filters('wpinv_cart_item_subtotal_label', $subtotal, $item);
402 402
 }
403 403
 
404
-function wpinv_cart_item_tax( $item, $currency = '' ) {
404
+function wpinv_cart_item_tax($item, $currency = '') {
405 405
     $tax        = '';
406 406
     $tax_rate   = '';
407 407
 
408
-    if( empty( $currency ) ) {
408
+    if (empty($currency)) {
409 409
         $currency = wpinv_get_currency();
410 410
     }
411 411
     
412
-    if ( isset( $item['tax'] ) && $item['tax'] > 0 && $item['subtotal'] > 0 ) {
413
-        $tax      = wpinv_price( wpinv_format_amount( $item['tax'] ), $currency );
414
-        $tax_rate = !empty( $item['vat_rate'] ) ? $item['vat_rate'] : ( $item['tax'] / $item['subtotal'] ) * 100;
415
-        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
412
+    if (isset($item['tax']) && $item['tax'] > 0 && $item['subtotal'] > 0) {
413
+        $tax      = wpinv_price(wpinv_format_amount($item['tax']), $currency);
414
+        $tax_rate = !empty($item['vat_rate']) ? $item['vat_rate'] : ($item['tax'] / $item['subtotal']) * 100;
415
+        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
416 416
         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate normal small">(' . $tax_rate . '%)</small>' : '';
417 417
     }
418 418
     
419
-    $tax        = $tax . $tax_rate;
419
+    $tax = $tax . $tax_rate;
420 420
     
421
-    if ( $tax === '' ) {
421
+    if ($tax === '') {
422 422
         $tax = 0; // Zero tax
423 423
     }
424 424
 
425
-    return apply_filters( 'wpinv_cart_item_tax_label', $tax, $item );
425
+    return apply_filters('wpinv_cart_item_tax_label', $tax, $item);
426 426
 }
427 427
 
428 428
 /**
@@ -431,13 +431,13 @@  discard block
 block discarded – undo
431 431
  * @param WPInv_Item|int $item
432 432
  * @param bool $html
433 433
  */
434
-function wpinv_get_item_suffix( $item, $html = true ) {
434
+function wpinv_get_item_suffix($item, $html = true) {
435 435
 
436
-    $item   = new WPInv_Item( $item );
437
-    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '';
438
-    $suffix = $html ? $suffix : strip_tags( $suffix );
436
+    $item   = new WPInv_Item($item);
437
+    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '';
438
+    $suffix = $html ? $suffix : strip_tags($suffix);
439 439
 
440
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
440
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
441 441
 }
442 442
 
443 443
 /**
@@ -446,9 +446,9 @@  discard block
 block discarded – undo
446 446
  * @param WPInv_Item|int $item
447 447
  * @param bool $force_delete
448 448
  */
449
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
450
-    $item = new WPInv_Item( $item );
451
-    $item->delete( $force_delete );
449
+function wpinv_remove_item($item = 0, $force_delete = false) {
450
+    $item = new WPInv_Item($item);
451
+    $item->delete($force_delete);
452 452
 }
453 453
 
454 454
 /**
@@ -487,45 +487,45 @@  discard block
 block discarded – undo
487 487
  * @param bool $wp_error whether or not to return a WP_Error on failure.
488 488
  * @return bool|WP_Error|WPInv_Item
489 489
  */
490
-function wpinv_create_item( $args = array(), $wp_error = false ) {
490
+function wpinv_create_item($args = array(), $wp_error = false) {
491 491
 
492 492
     // Prepare the item.
493
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
494
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
495
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
493
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
494
+        $type = empty($args['type']) ? 'custom' : $args['type'];
495
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
496 496
 
497
-        if ( ! empty( $item ) ) {
497
+        if (!empty($item)) {
498 498
             $args['ID'] = $item->get_id();
499 499
         }
500 500
 
501 501
     }
502 502
 
503 503
     // Do we have an item?
504
-    if ( ! empty( $args['ID'] ) ) {
505
-        $item = new WPInv_Item( $args['ID'] );
504
+    if (!empty($args['ID'])) {
505
+        $item = new WPInv_Item($args['ID']);
506 506
     } else {
507 507
         $item = new WPInv_Item();
508 508
     }
509 509
 
510 510
     // Do we have an error?
511
-    if ( ! empty( $item->last_error ) ) {
512
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
511
+    if (!empty($item->last_error)) {
512
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
513 513
     }
514 514
 
515 515
     // Update item props.
516
-    $item->set_props( $args );
516
+    $item->set_props($args);
517 517
 
518 518
     // Save the item.
519 519
     $item->save();
520 520
 
521 521
     // Do we have an error?
522
-    if ( ! empty( $item->last_error ) ) {
523
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
522
+    if (!empty($item->last_error)) {
523
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
524 524
     }
525 525
 
526 526
     // Was the item saved?
527
-    if ( ! $item->get_id() ) {
528
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
527
+    if (!$item->get_id()) {
528
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
529 529
     }
530 530
 
531 531
     return $item;
@@ -537,14 +537,14 @@  discard block
 block discarded – undo
537 537
  * 
538 538
  * @see wpinv_create_item()
539 539
  */
540
-function wpinv_update_item( $args = array(), $wp_error = false ) {
541
-    return wpinv_create_item( $args, $wp_error );
540
+function wpinv_update_item($args = array(), $wp_error = false) {
541
+    return wpinv_create_item($args, $wp_error);
542 542
 }
543 543
 
544 544
 /**
545 545
  * Sanitizes a recurring period
546 546
  */
547
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
547
+function getpaid_sanitize_recurring_period($period, $full = false) {
548 548
 
549 549
     $periods = array(
550 550
         'D' => 'day',
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
         'Y' => 'year',
554 554
     );
555 555
 
556
-    if ( ! isset( $periods[ $period ] ) ) {
556
+    if (!isset($periods[$period])) {
557 557
         $period = 'D';
558 558
     }
559 559
 
560
-    return $full ? $periods[ $period ] : $period;
560
+    return $full ? $periods[$period] : $period;
561 561
 
562 562
 }
563 563
 
@@ -566,34 +566,34 @@  discard block
 block discarded – undo
566 566
  * 
567 567
  * @param WPInv_Item|GetPaid_Form_Item $item
568 568
  */
569
-function getpaid_item_recurring_price_help_text( $item, $currency = '' ) {
569
+function getpaid_item_recurring_price_help_text($item, $currency = '') {
570 570
 
571 571
     // Abort if it is not recurring.
572
-    if ( ! $item->is_recurring() ) {
572
+    if (!$item->is_recurring()) {
573 573
         return '';
574 574
     }
575 575
 
576
-    $initial_price   = wpinv_price( $item->get_initial_price(), $currency );
577
-    $recurring_price = wpinv_price( $item->get_recurring_price(), $currency );
578
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
576
+    $initial_price   = wpinv_price($item->get_initial_price(), $currency);
577
+    $recurring_price = wpinv_price($item->get_recurring_price(), $currency);
578
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
579 579
     $initial_class   = 'getpaid-item-initial-price';
580 580
     $recurring_class = 'getpaid-item-recurring-price';
581 581
 
582
-    if ( $item instanceof GetPaid_Form_Item ) {
583
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
584
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
582
+    if ($item instanceof GetPaid_Form_Item) {
583
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
584
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
585 585
     }
586 586
 
587 587
     // For free trial items.
588
-    if ( $item->has_free_trial() ) {
589
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
588
+    if ($item->has_free_trial()) {
589
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
590 590
 
591
-        if ( 0 == $item->get_initial_price() ) {
591
+        if (0 == $item->get_initial_price()) {
592 592
 
593 593
             return sprintf(
594 594
 
595 595
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
596
-                _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
596
+                _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
597 597
                 $trial_period,
598 598
                 "<span class='$recurring_class'>$recurring_price</span>",
599 599
                 $period
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
         return sprintf(
606 606
 
607 607
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
608
-            _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
608
+            _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
609 609
             "<span class='$initial_class'>$initial_price</span>",
610 610
             $trial_period,
611 611
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
 
616 616
     }
617 617
 
618
-    if ( $initial_price == $recurring_price ) {
618
+    if ($initial_price == $recurring_price) {
619 619
 
620 620
         return sprintf(
621 621
 
622 622
             // translators: $1: is the recurring price, $2: is the susbcription period
623
-            _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
623
+            _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
624 624
             "<span class='$recurring_class'>$recurring_price</span>",
625 625
             $period
626 626
 
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
     return sprintf(
632 632
 
633 633
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
634
-        _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
634
+        _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
635 635
         "<span class='$initial_class'>$initial_price</span>",
636 636
         "<span class='$recurring_class'>$recurring_price</span>",
637 637
         $period
Please login to merge, or discard this patch.
includes/class-getpaid-notification-email-sender.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This function is responsible for sending emails.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * 
33 33
      * @return bool
34 34
 	 */
35
-	public function send( $to, $subject, $email, $attachments = array() ) {
35
+	public function send($to, $subject, $email, $attachments = array()) {
36 36
 
37 37
 		/*
38 38
 		 * Allow to filter data on per-email basis.
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 		$data = apply_filters(
41 41
 			'getpaid_email_data',
42 42
 			array(
43
-				'to'          => array_filter( array_unique( wpinv_parse_list( $to ) ) ),
44
-				'subject'     => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ),
43
+				'to'          => array_filter(array_unique(wpinv_parse_list($to))),
44
+				'subject'     => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES),
45 45
 				'email'       => $email,
46 46
 				'headers'     => $this->get_headers(),
47 47
 				'attachments' => $attachments,
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		);
51 51
 
52 52
         // Remove slashes.
53
-        $data               = (array) wp_unslash( $data );
53
+        $data = (array) wp_unslash($data);
54 54
 
55 55
         // Cache it.
56 56
 		$this->wp_mail_data = $data;
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 
61 61
         $result = false;
62 62
 
63
-        foreach ( $this->wp_mail_data['to'] as $to ) {
64
-			$result = $this->_send( $to, $data );
63
+        foreach ($this->wp_mail_data['to'] as $to) {
64
+			$result = $this->_send($to, $data);
65 65
         }
66 66
 
67 67
 		// Remove our hooks.
@@ -82,24 +82,24 @@  discard block
 block discarded – undo
82 82
      * 
83 83
      * @return bool
84 84
 	 */
85
-	protected function _send( $to, $data ) {
85
+	protected function _send($to, $data) {
86 86
 
87 87
 		// Prepare the sending function.
88
-		$sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' );
88
+		$sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail');
89 89
 
90 90
 		// Send the actual email.
91 91
 		$result = call_user_func(
92 92
 			$sending_function,
93 93
 			$to,
94
-			html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ),
94
+			html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')),
95 95
 			$data['email'],
96 96
 			$data['headers'],
97 97
 			$data['attachments']
98 98
 		);
99 99
 
100
-		if ( ! $result ) {
101
-			$log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] );
102
-			wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ );
100
+		if (!$result) {
101
+			$log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']);
102
+			wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__);
103 103
 		}
104 104
 
105 105
 		return $result;
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$name       = $this->get_from_name();
114 114
 		$reply_to   = $this->get_reply_to();
115
-		$headers    = array( "Reply-To:$name <$reply_to>" );
115
+		$headers    = array("Reply-To:$name <$reply_to>");
116 116
 
117
-		return apply_filters( 'getpaid_email_headers',  $headers, $this );
117
+		return apply_filters('getpaid_email_headers', $headers, $this);
118 118
 
119 119
 	}
120 120
 
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function before_sending() {
127 127
 
128
-        do_action( 'getpaid_before_send_email', $this );
129
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
130
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
131
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
132
-		add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 );
128
+        do_action('getpaid_before_send_email', $this);
129
+		add_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
130
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
131
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
132
+		add_filter('wp_mail', array($this, 'ensure_email_content'), 1000);
133 133
 
134 134
 	}
135 135
 
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_from_name() {
140 140
 
141
-        $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) );
141
+        $from_name = wpinv_get_option('email_from_name', get_bloginfo('name'));
142 142
 
143
-		if ( empty( $from_name ) ) {
144
-			$from_name =  get_bloginfo( 'name' );
143
+		if (empty($from_name)) {
144
+			$from_name = get_bloginfo('name');
145 145
         }
146 146
 
147
-		return wp_specialchars_decode( $from_name, ENT_QUOTES );
147
+		return wp_specialchars_decode($from_name, ENT_QUOTES);
148 148
     }
149 149
 
150 150
     /**
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function get_from_address() {
154 154
 
155
-        $from_address = wpinv_get_option( 'email_from', $this->default_from_address() );
155
+        $from_address = wpinv_get_option('email_from', $this->default_from_address());
156 156
 
157
-		if ( ! is_email( $from_address ) ) {
158
-			$from_address =  $this->default_from_address();
157
+		if (!is_email($from_address)) {
158
+			$from_address = $this->default_from_address();
159 159
         }
160 160
         
161 161
         return $from_address;
@@ -174,14 +174,14 @@  discard block
 block discarded – undo
174 174
 	public function default_from_address() {
175 175
 
176 176
 		// Get the site domain and get rid of www.
177
-		$sitename = strtolower( $_SERVER['SERVER_NAME'] );
178
-		if ( substr( $sitename, 0, 4 ) == 'www.' ) {
179
-			$sitename = substr( $sitename, 4 );
177
+		$sitename = strtolower($_SERVER['SERVER_NAME']);
178
+		if (substr($sitename, 0, 4) == 'www.') {
179
+			$sitename = substr($sitename, 4);
180 180
 		}
181 181
 
182 182
 		$from_email = 'wordpress@' . $sitename;
183 183
 
184
-		return apply_filters( 'getpaid_default_from_address', $from_email );
184
+		return apply_filters('getpaid_default_from_address', $from_email);
185 185
 
186 186
     }
187 187
     
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 
196 196
 		$reply_to = wpinv_get_admin_email();
197 197
 
198
-		if ( ! is_email( $reply_to ) ) {
199
-			$reply_to =  get_option( 'admin_email' );
198
+		if (!is_email($reply_to)) {
199
+			$reply_to = get_option('admin_email');
200 200
 		}
201 201
 
202 202
 		return $reply_to;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 */
209 209
 	public function get_content_type() {
210
-		return apply_filters( 'getpaid_email_content_type', 'text/html', $this );
210
+		return apply_filters('getpaid_email_content_type', 'text/html', $this);
211 211
     }
212 212
     
213 213
     /**
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return array wp_mail_data.
217 217
 	 */
218
-	public function ensure_email_content( $args ) {
218
+	public function ensure_email_content($args) {
219 219
 		$args['message'] = $this->wp_mail_data['email'];
220 220
 		return $args;
221 221
     }
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
  	 */
227 227
 	public function after_sending() {
228 228
 
229
-        do_action( 'getpaid_after_send_email', $this->wp_mail_data );
230
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 );
231
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 );
232
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 );
233
-		remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000000 );
229
+        do_action('getpaid_after_send_email', $this->wp_mail_data);
230
+		remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000);
231
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000);
232
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000);
233
+		remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000000);
234 234
 
235 235
 	}
236 236
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -72,28 +72,28 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74 74
 	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
75
+	public function __construct($form = 0) {
76
+		parent::__construct($form);
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+		if (is_numeric($form) && $form > 0) {
79
+			$this->set_id($form);
80
+		} elseif ($form instanceof self) {
81 81
 
82
-			$this->set_id( $form->get_id() );
82
+			$this->set_id($form->get_id());
83 83
 			$this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
85
+		} elseif (!empty($form->ID)) {
86
+			$this->set_id($form->ID);
87 87
 		} else {
88
-			$this->set_object_read( true );
88
+			$this->set_object_read(true);
89 89
 		}
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
93 93
 
94
-		if ( $this->get_id() > 0 ) {
95
-            $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
94
+		if ($this->get_id() > 0) {
95
+            $this->post = get_post($this->get_id());
96
+			$this->data_store->read($this);
97 97
         }
98 98
 
99 99
 	}
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 * @param  string $context View or edit context.
121 121
 	 * @return string
122 122
 	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
123
+	public function get_version($context = 'view') {
124
+		return $this->get_prop('version', $context);
125 125
     }
126 126
 
127 127
     /**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param  string $context View or edit context.
132 132
 	 * @return string
133 133
 	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
134
+	public function get_date_created($context = 'view') {
135
+		return $this->get_prop('date_created', $context);
136 136
     }
137 137
 
138 138
     /**
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 	 * @param  string $context View or edit context.
143 143
 	 * @return string
144 144
 	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
146
-        $date = $this->get_date_created( $context );
145
+	public function get_date_created_gmt($context = 'view') {
146
+        $date = $this->get_date_created($context);
147 147
 
148
-        if ( $date ) {
149
-            $date = get_gmt_from_date( $date );
148
+        if ($date) {
149
+            $date = get_gmt_from_date($date);
150 150
         }
151 151
 		return $date;
152 152
     }
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @param  string $context View or edit context.
159 159
 	 * @return string
160 160
 	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
161
+	public function get_date_modified($context = 'view') {
162
+		return $this->get_prop('date_modified', $context);
163 163
     }
164 164
 
165 165
     /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param  string $context View or edit context.
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
173
-        $date = $this->get_date_modified( $context );
172
+	public function get_date_modified_gmt($context = 'view') {
173
+        $date = $this->get_date_modified($context);
174 174
 
175
-        if ( $date ) {
176
-            $date = get_gmt_from_date( $date );
175
+        if ($date) {
176
+            $date = get_gmt_from_date($date);
177 177
         }
178 178
 		return $date;
179 179
     }
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param  string $context View or edit context.
186 186
 	 * @return string
187 187
 	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
188
+	public function get_name($context = 'view') {
189
+		return $this->get_prop('name', $context);
190 190
     }
191 191
 
192 192
     /**
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 	 * @param  string $context View or edit context.
197 197
 	 * @return string
198 198
 	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
199
+	public function get_title($context = 'view') {
200
+		return $this->get_name($context);
201 201
 	}
202 202
 
203 203
     /**
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 	 * @param  string $context View or edit context.
208 208
 	 * @return int
209 209
 	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
210
+	public function get_author($context = 'view') {
211
+		return (int) $this->get_prop('author', $context);
212 212
     }
213 213
 
214 214
     /**
@@ -218,21 +218,21 @@  discard block
 block discarded – undo
218 218
 	 * @param  string $context View or edit context.
219 219
 	 * @return array
220 220
 	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
221
+	public function get_elements($context = 'view') {
222
+		$elements = $this->get_prop('elements', $context);
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
225
-            return wpinv_get_data( 'sample-payment-form' );
224
+		if (empty($elements) || !is_array($elements)) {
225
+            return wpinv_get_data('sample-payment-form');
226 226
 		}
227 227
 
228 228
 		// Ensure that all required elements exist.
229 229
 		$_elements = array();
230
-		foreach ( $elements as $element ) {
230
+		foreach ($elements as $element) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+			if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) {
233 233
 
234 234
 				$_elements[] = array(
235
-					'text'        => __( 'Select Payment Method', 'invoicing' ),
235
+					'text'        => __('Select Payment Method', 'invoicing'),
236 236
 					'id'          => 'gtscicd',
237 237
 					'name'        => 'gtscicd',
238 238
 					'type'        => 'gateway_select',
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $return objects or arrays.
258 258
 	 * @return GetPaid_Form_Item[]
259 259
 	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
260
+	public function get_items($context = 'view', $return = 'objects') {
261
+		$items = $this->get_prop('items', $context);
262 262
 
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
264
-            $items = wpinv_get_data( 'sample-payment-form-items' );
263
+		if (empty($items) || !is_array($items)) {
264
+            $items = wpinv_get_data('sample-payment-form-items');
265 265
 		}
266 266
 
267 267
 		// Convert the items.
268 268
 		$prepared = array();
269 269
 
270
-		foreach ( $items as $key => $value ) {
270
+		foreach ($items as $key => $value) {
271 271
 
272 272
 			// Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
273
+			if ($value instanceof GetPaid_Form_Item) {
274 274
 
275
-				if ( $value->can_purchase() ) {
275
+				if ($value->can_purchase()) {
276 276
 					$prepared[] = $value;
277 277
 				}
278 278
 
@@ -281,16 +281,16 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 
283 283
 			// $item_id => $quantity (buy buttons)
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
284
+			if (is_numeric($key) && is_numeric($value)) {
285
+				$item = new GetPaid_Form_Item($key);
286 286
 
287
-				if ( $item->can_purchase() ) {
287
+				if ($item->can_purchase()) {
288 288
 
289 289
 					$value = (int) $value;
290
-					$item->set_quantity( $value );
291
-					if ( 0 == $value ) {
292
-						$item->set_quantity( 1 );
293
-						$item->set_allow_quantities( true );
290
+					$item->set_quantity($value);
291
+					if (0 == $value) {
292
+						$item->set_quantity(1);
293
+						$item->set_allow_quantities(true);
294 294
 					}
295 295
 
296 296
 					$prepared[] = $item;
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 
302 302
 			// Items saved via payment forms editor.
303
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
303
+			if (is_array($value) && isset($value['id'])) {
304 304
 
305
-				$item = new GetPaid_Form_Item( $value['id'] );
305
+				$item = new GetPaid_Form_Item($value['id']);
306 306
 
307
-				if ( ! $item->can_purchase() ) {
307
+				if (!$item->can_purchase()) {
308 308
 					continue;
309 309
 				}
310 310
 
311 311
 				// Sub-total (Cart items).
312
-				if ( isset( $value['subtotal'] ) ) {
313
-					$item->set_price( $value['subtotal'] );
312
+				if (isset($value['subtotal'])) {
313
+					$item->set_price($value['subtotal']);
314 314
 				}
315 315
 
316
-				if ( isset( $value['quantity'] ) ) {
317
-					$item->set_quantity( $value['quantity'] );
316
+				if (isset($value['quantity'])) {
317
+					$item->set_quantity($value['quantity']);
318 318
 				}
319 319
 
320
-				if ( isset( $value['allow_quantities'] ) ) {
321
-					$item->set_allow_quantities( $value['allow_quantities'] );
320
+				if (isset($value['allow_quantities'])) {
321
+					$item->set_allow_quantities($value['allow_quantities']);
322 322
 				}
323 323
 
324
-				if ( isset( $value['required'] ) ) {
325
-					$item->set_is_required( $value['required'] );
324
+				if (isset($value['required'])) {
325
+					$item->set_is_required($value['required']);
326 326
 				}
327 327
 
328
-				if ( isset( $value['description'] ) ) {
329
-					$item->set_custom_description( $value['description'] );
328
+				if (isset($value['description'])) {
329
+					$item->set_custom_description($value['description']);
330 330
 				}
331 331
 
332 332
 				$prepared[] = $item;
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 			}
336 336
 
337 337
 			// $item_id => array( 'price' => 10 ) (item variations)
338
-			if ( is_numeric( $key ) && is_array( $value ) ) {
339
-				$item = new GetPaid_Form_Item( $key );
338
+			if (is_numeric($key) && is_array($value)) {
339
+				$item = new GetPaid_Form_Item($key);
340 340
 
341
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
342
-					$item->set_price( $value['price'] );
341
+				if (isset($value['price']) && $item->user_can_set_their_price()) {
342
+					$item->set_price($value['price']);
343 343
 				}
344 344
 
345
-				if ( $item->can_purchase() ) {
345
+				if ($item->can_purchase()) {
346 346
 					$prepared[] = $item;
347 347
 				}
348 348
 
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 
352 352
 		}
353 353
 
354
-		if ( 'objects' == $return && 'view' == $context ) {
354
+		if ('objects' == $return && 'view' == $context) {
355 355
 			return $prepared;
356 356
 		}
357 357
 
358 358
 		$items = array();
359
-		foreach ( $prepared as $item ) {
359
+		foreach ($prepared as $item) {
360 360
 			$items[] = $item->prepare_data_for_use();
361 361
 		}
362 362
 
@@ -370,14 +370,14 @@  discard block
 block discarded – undo
370 370
 	 * @param  int $item_id The item id to return.
371 371
 	 * @return GetPaid_Form_Item|bool
372 372
 	 */
373
-	public function get_item( $item_id ) {
373
+	public function get_item($item_id) {
374 374
 
375
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
375
+		if (empty($item_id) || !is_numeric($item_id)) {
376 376
 			return false;
377 377
 		}
378 378
 
379
-		foreach( $this->get_items() as $item ) {
380
-			if ( $item->get_id() == (int) $item_id ) {
379
+		foreach ($this->get_items() as $item) {
380
+			if ($item->get_id() == (int) $item_id) {
381 381
 				return $item;
382 382
 			}
383 383
 		}
@@ -393,15 +393,15 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $element_type The element type to return.
394 394
 	 * @return array|bool
395 395
 	 */
396
-	public function get_element_type( $element_type ) {
396
+	public function get_element_type($element_type) {
397 397
 
398
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
398
+		if (empty($element_type) || !is_scalar($element_type)) {
399 399
 			return false;
400 400
 		}
401 401
 
402
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
402
+		foreach ($this->get_prop('elements') as $element) {
403 403
 
404
-			if ( $element['type'] == $element_type ) {
404
+			if ($element['type'] == $element_type) {
405 405
 				return $element;
406 406
 			}
407 407
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param  string $context View or edit context.
419 419
 	 * @return array
420 420
 	 */
421
-	public function get_earned( $context = 'view' ) {
422
-		return $this->get_prop( 'earned', $context );
421
+	public function get_earned($context = 'view') {
422
+		return $this->get_prop('earned', $context);
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param  string $context View or edit context.
430 430
 	 * @return array
431 431
 	 */
432
-	public function get_refunded( $context = 'view' ) {
433
-		return $this->get_prop( 'refunded', $context );
432
+	public function get_refunded($context = 'view') {
433
+		return $this->get_prop('refunded', $context);
434 434
 	}
435 435
 
436 436
 	/**
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 	 * @param  string $context View or edit context.
441 441
 	 * @return array
442 442
 	 */
443
-	public function get_cancelled( $context = 'view' ) {
444
-		return $this->get_prop( 'cancelled', $context );
443
+	public function get_cancelled($context = 'view') {
444
+		return $this->get_prop('cancelled', $context);
445 445
 	}
446 446
 
447 447
 	/**
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 	 * @param  string $context View or edit context.
452 452
 	 * @return array
453 453
 	 */
454
-	public function get_failed( $context = 'view' ) {
455
-		return $this->get_prop( 'failed', $context );
454
+	public function get_failed($context = 'view') {
455
+		return $this->get_prop('failed', $context);
456 456
 	}
457 457
 
458 458
 	/**
@@ -463,8 +463,8 @@  discard block
 block discarded – undo
463 463
 	 * @return string
464 464
 	 */
465 465
 	public function get_currency() {
466
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
467
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
466
+		$currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency();
467
+		return apply_filters('getpaid-payment-form-currency', $currency, $this);
468 468
 	}
469 469
 
470 470
     /*
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @since 1.0.19
484 484
 	 */
485
-	public function set_version( $value ) {
486
-		$this->set_prop( 'version', $value );
485
+	public function set_version($value) {
486
+		$this->set_prop('version', $value);
487 487
     }
488 488
 
489 489
     /**
@@ -493,11 +493,11 @@  discard block
 block discarded – undo
493 493
 	 * @param string $value Value to set.
494 494
      * @return bool Whether or not the date was set.
495 495
 	 */
496
-	public function set_date_created( $value ) {
497
-        $date = strtotime( $value );
496
+	public function set_date_created($value) {
497
+        $date = strtotime($value);
498 498
 
499
-        if ( $date ) {
500
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
499
+        if ($date) {
500
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
501 501
             return true;
502 502
         }
503 503
 
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	 * @param string $value Value to set.
513 513
      * @return bool Whether or not the date was set.
514 514
 	 */
515
-	public function set_date_modified( $value ) {
516
-        $date = strtotime( $value );
515
+	public function set_date_modified($value) {
516
+        $date = strtotime($value);
517 517
 
518
-        if ( $date ) {
519
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
518
+        if ($date) {
519
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
520 520
             return true;
521 521
         }
522 522
 
@@ -530,8 +530,8 @@  discard block
 block discarded – undo
530 530
 	 * @since 1.0.19
531 531
 	 * @param  string $value New name.
532 532
 	 */
533
-	public function set_name( $value ) {
534
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
533
+	public function set_name($value) {
534
+		$this->set_prop('name', sanitize_text_field($value));
535 535
     }
536 536
 
537 537
     /**
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 * @since 1.0.19
541 541
 	 * @param  string $value New name.
542 542
 	 */
543
-	public function set_title( $value ) {
544
-		$this->set_name( $value );
543
+	public function set_title($value) {
544
+		$this->set_name($value);
545 545
     }
546 546
 
547 547
     /**
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @since 1.0.19
551 551
 	 * @param  int $value New author.
552 552
 	 */
553
-	public function set_author( $value ) {
554
-		$this->set_prop( 'author', (int) $value );
553
+	public function set_author($value) {
554
+		$this->set_prop('author', (int) $value);
555 555
 	}
556 556
 
557 557
 	/**
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
 	 * @since 1.0.19
561 561
 	 * @param  array $value Form elements.
562 562
 	 */
563
-	public function set_elements( $value ) {
564
-		if ( is_array( $value ) ) {
565
-			$this->set_prop( 'elements', $value );
563
+	public function set_elements($value) {
564
+		if (is_array($value)) {
565
+			$this->set_prop('elements', $value);
566 566
 		}
567 567
 	}
568 568
 
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 	 * @since 1.0.19
573 573
 	 * @param  array $value Form elements.
574 574
 	 */
575
-	public function set_items( $value ) {
576
-		if ( is_array( $value ) ) {
577
-			$this->set_prop( 'items', $value );
575
+	public function set_items($value) {
576
+		if (is_array($value)) {
577
+			$this->set_prop('items', $value);
578 578
 		}
579 579
 	}
580 580
 
@@ -584,9 +584,9 @@  discard block
 block discarded – undo
584 584
 	 * @since 1.0.19
585 585
 	 * @param  float $value Amount earned.
586 586
 	 */
587
-	public function set_earned( $value ) {
588
-		$value = max( (float) $value, 0 );
589
-		$this->set_prop( 'earned', $value );
587
+	public function set_earned($value) {
588
+		$value = max((float) $value, 0);
589
+		$this->set_prop('earned', $value);
590 590
 	}
591 591
 
592 592
 	/**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	 * @since 1.0.19
596 596
 	 * @param  float $value Amount refunded.
597 597
 	 */
598
-	public function set_refunded( $value ) {
599
-		$value = max( (float) $value, 0 );
600
-		$this->set_prop( 'refunded', $value );
598
+	public function set_refunded($value) {
599
+		$value = max((float) $value, 0);
600
+		$this->set_prop('refunded', $value);
601 601
 	}
602 602
 
603 603
 	/**
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
 	 * @since 1.0.19
607 607
 	 * @param  float $value Amount cancelled.
608 608
 	 */
609
-	public function set_cancelled( $value ) {
610
-		$value = max( (float) $value, 0 );
611
-		$this->set_prop( 'cancelled', $value );
609
+	public function set_cancelled($value) {
610
+		$value = max((float) $value, 0);
611
+		$this->set_prop('cancelled', $value);
612 612
 	}
613 613
 
614 614
 	/**
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 	 * @since 1.0.19
618 618
 	 * @param  float $value Amount cancelled.
619 619
 	 */
620
-	public function set_failed( $value ) {
621
-		$value = max( (float) $value, 0 );
622
-		$this->set_prop( 'failed', $value );
620
+	public function set_failed($value) {
621
+		$value = max((float) $value, 0);
622
+		$this->set_prop('failed', $value);
623 623
 	}
624 624
 
625 625
     /**
@@ -628,11 +628,11 @@  discard block
 block discarded – undo
628 628
      * @deprecated
629 629
 	 * @return int item id
630 630
      */
631
-    public function create( $data = array() ) {
631
+    public function create($data = array()) {
632 632
 
633 633
 		// Set the properties.
634
-		if ( is_array( $data ) ) {
635
-			$this->set_props( $data );
634
+		if (is_array($data)) {
635
+			$this->set_props($data);
636 636
 		}
637 637
 
638 638
 		// Save the item.
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
      * @deprecated
647 647
 	 * @return int item id
648 648
      */
649
-    public function update( $data = array() ) {
650
-        return $this->create( $data );
649
+    public function update($data = array()) {
650
+        return $this->create($data);
651 651
     }
652 652
 
653 653
     /*
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 */
668 668
     public function is_default() {
669 669
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
670
-        return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
670
+        return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this);
671 671
 	}
672 672
 
673 673
     /**
@@ -679,11 +679,11 @@  discard block
 block discarded – undo
679 679
     public function is_active() {
680 680
         $is_active = 0 !== (int) $this->get_id();
681 681
 
682
-        if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) {
682
+        if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') {
683 683
             $is_active = false;
684 684
         }
685 685
 
686
-        return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
686
+        return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this);
687 687
 	}
688 688
 
689 689
 	/**
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 	 * @since 1.0.19
693 693
 	 * @return bool
694 694
 	 */
695
-    public function has_item( $item_id ) {
696
-        return false !== $this->get_item( $item_id );
695
+    public function has_item($item_id) {
696
+        return false !== $this->get_item($item_id);
697 697
 	}
698 698
 
699 699
 	/**
@@ -702,8 +702,8 @@  discard block
 block discarded – undo
702 702
 	 * @since 1.0.19
703 703
 	 * @return bool
704 704
 	 */
705
-    public function has_element_type( $element_type ) {
706
-        return false !== $this->get_element_type( $element_type );
705
+    public function has_element_type($element_type) {
706
+        return false !== $this->get_element_type($element_type);
707 707
 	}
708 708
 
709 709
 	/**
@@ -714,13 +714,13 @@  discard block
 block discarded – undo
714 714
 	 */
715 715
     public function is_recurring() {
716 716
 
717
-		if ( ! empty( $this->invoice ) ) {
717
+		if (!empty($this->invoice)) {
718 718
 			return $this->invoice->is_recurring();
719 719
 		}
720 720
 
721
-		foreach ( $this->get_items() as $item ) {
721
+		foreach ($this->get_items() as $item) {
722 722
 
723
-			if ( $item->is_recurring() ) {
723
+			if ($item->is_recurring()) {
724 724
 				return true;
725 725
 			}
726 726
 
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	 *
735 735
 	 * @since 1.0.19
736 736
 	 */
737
-    public function get_html( $extra_markup = '' ) {
737
+    public function get_html($extra_markup = '') {
738 738
 
739 739
 		// Return the HTML.
740 740
 		return wpinv_get_template_html(
@@ -752,8 +752,8 @@  discard block
 block discarded – undo
752 752
 	 *
753 753
 	 * @since 1.0.19
754 754
 	 */
755
-    public function display( $extra_markup = '' ) {
756
-		echo $this->get_html( $extra_markup );
755
+    public function display($extra_markup = '') {
756
+		echo $this->get_html($extra_markup);
757 757
     }
758 758
 
759 759
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-info.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,20 +21,20 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?>
32
+            <?php do_action('wpinv_item_before_info_metabox', $item); ?>
33 33
 
34 34
             <div class="wpinv_item_type form-group row">
35 35
                 <label for="wpinv_item_type" class="col-sm-12 col-form-label">
36
-                    <?php _e( 'Item Type', 'invoicing' );?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags( self::get_tooltip( $post ) ); ?>"></span>
36
+                    <?php _e('Item Type', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags(self::get_tooltip($post)); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
                             array(
45 45
                                 'id'               => 'wpinv_item_type',
46 46
                                 'name'             => 'wpinv_item_type',
47
-                                'placeholder'      => __( 'Select item type', 'invoicing' ),
48
-                                'value'            => $item->get_type( 'edit' ),
47
+                                'placeholder'      => __('Select item type', 'invoicing'),
48
+                                'value'            => $item->get_type('edit'),
49 49
                                 'select2'          => true,
50 50
                                 'data-allow-clear' => 'false',
51 51
                                 'no_wrap'          => true,
@@ -59,38 +59,38 @@  discard block
 block discarded – undo
59 59
 
60 60
             <div class="wpinv_item_shortcode form-group row">
61 61
                 <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label">
62
-                    <?php _e( 'Payment Form Shortcode', 'invoicing' );?>
63
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
62
+                    <?php _e('Payment Form Shortcode', 'invoicing'); ?>
63
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
64 64
                 </label>
65 65
 
66 66
                 <div class="col-sm-12">
67
-                    <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/>
67
+                    <input  onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/>
68 68
                 </div>
69 69
             </div>
70 70
 
71 71
             <div class="wpinv_item_buy_shortcode form-group row">
72 72
                 <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label">
73
-                    <?php _e( 'Payment Button Shortcode', 'invoicing' );?>
74
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
73
+                    <?php _e('Payment Button Shortcode', 'invoicing'); ?>
74
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
75 75
                 </label>
76 76
 
77 77
                 <div class="col-sm-12">
78
-                    <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/>
78
+                    <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/>
79 79
                 </div>
80 80
             </div>
81 81
 
82 82
             <div class="wpinv_item_custom_id form-group">
83
-                <?php _e( 'Custom ID', 'invoicing' );?> &mdash; <?php echo sanitize_text_field( $item->get_custom_id() ) ?>
83
+                <?php _e('Custom ID', 'invoicing'); ?> &mdash; <?php echo sanitize_text_field($item->get_custom_id()) ?>
84 84
             </div>
85 85
 
86
-            <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?>
87
-            <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?>
86
+            <?php do_action('wpinv_meta_values_metabox_before', $post); ?>
87
+            <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?>
88 88
                 <div class="wpinv_item_custom_id form-group">
89
-                    <?php sanitize_text_field( $meta_key );?> &mdash; <?php echo sanitize_text_field( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?>
89
+                    <?php sanitize_text_field($meta_key); ?> &mdash; <?php echo sanitize_text_field(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?>
90 90
                 </div>
91 91
             <?php endforeach; ?>
92
-            <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?>
93
-            <?php do_action( 'wpinv_item_info_metabox', $item ); ?>
92
+            <?php do_action('wpinv_meta_values_metabox_after', $post); ?>
93
+            <?php do_action('wpinv_item_info_metabox', $item); ?>
94 94
         </div>
95 95
         <?php
96 96
 
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 	 * Returns item type tolltip.
101 101
 	 *
102 102
 	 */
103
-    public static function get_tooltip( $post ) {
103
+    public static function get_tooltip($post) {
104 104
 
105 105
         ob_start();
106 106
         ?>
107 107
 
108
-        <?php _e( 'Standard: Standard item type', 'invoicing' );?>
109
-        <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' );?>
108
+        <?php _e('Standard: Standard item type', 'invoicing'); ?>
109
+        <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?>
110 110
 
111 111
         <?php
112
-        do_action( 'wpinv_item_info_metabox_after', $post );
112
+        do_action('wpinv_item_info_metabox_after', $post);
113 113
 
114 114
         return ob_get_clean();
115 115
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission itemss class
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
30 30
 
31 31
 		// Prepare the selected items.
32 32
 		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
33
+		if (!empty($data['getpaid-items'])) {
34
+			$selected_items = wpinv_clean($data['getpaid-items']);
35 35
 		}
36 36
 
37 37
 		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
38
+		if ($payment_form->is_default() && !$submission->has_invoice() && isset($data['getpaid-form-items'])) {
39
+			$form_items = wpinv_clean($data['getpaid-form-items']);
40
+			$payment_form->set_items(getpaid_convert_items_to_array($form_items));
41 41
 		}
42 42
 
43 43
 		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items );
44
+		foreach ($payment_form->get_items() as $item) {
45
+			$this->process_item($item, $selected_items);
46 46
 		}
47 47
 
48 48
 	}
@@ -53,30 +53,30 @@  discard block
 block discarded – undo
53 53
 	 * @param GetPaid_Form_Item $item
54 54
 	 * @param array $selected_items
55 55
 	 */
56
-	public function process_item( $item, $selected_items ) {
56
+	public function process_item($item, $selected_items) {
57 57
 
58 58
 		// Abort if this is an optional item and it has not been selected.
59
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
59
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
60 60
 			return;
61 61
 		}
62 62
 
63 63
 		// (maybe) let customers change the quantities and prices.
64
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
64
+		if (isset($selected_items[$item->get_id()])) {
65 65
 
66 66
 			// Maybe change the quantities.
67
-			if ( $item->allows_quantities() ) {
68
-				$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
67
+			if ($item->allows_quantities()) {
68
+				$item->set_quantity((int) $selected_items[$item->get_id()]['quantity']);
69 69
 			}
70 70
 
71 71
 			// Maybe change the price.
72
-			if ( $item->user_can_set_their_price() ) {
73
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
72
+			if ($item->user_can_set_their_price()) {
73
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
74 74
 
75
-				if ( $item->get_minimum_price() > $price ) {
76
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) );
75
+				if ($item->get_minimum_price() > $price) {
76
+					throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_sanitize_amount($item->get_minimum_price())));
77 77
 				}
78 78
 
79
-				$item->set_price( $price );
79
+				$item->set_price($price);
80 80
 
81 81
 			}
82 82
 
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,80 +7,80 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
12
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
13 13
 
14 14
 $currency = $form->get_currency();
15 15
 
16 16
 ?>
17
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'>
17
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'>
18 18
     <div class="form-row">
19
-        <?php foreach ( $columns as $key => $label ) : ?>
20
-            <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo $item->get_id(); ?>">
19
+        <?php foreach ($columns as $key => $label) : ?>
20
+            <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo $item->get_id(); ?>">
21 21
                 <?php
22 22
 
23 23
                     // Item name.
24
-                    if ( 'name' == $key ) {
25
-                        echo sanitize_text_field( $item->get_name() );
24
+                    if ('name' == $key) {
25
+                        echo sanitize_text_field($item->get_name());
26 26
                         $description = $item->get_description();
27 27
 
28
-                        if ( ! empty( $description ) ) {
29
-                            $description = wp_kses_post( $description );
28
+                        if (!empty($description)) {
29
+                            $description = wp_kses_post($description);
30 30
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
31 31
                         }
32 32
 
33
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
33
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
34 34
 
35
-                        if ( $description ) {
35
+                        if ($description) {
36 36
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
37 37
                         }
38 38
                     }
39 39
 
40 40
                     // Item price.
41
-                    if ( 'price' == $key ) {
41
+                    if ('price' == $key) {
42 42
 
43 43
                         // Set the currency position.
44 44
                         $position = wpinv_currency_position();
45 45
 
46
-                        if ( $position == 'left_space' ) {
46
+                        if ($position == 'left_space') {
47 47
                             $position = 'left';
48 48
                         }
49 49
 
50
-                        if ( $position == 'right_space' ) {
50
+                        if ($position == 'right_space') {
51 51
                             $position = 'right';
52 52
                         }
53 53
 
54
-                        if ( $item->user_can_set_their_price() ) {
55
-                            $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
54
+                        if ($item->user_can_set_their_price()) {
55
+                            $price = max((float) $item->get_price(), (float) $item->get_minimum_price());
56 56
                             ?>
57 57
                                 <div class="input-group input-group-sm">
58
-                                    <?php if( 'left' == $position ) : ?>
58
+                                    <?php if ('left' == $position) : ?>
59 59
                                         <div class="input-group-prepend">
60
-                                            <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
60
+                                            <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
61 61
                                         </div>
62 62
                                     <?php endif; ?>
63
-                                    <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input">
63
+                                    <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input">
64 64
 
65
-                                    <?php if( 'left' != $position ) : ?>
65
+                                    <?php if ('left' != $position) : ?>
66 66
                                         <div class="input-group-append">
67
-                                            <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
67
+                                            <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
68 68
                                         </div>
69 69
                                     <?php endif; ?>
70 70
                                 </div>
71 71
                             <?php
72 72
                         } else {
73
-                            echo wpinv_price( wpinv_format_amount( $item->get_price() ), $currency );
73
+                            echo wpinv_price(wpinv_format_amount($item->get_price()), $currency);
74 74
                             ?>
75
-                                <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
75
+                                <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
76 76
                             <?php
77 77
                         }
78 78
                     }
79 79
 
80 80
                     // Item quantity.
81
-                    if ( 'quantity' == $key ) {
81
+                    if ('quantity' == $key) {
82 82
 
83
-                        if ( $item->allows_quantities() ) {
83
+                        if ($item->allows_quantities()) {
84 84
                             ?>
85 85
                                 <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='number' class='getpaid-item-quantity-input pr-1' value='<?php echo (int) $item->get_qantity(); ?>' min='1' required>
86 86
                             <?php
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
                     }
95 95
 
96 96
                     // Item sub total.
97
-                    if ( 'subtotal' == $key ) {
98
-                        echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $currency );
97
+                    if ('subtotal' == $key) {
98
+                        echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $currency);
99 99
                     }
100 100
 
101
-                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
101
+                    do_action("getpaid_payment_form_cart_item_$key", $item, $form);
102 102
                 ?>
103 103
             </div>
104 104
         <?php endforeach; ?>
105 105
     </div>
106 106
 </div>
107 107
 <?php
108
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
108
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
includes/admin/class-wpinv-items-report-table.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function __construct() {
38 38
 
39 39
 		// Set parent defaults
40
-		parent::__construct( array(
40
+		parent::__construct(array(
41 41
 			'singular' => 'id',
42 42
 			'plural'   => 'ids',
43 43
 			'ajax'     => false,
44
-		) );
44
+		));
45 45
 
46 46
 	}
47 47
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string Column Name
69 69
 	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
70
+	public function column_default($item, $column_name) {
71
+		return wp_kses_post($item[$column_name]);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	public function get_columns() {
81 81
 
82 82
 		return array(
83
-			'item'     => __( 'Item', 'invoicing' ),
84
-			'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
83
+			'item'     => __('Item', 'invoicing'),
84
+			'sales'    => __('Quantity Sold', 'invoicing'),
85
+			'total'    => __('Total Earnings', 'invoicing'),
86
+			'discount' => __('Total Discounts', 'invoicing'),
87
+			'tax'      => __('Total Taxes', 'invoicing'),
88 88
 		);
89 89
 
90 90
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return int Current page number
97 97
 	 */
98 98
 	public function get_paged() {
99
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
99
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @since 1.0.19
106 106
 	 * @return void
107 107
 	 */
108
-	public function bulk_actions( $which = '' ) {
108
+	public function bulk_actions($which = '') {
109 109
 		return array();
110 110
 	}
111 111
 
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 		$reports_data = $this->revenue_reports_data();
121 121
 
122 122
 		$prepared = array();
123
-		foreach ( $reports_data as $report_data ) {
123
+		foreach ($reports_data as $report_data) {
124 124
 			$prepared[] = array(
125 125
 				'item'     => $report_data['item_name'],
126 126
 				'sales'    => $report_data['sales'],
127
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
127
+				'total'    => wpinv_price(wpinv_format_amount($report_data['total'])),
128
+				'discount' => wpinv_price(wpinv_format_amount($report_data['discount'])),
129
+				'tax'      => wpinv_price(wpinv_format_amount($report_data['tax'])),
130 130
 			);
131 131
 		}
132 132
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function revenue_reports_data() {
142 142
 		global $wpdb;
143 143
 
144
-		$table =  $wpdb->prefix . 'getpaid_invoice_items';
144
+		$table = $wpdb->prefix . 'getpaid_invoice_items';
145 145
 		return $wpdb->get_results(
146 146
 			"SELECT
147 147
 				SUM(quantity) as sales,
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		$columns               = $this->get_columns();
170 170
 		$hidden                = array(); // No hidden columns
171 171
 		$sortable              = $this->get_sortable_columns();
172
-		$this->_column_headers = array( $columns, $hidden, $sortable );
172
+		$this->_column_headers = array($columns, $hidden, $sortable);
173 173
 		$this->items           = $this->reports_data();
174 174
 	}
175 175
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-gateways-report-table.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function __construct() {
38 38
 
39 39
 		// Set parent defaults
40
-		parent::__construct( array(
40
+		parent::__construct(array(
41 41
 			'singular' => 'id',
42 42
 			'plural'   => 'ids',
43 43
 			'ajax'     => false,
44
-		) );
44
+		));
45 45
 
46 46
 	}
47 47
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string Column Name
69 69
 	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
70
+	public function column_default($item, $column_name) {
71
+		return wp_kses_post($item[$column_name]);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,12 +80,12 @@  discard block
 block discarded – undo
80 80
 	public function get_columns() {
81 81
 
82 82
 		return array(
83
-			'gateway'  => __( 'Gateway', 'invoicing' ),
84
-			'sales'    => __( 'Total Sales', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-			'fees'     => __( 'Total Fees', 'invoicing' ),
83
+			'gateway'  => __('Gateway', 'invoicing'),
84
+			'sales'    => __('Total Sales', 'invoicing'),
85
+			'total'    => __('Total Earnings', 'invoicing'),
86
+			'discount' => __('Total Discounts', 'invoicing'),
87
+			'tax'      => __('Total Taxes', 'invoicing'),
88
+			'fees'     => __('Total Fees', 'invoicing'),
89 89
 		);
90 90
 
91 91
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return int Current page number
98 98
 	 */
99 99
 	public function get_paged() {
100
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
101 101
 	}
102 102
 
103 103
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @since 1.0.19
107 107
 	 * @return void
108 108
 	 */
109
-	public function bulk_actions( $which = '' ) {
109
+	public function bulk_actions($which = '') {
110 110
 		return array();
111 111
 	}
112 112
 
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 		$reports_data = $this->revenue_reports_data();
122 122
 		$gateways     = wpinv_get_payment_gateways();
123 123
 
124
-		foreach ( $gateways as $gateway_id => $gateway ) {
124
+		foreach ($gateways as $gateway_id => $gateway) {
125 125
 
126
-			if ( ! empty( $reports_data[ $gateway_id ] ) ) {
126
+			if (!empty($reports_data[$gateway_id])) {
127 127
 				continue;
128 128
 			}
129 129
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 		}
139 139
 
140 140
 		$prepared = array();
141
-		foreach ( $reports_data as $report_data ) {
141
+		foreach ($reports_data as $report_data) {
142 142
 			$prepared[] = array(
143
-				'gateway'  => wpinv_get_gateway_admin_label( $report_data['gateway'] ),
143
+				'gateway'  => wpinv_get_gateway_admin_label($report_data['gateway']),
144 144
 				'sales'    => $report_data['sales'],
145
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
146
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
147
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
148
-				'fees'     => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ),
145
+				'total'    => wpinv_price(wpinv_format_amount($report_data['total'])),
146
+				'discount' => wpinv_price(wpinv_format_amount($report_data['discount'])),
147
+				'tax'      => wpinv_price(wpinv_format_amount($report_data['tax'])),
148
+				'fees'     => wpinv_price(wpinv_format_amount($report_data['fees'])),
149 149
 			);
150 150
 		}
151 151
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	public function revenue_reports_data() {
161 161
 		global $wpdb;
162 162
 
163
-		$table =  $wpdb->prefix . 'getpaid_invoices';
163
+		$table = $wpdb->prefix . 'getpaid_invoices';
164 164
 		$data  = $wpdb->get_results(
165 165
 			"SELECT
166 166
 				COUNT(posts.ID) as sales,
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 		
180 180
 		$return = array();
181 181
 
182
-		foreach ( $data as $gateway ) {
183
-			$return[ $gateway ['gateway']] = $gateway;
182
+		foreach ($data as $gateway) {
183
+			$return[$gateway ['gateway']] = $gateway;
184 184
 		}
185 185
 
186 186
 		return $return;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$columns               = $this->get_columns();
198 198
 		$hidden                = array(); // No hidden columns
199 199
 		$sortable              = $this->get_sortable_columns();
200
-		$this->_column_headers = array( $columns, $hidden, $sortable );
200
+		$this->_column_headers = array($columns, $hidden, $sortable);
201 201
 		$this->items           = $this->reports_data();
202 202
 	}
203 203
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-taxes-report-table.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function __construct() {
38 38
 
39 39
 		// Set parent defaults
40
-		parent::__construct( array(
40
+		parent::__construct(array(
41 41
 			'singular' => 'id',
42 42
 			'plural'   => 'ids',
43 43
 			'ajax'     => false,
44
-		) );
44
+		));
45 45
 
46 46
 	}
47 47
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string Column Name
69 69
 	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
70
+	public function column_default($item, $column_name) {
71
+		return wp_kses_post($item[$column_name]);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	public function get_columns() {
81 81
 
82 82
 		return array(
83
-			'month'    => __( 'Month', 'invoicing' ),
84
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
83
+			'month'    => __('Month', 'invoicing'),
84
+			'tax'      => __('Total Taxes', 'invoicing'),
85 85
 		);
86 86
 
87 87
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return int Current page number
94 94
 	 */
95 95
 	public function get_paged() {
96
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
96
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
97 97
 	}
98 98
 
99 99
 	/**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @since 1.0.19
103 103
 	 * @return void
104 104
 	 */
105
-	public function bulk_actions( $which = '' ) {
105
+	public function bulk_actions($which = '') {
106 106
 		return array();
107 107
 	}
108 108
 
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
 
117 117
 		$reports_data = $this->taxes_reports_data();
118 118
 		$months       = array(
119
-			'1' => __( 'January', 'invoicing' ),
120
-			'2' => __( 'February', 'invoicing' ),
121
-			'3' => __( 'March', 'invoicing' ),
122
-			'4' => __( 'April', 'invoicing' ),
123
-			'5' => __( 'May', 'invoicing' ),
124
-			'6' => __( 'June', 'invoicing' ),
125
-			'7' => __( 'July', 'invoicing' ),
126
-			'8' => __( 'August', 'invoicing' ),
127
-			'9' => __( 'September', 'invoicing' ),
128
-			'10' => __( 'October', 'invoicing' ),
129
-			'11' => __( 'November', 'invoicing' ),
130
-			'12' => __( 'December', 'invoicing' ),
119
+			'1' => __('January', 'invoicing'),
120
+			'2' => __('February', 'invoicing'),
121
+			'3' => __('March', 'invoicing'),
122
+			'4' => __('April', 'invoicing'),
123
+			'5' => __('May', 'invoicing'),
124
+			'6' => __('June', 'invoicing'),
125
+			'7' => __('July', 'invoicing'),
126
+			'8' => __('August', 'invoicing'),
127
+			'9' => __('September', 'invoicing'),
128
+			'10' => __('October', 'invoicing'),
129
+			'11' => __('November', 'invoicing'),
130
+			'12' => __('December', 'invoicing'),
131 131
 		);
132 132
 
133 133
 		$prepared = array();
134
-		foreach ( $months as $month => $label ) {
134
+		foreach ($months as $month => $label) {
135 135
 
136
-			$tax = wpinv_price( 0 );
137
-			if ( ! empty( $reports_data[ $month ] ) ) {
138
-				$tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
136
+			$tax = wpinv_price(0);
137
+			if (!empty($reports_data[$month])) {
138
+				$tax = wpinv_price(wpinv_format_amount($reports_data[$month]));
139 139
 			}
140 140
 
141 141
 			$prepared[] = array(
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	public function taxes_reports_data() {
157 157
 		global $wpdb;
158 158
 
159
-		$table =  $wpdb->prefix . 'getpaid_invoices';
160
-		$year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
159
+		$table = $wpdb->prefix . 'getpaid_invoices';
160
+		$year  = isset($_GET['year']) ? absint($_GET['year']) : date('Y');
161 161
 		$data  = $wpdb->get_results(
162 162
 			"SELECT
163 163
 				MONTH(meta.completed_date) as _month,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				AND ( YEAR(meta.completed_date) = '$year' )
172 172
 			GROUP BY MONTH(meta.completed_date)");
173 173
 
174
-		return wp_list_pluck( $data, 'tax', '_month' );
174
+		return wp_list_pluck($data, 'tax', '_month');
175 175
 
176 176
 	}
177 177
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$columns               = $this->get_columns();
186 186
 		$hidden                = array(); // No hidden columns
187 187
 		$sortable              = $this->get_sortable_columns();
188
-		$this->_column_headers = array( $columns, $hidden, $sortable );
188
+		$this->_column_headers = array($columns, $hidden, $sortable);
189 189
 		$this->items           = $this->reports_data();
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.