Passed
Push — master ( 18ec29...d57dff )
by Brian
05:19
created
templates/emails/wpinv-email-footer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-$email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) );
7
-$email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
6
+$email_footer = apply_filters('wpinv_email_footer_text', wpinv_get_option('email_footer_text'));
7
+$email_footer = $email_footer ? wpautop(wp_kses_post(wptexturize($email_footer))) : '';
8 8
 ?>
9 9
                                                             </div>
10 10
                                                         </td>
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 $email_footer = apply_filters( 'wpinv_email_footer_text', wpinv_get_option( 'email_footer_text' ) );
7 8
 $email_footer = $email_footer ? wpautop( wp_kses_post( wptexturize( $email_footer ) ) ) : '';
Please login to merge, or discard this patch.
templates/emails/wpinv-email-header.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-if ( !isset( $email_heading ) ) {
6
+if (!isset($email_heading)) {
7 7
     global $email_heading;
8 8
 }
9 9
 ?>
10 10
 <!DOCTYPE html>
11 11
 <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>">
12 12
     <head>
13
-        <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
13
+        <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
14 14
         <meta name="viewport" content="width=device-width, initial-scale=1">
15 15
         <meta name="robots" content="noindex,nofollow">
16 16
         <title><?php echo wpinv_get_blogname(); ?></title>
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
                     <td align="center" valign="top">
23 23
                         <div id="template_header_image">
24 24
                         <?php
25
-                            if ( $img = wpinv_get_option( 'email_header_image' ) ) {
26
-                                echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>';
25
+                            if ($img = wpinv_get_option('email_header_image')) {
26
+                                echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>';
27 27
                             }
28 28
                         ?>
29 29
                         </div>
30 30
                         <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container">
31
-                            <?php if ( !empty( $email_heading ) ) { ?>
31
+                            <?php if (!empty($email_heading)) { ?>
32 32
                             <tr>
33 33
                                 <td align="center" valign="top">
34 34
                                     <!-- Header -->
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 if ( !isset( $email_heading ) ) {
7 8
     global $email_heading;
Please login to merge, or discard this patch.
templates/emails/wpinv-email-styles.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 // Load colours
7 8
 $bg              = wpinv_get_option( 'email_background_color', '#f5f5f5' );
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,25 +1,25 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6 6
 // Load colours
7
-$bg              = wpinv_get_option( 'email_background_color', '#f5f5f5' );
8
-$body            = wpinv_get_option( 'email_body_background_color', '#fdfdfd' );
9
-$base            = wpinv_get_option( 'email_base_color', '#557da2' );
10
-$base_text       = wpinv_light_or_dark( $base, '#202020', '#ffffff' );
11
-$text            = wpinv_get_option( 'email_text_color', '#505050' );
7
+$bg              = wpinv_get_option('email_background_color', '#f5f5f5');
8
+$body            = wpinv_get_option('email_body_background_color', '#fdfdfd');
9
+$base            = wpinv_get_option('email_base_color', '#557da2');
10
+$base_text       = wpinv_light_or_dark($base, '#202020', '#ffffff');
11
+$text            = wpinv_get_option('email_text_color', '#505050');
12 12
 
13
-$bg_darker_10    = wpinv_hex_darker( $bg, 10 );
14
-$body_darker_10  = wpinv_hex_darker( $body, 10 );
15
-$base_lighter_20 = wpinv_hex_lighter( $base, 20 );
16
-$base_lighter_40 = wpinv_hex_lighter( $base, 40 );
17
-$text_lighter_20 = wpinv_hex_lighter( $text, 20 );
13
+$bg_darker_10    = wpinv_hex_darker($bg, 10);
14
+$body_darker_10  = wpinv_hex_darker($body, 10);
15
+$base_lighter_20 = wpinv_hex_lighter($base, 20);
16
+$base_lighter_40 = wpinv_hex_lighter($base, 40);
17
+$text_lighter_20 = wpinv_hex_lighter($text, 20);
18 18
 
19 19
 // !important; is a gmail hack to prevent styles being stripped if it doesn't like something.
20 20
 ?>
21 21
 #wrapper {
22
-    background-color: <?php echo esc_attr( $bg ); ?>;
22
+    background-color: <?php echo esc_attr($bg); ?>;
23 23
     margin: 0;
24 24
     -webkit-text-size-adjust: none !important;
25 25
     padding: 3%;
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 
41 41
 #template_container {
42 42
     box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
43
-    background-color: <?php echo esc_attr( $body ); ?>;
44
-    border: 1px solid <?php echo esc_attr( $bg_darker_10 ); ?>;
43
+    background-color: <?php echo esc_attr($body); ?>;
44
+    border: 1px solid <?php echo esc_attr($bg_darker_10); ?>;
45 45
     border-radius: 3px !important;
46 46
 }
47 47
 
48 48
 #template_header {
49
-    background-color: <?php echo esc_attr( $base ); ?>;
49
+    background-color: <?php echo esc_attr($base); ?>;
50 50
     border-radius: 3px 3px 0 0 !important;
51
-    color: <?php echo esc_attr( $base_text ); ?>;
51
+    color: <?php echo esc_attr($base_text); ?>;
52 52
     border-bottom: 0;
53 53
     font-weight: bold;
54 54
     line-height: 100%;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 #template_header h1 {
64
-    color: <?php echo esc_attr( $base_text ); ?>;
64
+    color: <?php echo esc_attr($base_text); ?>;
65 65
 }
66 66
 
67 67
 #template_footer td {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 #template_footer #credit {
74 74
     border:0;
75
-    color: <?php echo esc_attr( $base_lighter_40 ); ?>;
75
+    color: <?php echo esc_attr($base_lighter_40); ?>;
76 76
     font-family: Arial;
77 77
     font-size:12px;
78 78
     line-height:125%;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 }
82 82
 
83 83
 #body_content {
84
-    background-color: <?php echo esc_attr( $body ); ?>;
84
+    background-color: <?php echo esc_attr($body); ?>;
85 85
 }
86 86
 
87 87
 #body_content table td {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 }
102 102
 
103 103
 #body_content_inner {
104
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
104
+    color: <?php echo esc_attr($text_lighter_20); ?>;
105 105
     font-family: Arial,Helvetica,sans-serif;
106 106
     font-size: 14px;
107 107
     line-height: 150%;
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 }
110 110
 
111 111
 .td {
112
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
113
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
112
+    color: <?php echo esc_attr($text_lighter_20); ?>;
113
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
114 114
 }
115 115
 
116 116
 .text {
117
-    color: <?php echo esc_attr( $text ); ?>;
117
+    color: <?php echo esc_attr($text); ?>;
118 118
     font-family: Arial,Helvetica,sans-serif;
119 119
 }
120 120
 
121 121
 .link {
122
-    color: <?php echo esc_attr( $base ); ?>;
122
+    color: <?php echo esc_attr($base); ?>;
123 123
 }
124 124
 
125 125
 #header_wrapper {
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 }
129 129
 
130 130
 h1 {
131
-    color: <?php echo esc_attr( $base ); ?>;
131
+    color: <?php echo esc_attr($base); ?>;
132 132
     font-family: Arial,Helvetica,sans-serif;
133 133
     font-size: 30px;
134 134
     font-weight: 300;
135 135
     line-height: 150%;
136 136
     margin: 0;
137 137
     text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
138
-    text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>;
138
+    text-shadow: 0 1px 0 <?php echo esc_attr($base_lighter_20); ?>;
139 139
     -webkit-font-smoothing: antialiased;
140 140
 }
141 141
 
142 142
 h2 {
143
-    color: <?php echo esc_attr( $base ); ?>;
143
+    color: <?php echo esc_attr($base); ?>;
144 144
     display: block;
145 145
     font-family: Arial,Helvetica,sans-serif;
146 146
     font-size: 18px;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 }
152 152
 
153 153
 h3 {
154
-    color: <?php echo esc_attr( $base ); ?>;
154
+    color: <?php echo esc_attr($base); ?>;
155 155
     display: block;
156 156
     font-family: Arial,Helvetica,sans-serif;
157 157
     font-size: 16px;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 }
163 163
 
164 164
 a {
165
-    color: <?php echo esc_attr( $base ); ?>;
165
+    color: <?php echo esc_attr($base); ?>;
166 166
     font-weight: normal;
167 167
     text-decoration: underline;
168 168
 }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 }
181 181
 
182 182
 .table-bordered {
183
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
183
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
184 184
     border-collapse: collapse;
185 185
     border-spacing: 0;
186 186
     width: 100%;
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 
189 189
 .table-bordered th,
190 190
 .table-bordered td {
191
-    border: 1px solid <?php echo esc_attr( $body_darker_10 ); ?>;
192
-    color: <?php echo esc_attr( $text_lighter_20 ); ?>;
191
+    border: 1px solid <?php echo esc_attr($body_darker_10); ?>;
192
+    color: <?php echo esc_attr($text_lighter_20); ?>;
193 193
     font-size: 14px;
194 194
 }
195 195
 .small {
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
   text-decoration: none;
289 289
 }
290 290
 .btn-default {
291
-    color: <?php echo esc_attr( $base_text ); ?>;
292
-    background-color: <?php echo esc_attr( $base ); ?>;
293
-    border-color: <?php echo esc_attr( $base ); ?>;
291
+    color: <?php echo esc_attr($base_text); ?>;
292
+    background-color: <?php echo esc_attr($base); ?>;
293
+    border-color: <?php echo esc_attr($base); ?>;
294 294
 }
295 295
 .btn-primary {
296 296
   color: #fff;
Please login to merge, or discard this patch.
templates/emails/wpinv-email-billing-details.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_before_billing_details', $invoice ); ?>
7 8
 <div id="wpinv-email-billing">
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,41 +1,41 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_before_billing_details', $invoice ); ?>
6
+do_action('wpinv_email_before_billing_details', $invoice); ?>
7 7
 <div id="wpinv-email-billing">
8
-    <h3 class="wpinv-address-t"><?php echo apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ); ?></h3>
8
+    <h3 class="wpinv-address-t"><?php echo apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing')); ?></h3>
9 9
 
10 10
     <table class="table table-bordered table-sm wpi-billing-details">
11 11
         <tbody>
12
-            <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?>
12
+            <?php do_action('wpinv_email_billing_fields_first', $invoice); ?>
13 13
             <tr class="wpi-receipt-name">
14
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
15
-                <td><?php if ( $sent_to_admin && $invoice->get_user_id() ) { ?><a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ) ;?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a><?php } else { echo esc_html( $invoice->get_user_full_name() ); } ?></td>
14
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
15
+                <td><?php if ($sent_to_admin && $invoice->get_user_id()) { ?><a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a><?php } else { echo esc_html($invoice->get_user_full_name()); } ?></td>
16 16
             </tr>
17 17
             <tr class="wpi-receipt-email">
18
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
19
-                <td><?php echo $invoice->get_email() ;?></td>
18
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
19
+                <td><?php echo $invoice->get_email(); ?></td>
20 20
             </tr>
21
-            <?php if ( $invoice->get_company() ) { ?>
21
+            <?php if ($invoice->get_company()) { ?>
22 22
             <tr class="wpi-receipt-company">
23
-                <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th>
24
-                <td><?php echo esc_html( $invoice->get_company() ) ;?></td>
23
+                <th class="text-left"><?php _e('Company', 'invoicing'); ?></th>
24
+                <td><?php echo esc_html($invoice->get_company()); ?></td>
25 25
             </tr>
26 26
             <?php } ?>
27 27
             <tr class="wpi-receipt-address">
28
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
29
-                <td><?php echo wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ;?></td>
28
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
29
+                <td><?php echo wpinv_get_invoice_address_markup($invoice->get_user_info()); ?></td>
30 30
             </tr>
31
-            <?php if ( $invoice->get_phone() ) { ?>
31
+            <?php if ($invoice->get_phone()) { ?>
32 32
             <tr class="wpi-receipt-phone">
33
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
34
-                <td><?php echo esc_html( $invoice->phone ) ;?></td>
33
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
34
+                <td><?php echo esc_html($invoice->phone); ?></td>
35 35
             </tr>
36 36
             <?php } ?>
37
-            <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?>
37
+            <?php do_action('wpinv_email_billing_fields_last', $invoice); ?>
38 38
         </tbody>
39 39
     </table>
40 40
 </div>
41
-<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?>
42 41
\ No newline at end of file
42
+<?php do_action('wpinv_email_after_billing_details', $invoice); ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-invoice-details.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 global $wpinv_euvat;
7 8
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6 6
 global $wpinv_euvat;
7 7
 
8
-$sent_to_admin  = !empty( $sent_to_admin ) ? true : false;
9
-$invoice_url = $invoice->get_view_url( true );
8
+$sent_to_admin = !empty($sent_to_admin) ? true : false;
9
+$invoice_url = $invoice->get_view_url(true);
10 10
 $use_taxes = wpinv_use_taxes();
11 11
 $vat_name = getpaid_tax()->get_vat_name();
12 12
 
13
-do_action( 'wpinv_email_before_invoice_details', $invoice, $sent_to_admin ); ?>
13
+do_action('wpinv_email_before_invoice_details', $invoice, $sent_to_admin); ?>
14 14
 <div id="wpinv-email-details">
15
-    <h3 class="wpinv-details-t"><?php echo apply_filters( 'wpinv_email_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?></h3>
15
+    <h3 class="wpinv-details-t"><?php echo apply_filters('wpinv_email_details_title', __('Invoice Details', 'invoicing'), $invoice); ?></h3>
16 16
     <table class="table table-bordered table-sm">
17
-        <?php if ( $invoice_number = $invoice->get_number() ) { ?>
17
+        <?php if ($invoice_number = $invoice->get_number()) { ?>
18 18
             <tr>
19
-                <td><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></td>
20
-                <td><a href="<?php echo esc_url( $invoice_url ) ;?>"><?php echo $invoice_number; ?></a></td>
19
+                <td><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></td>
20
+                <td><a href="<?php echo esc_url($invoice_url); ?>"><?php echo $invoice_number; ?></a></td>
21 21
             </tr>
22 22
         <?php } ?>
23 23
         <tr>
24
-            <td><?php echo apply_filters( 'wpinv_invoice_status_title', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></td>
25
-            <td><?php echo $invoice->get_status( true ); ?></td>
24
+            <td><?php echo apply_filters('wpinv_invoice_status_title', __('Invoice Status', 'invoicing'), $invoice); ?></td>
25
+            <td><?php echo $invoice->get_status(true); ?></td>
26 26
         </tr>
27
-        <?php if ( $invoice->is_renewal() ) { ?>
27
+        <?php if ($invoice->is_renewal()) { ?>
28 28
         <tr>
29
-            <td><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></td>
30
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
29
+            <td><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></td>
30
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
31 31
         </tr>
32 32
         <?php } ?>
33
-        <?php if ( ( $gateway_title = $invoice->get_gateway_title() ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
34
-            <td><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></td>
33
+        <?php if (($gateway_title = $invoice->get_gateway_title()) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
34
+            <td><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></td>
35 35
             <td><?php echo $gateway_title; ?></td>
36 36
         <?php } ?>
37
-        <?php if ( $invoice_date = $invoice->get_invoice_date( false ) ) { ?>
37
+        <?php if ($invoice_date = $invoice->get_invoice_date(false)) { ?>
38 38
             <tr>
39
-                <td><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></td>
40
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $invoice_date ) ), $invoice->get_invoice_date() ); ?></td>
39
+                <td><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></td>
40
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($invoice_date)), $invoice->get_invoice_date()); ?></td>
41 41
             </tr>
42 42
         <?php } ?>
43
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date() ) ) { ?>
43
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date())) { ?>
44 44
             <tr>
45
-                <td><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></td>
46
-                <td><?php echo wp_sprintf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $due_date ) ), $invoice->get_due_date( true ) ); ?></td>
45
+                <td><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></td>
46
+                <td><?php echo wp_sprintf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($due_date)), $invoice->get_due_date(true)); ?></td>
47 47
             </tr>
48 48
         <?php } ?>
49
-        <?php do_action( 'wpinv_email_invoice_details_after_due_date', $invoice->get_id() ); ?>
50
-        <?php if ( empty( $sent_to_admin ) && ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) ) { ?>
49
+        <?php do_action('wpinv_email_invoice_details_after_due_date', $invoice->get_id()); ?>
50
+        <?php if (empty($sent_to_admin) && ($owner_vat_number = $wpinv_euvat->get_vat_number())) { ?>
51 51
             <tr>
52
-                <td><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
52
+                <td><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
53 53
                 <td><?php echo $owner_vat_number; ?></td>
54 54
             </tr>
55 55
         <?php } ?>
56
-        <?php if ( $use_taxes && ( $user_vat_number = $invoice->vat_number ) ) { ?>
56
+        <?php if ($use_taxes && ($user_vat_number = $invoice->vat_number)) { ?>
57 57
             <tr>
58
-                <td><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></td>
58
+                <td><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></td>
59 59
                 <td><?php echo $user_vat_number; ?></td>
60 60
             </tr>
61 61
         <?php } ?>
62 62
         <tr class="table-active">
63
-            <td><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></td>
64
-            <td><strong><?php echo $invoice->get_total( true ); ?></strong></td>
63
+            <td><strong><?php _e('Total Amount', 'invoicing') ?></strong></td>
64
+            <td><strong><?php echo $invoice->get_total(true); ?></strong></td>
65 65
         </tr>
66 66
     </table>
67 67
 </div>
68
-<?php do_action( 'wpinv_email_after_invoice_details', $invoice, $sent_to_admin ); ?>
69 68
\ No newline at end of file
69
+<?php do_action('wpinv_email_after_invoice_details', $invoice, $sent_to_admin); ?>
70 70
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -348,7 +348,7 @@
 block discarded – undo
348 348
 
349 349
         $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
350 350
         if ( !empty( $status ) && $status != 'all' ) {
351
-           $query_args['status'] = $status;
351
+            $query_args['status'] = $status;
352 352
         }
353 353
         $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
354 354
         
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 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; // Exit if accessed directly
4 4
 }
5 5
 
@@ -9,42 +9,42 @@  discard block
 block discarded – undo
9 9
     
10 10
     public function __construct() {
11 11
 
12
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
13
-            define( 'WPINV_BP_SLUG', 'invoices' );
12
+        if (!defined('WPINV_BP_SLUG')) {
13
+            define('WPINV_BP_SLUG', 'invoices');
14 14
         }
15 15
 
16
-        add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) );
17
-        add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) );
18
-        add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 );
19
-        add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 );
20
-        add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
16
+        add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content'));
17
+        add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content'));
18
+        add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1);
19
+        add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1);
20
+        add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2);
21 21
         add_action('bp_setup_nav', array($this, 'setup_nav'), 15);
22 22
         
23
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
23
+        $position       = wpinv_get_option('wpinv_menu_position');
24 24
         $position       = $position !== '' && $position !== false ? $position : 91;
25
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
26
-        $this->id     = WPINV_BP_SLUG;
25
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
26
+        $this->id = WPINV_BP_SLUG;
27 27
     }
28 28
 
29 29
     public function setup_nav() {
30 30
 
31
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) {
31
+        if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) {
32 32
             return;
33 33
         }
34 34
 
35
-        if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){
35
+        if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $count = $this->get_invoice_count();
40
-        $class = ( 0 === $count ) ? 'no-count' : 'count';
40
+        $class = (0 === $count) ? 'no-count' : 'count';
41 41
 
42 42
         $main_nav_name = sprintf(
43
-            __( 'My Invoices %s', 'invoicing' ),
43
+            __('My Invoices %s', 'invoicing'),
44 44
             sprintf(
45 45
                 '<span class="%s">%s</span>',
46
-                esc_attr( $class ),
47
-                bp_core_number_format( $count )
46
+                esc_attr($class),
47
+                bp_core_number_format($count)
48 48
             )
49 49
         );
50 50
 
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
             'name'                => $main_nav_name,
53 53
             'slug'                => WPINV_BP_SLUG,
54 54
             'position'            => $this->position,
55
-            'screen_function'     => array( $this, 'invoices_screen' ),
55
+            'screen_function'     => array($this, 'invoices_screen'),
56 56
             'default_subnav_slug' => 'invoices',
57 57
             'item_css_id'         => $this->id
58 58
         );
59 59
 
60
-        bp_core_new_nav_item( $main_nav );
60
+        bp_core_new_nav_item($main_nav);
61 61
     }
62 62
     
63 63
     public function invoices_screen() {
64
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
64
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
65 65
             return;
66 66
         }
67 67
         
68
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
68
+        add_action('bp_template_content', array($this, 'invoices_content'));
69 69
 
70
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
70
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
71 71
         
72
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
72
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
73 73
     }
74 74
     
75 75
     public function invoices_content() {
76
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
76
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
77 77
             global $invoices_template;
78 78
             
79
-            do_action( 'wpinv_bp_invoices_before_content' );
79
+            do_action('wpinv_bp_invoices_before_content');
80 80
             ?>
81 81
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
82 82
                 <div id="pag-top" class="pagination">
@@ -90,61 +90,61 @@  discard block
 block discarded – undo
90 90
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
91 91
                     <thead>
92 92
                         <tr>
93
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
94
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
93
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
94
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
95 95
                             <?php endforeach; ?>
96 96
                         </tr>
97 97
                     </thead>
98 98
                     <tbody>
99
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
99
+                        <?php foreach ($invoices_template->invoices as $invoice) {
100 100
                             ?>
101 101
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
104
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
-
107
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
102
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
103
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
104
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
105
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
106
+
107
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
108
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
109
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
110 110
                                             </a>
111 111
 
112
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
113
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
112
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
113
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114 114
 
115
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
116
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
115
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
116
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117 117
 
118
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
-                                            <?php echo $invoice->get_status_label_html() ; ?>
118
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
119
+                                            <?php echo $invoice->get_status_label_html(); ?>
120 120
 
121
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
-                                            <?php echo $invoice->get_total( true ); ?>
121
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
122
+                                            <?php echo $invoice->get_total(true); ?>
123 123
 
124
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
124
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
125 125
                                             <?php
126 126
                                                 $actions = array(
127 127
                                                     'pay'    => array(
128 128
                                                         'url'  => $invoice->get_checkout_payment_url(),
129
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
129
+                                                        'name' => __('Pay Now', 'invoicing'),
130 130
                                                         'class' => 'btn-success'
131 131
                                                     ),
132 132
                                                     'print'   => array(
133 133
                                                         'url'  => $invoice->get_view_url(),
134
-                                                        'name' => __( 'Print', 'invoicing' ),
134
+                                                        'name' => __('Print', 'invoicing'),
135 135
                                                         'class' => 'btn-primary',
136 136
                                                         'attrs' => 'target="_blank"'
137 137
                                                     )
138 138
                                                 );
139 139
 
140
-                                                if ( ! $invoice->needs_payment() ) {
141
-                                                    unset( $actions['pay'] );
140
+                                                if (!$invoice->needs_payment()) {
141
+                                                    unset($actions['pay']);
142 142
                                                 }
143 143
 
144
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
-                                                    foreach ( $actions as $key => $action ) {
144
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
145
+                                                    foreach ($actions as $key => $action) {
146 146
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
147
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
148 148
                                                     }
149 149
                                                 }
150 150
                                             ?>
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
             </div>
173 173
             <?php
174 174
         
175
-            do_action( 'wpinv_bp_invoices_after_content' );
175
+            do_action('wpinv_bp_invoices_after_content');
176 176
         } else {
177 177
             ?>
178 178
             <div id="message" class="info">
179
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
179
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
180 180
             </div>
181 181
             <?php
182 182
         }
183 183
         
184
-        if ( defined( 'DOING_AJAX' ) ) {
184
+        if (defined('DOING_AJAX')) {
185 185
             exit;
186 186
         }
187 187
     }
188 188
     
189
-    public function has_invoices( $args = '' ) {
189
+    public function has_invoices($args = '') {
190 190
         global $invoices_template;
191 191
 
192
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
192
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
193 193
         // Parse arguments.
194
-        $r = bp_parse_args( $args, array(
194
+        $r = bp_parse_args($args, array(
195 195
             'status'            => 'all',
196 196
             'page_arg'          => 'bpage',
197 197
             'page'              => 1,
198 198
             'per_page'          => $per_page > 0 ? $per_page : 20,
199 199
             'max'               => false,
200 200
             'user_id'           => bp_displayed_user_id(),
201
-        ), 'has_invoices' );
201
+        ), 'has_invoices');
202 202
 
203 203
 
204
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
205
-            $r['per_page'] = (int)$r['max'];
204
+        if (!empty($r['max']) && ((int) $r['per_page'] > (int) $r['max'])) {
205
+            $r['per_page'] = (int) $r['max'];
206 206
         }
207 207
 
208 208
         // Get the invoices.
209
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
209
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
210 210
 
211
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
211
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
212 212
     }
213 213
     
214 214
     public function get_invoice_count() {
215
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
216
-        $invoices   = wpinv_get_invoices( $query );
215
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
216
+        $invoices   = wpinv_get_invoices($query);
217 217
         
218
-        return !empty( $invoices ) ? count( $invoices ) : 0;
218
+        return !empty($invoices) ? count($invoices) : 0;
219 219
     }
220 220
     
221 221
     public function pagination_count() {
222 222
         global $invoices_template;
223 223
 
224
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
225
-        $from_num  = bp_core_number_format( $start_num );
226
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
227
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
224
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
225
+        $from_num  = bp_core_number_format($start_num);
226
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
227
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
228 228
 
229
-        if ( 1 == $invoices_template->total_invoice_count ) {
230
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
229
+        if (1 == $invoices_template->total_invoice_count) {
230
+            $message = __('Viewing 1 invoice', 'invoicing');
231 231
         } else {
232
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
232
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
233 233
         }
234 234
 
235 235
         return $message;
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
     function pagination_links() {
239 239
         global $invoices_template;
240 240
 
241
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
241
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
242 242
     }
243 243
     
244
-    public function bp_section( $settings = array() ) {
245
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
244
+    public function bp_section($settings = array()) {
245
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
246 246
         return $settings;
247 247
     }
248 248
     
249
-    public function bp_settings( $settings = array() ) {
249
+    public function bp_settings($settings = array()) {
250 250
         $settings['wpinv_bp'] = array(
251 251
             'wpinv_bp_labels' => array(
252 252
                 'id'   => 'wpinv_bp_settings',
253
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
253
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
254 254
                 'desc' => '',
255 255
                 'type' => 'header',
256 256
             ),
257 257
             'wpinv_bp_hide_menu' => array(
258 258
                 'id'   => 'wpinv_bp_hide_menu',
259
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
260
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
259
+                'name' => __('Hide Invoices link', 'invoicing'),
260
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
261 261
                 'type' => 'checkbox',
262 262
             ),
263 263
             'wpinv_menu_position' => array(
264 264
                 'id'   => 'wpinv_menu_position',
265
-                'name' => __( 'Menu position', 'invoicing' ),
266
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
265
+                'name' => __('Menu position', 'invoicing'),
266
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
267 267
                 'type' => 'number',
268 268
                 'size' => 'small',
269 269
                 'min'  => '1',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
             ),
274 274
             'wpinv_bp_per_page' => array(
275 275
                 'id'   => 'wpinv_bp_per_page',
276
-                'name' => __( 'Max invoices per page', 'invoicing' ),
277
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
276
+                'name' => __('Max invoices per page', 'invoicing'),
277
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
278 278
                 'type' => 'number',
279 279
                 'size' => 'small',
280 280
                 'min'  => '1',
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         return $settings;
288 288
     }
289 289
 
290
-    public function wp_nav_menu_objects($items, $args){
291
-        if(!is_user_logged_in()){
290
+    public function wp_nav_menu_objects($items, $args) {
291
+        if (!is_user_logged_in()) {
292 292
             return $items;
293 293
         }
294 294
 
295
-        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
295
+        if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) {
296 296
             return $items;
297 297
         }
298 298
 
299 299
         $user_id = get_current_user_id();
300
-        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
300
+        $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG;
301 301
         $history_link = wpinv_get_history_page_uri();
302
-        foreach ( $items as $item ) {
303
-            $item->url = str_replace( $history_link, $link, $item->url );
302
+        foreach ($items as $item) {
303
+            $item->url = str_replace($history_link, $link, $item->url);
304 304
         }
305 305
 
306 306
         return $items;
@@ -318,78 +318,78 @@  discard block
 block discarded – undo
318 318
     public $pag_links = '';
319 319
     public $total_invoice_count = 0;
320 320
     
321
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
322
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
321
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
322
+        $this->invoices = array('invoices' => array(), 'total' => 0);
323 323
         
324
-        $this->pag_arg  = sanitize_key( $page_arg );
325
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
326
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
324
+        $this->pag_arg  = sanitize_key($page_arg);
325
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
326
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
327 327
 
328
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
329
-        if ( !empty( $status ) && $status != 'all' ) {
328
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
329
+        if (!empty($status) && $status != 'all') {
330 330
            $query_args['status'] = $status;
331 331
         }
332
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
332
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
333 333
         
334
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
335
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
334
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
335
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
336 336
             $this->invoices['total']    = $invoices->found_posts;
337 337
         }
338 338
 
339
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
340
-            $this->total_invoice_count = (int)$this->invoices['total'];
339
+        if (empty($max) || ($max >= (int) $this->invoices['total'])) {
340
+            $this->total_invoice_count = (int) $this->invoices['total'];
341 341
         } else {
342
-            $this->total_invoice_count = (int)$max;
342
+            $this->total_invoice_count = (int) $max;
343 343
         }
344 344
 
345 345
         $this->invoices = $this->invoices['invoices'];
346 346
 
347
-        $invoice_count = count( $this->invoices );
347
+        $invoice_count = count($this->invoices);
348 348
 
349
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
350
-            $this->invoice_count = (int)$invoice_count;
349
+        if (empty($max) || ($max >= (int) $invoice_count)) {
350
+            $this->invoice_count = (int) $invoice_count;
351 351
         } else {
352
-            $this->invoice_count = (int)$max;
352
+            $this->invoice_count = (int) $max;
353 353
         }
354 354
         
355
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
356
-            $this->pag_links = paginate_links( array(
357
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
355
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
356
+            $this->pag_links = paginate_links(array(
357
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
358 358
                 'format'    => '',
359
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
360
-                'current'   => (int)$this->pag_page,
361
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
362
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
359
+                'total'     => ceil((int) $this->total_invoice_count / (int) $this->pag_num),
360
+                'current'   => (int) $this->pag_page,
361
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
362
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
363 363
                 'mid_size'  => 1,
364 364
                 'add_args'  => array(),
365
-            ) );
365
+            ));
366 366
         }
367 367
     }
368 368
 
369 369
     public function has_invoices() {
370
-        return (bool) ! empty( $this->invoice_count );
370
+        return (bool) !empty($this->invoice_count);
371 371
     }
372 372
 
373 373
     public function next_invoice() {
374 374
         $this->current_invoice++;
375
-        $this->invoice = $this->invoices[ $this->current_invoice ];
375
+        $this->invoice = $this->invoices[$this->current_invoice];
376 376
 
377 377
         return $this->invoice;
378 378
     }
379 379
 
380 380
     public function rewind_invoices() {
381 381
         $this->current_invoice = -1;
382
-        if ( $this->invoice_count > 0 ) {
382
+        if ($this->invoice_count > 0) {
383 383
             $this->invoice = $this->invoices[0];
384 384
         }
385 385
     }
386 386
 
387 387
     public function invoices() {
388
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
388
+        if (($this->current_invoice + 1) < $this->invoice_count) {
389 389
             return true;
390
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
390
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
391 391
 
392
-            do_action( 'wpinv_bp_invoice_loop_end' );
392
+            do_action('wpinv_bp_invoice_loop_end');
393 393
             
394 394
             $this->rewind_invoices();
395 395
         }
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
         $this->in_the_loop = true;
404 404
         $this->invoice     = $this->next_invoice();
405 405
 
406
-        if ( 0 === $this->current_invoice ) {
407
-            do_action( 'wpinv_bp_invoice_loop_start' );
406
+        if (0 === $this->current_invoice) {
407
+            do_action('wpinv_bp_invoice_loop_start');
408 408
         }
409 409
     }
410 410
 }
411 411
 
412 412
 function wpinv_bp_setup_component() {
413 413
 
414
-    if(!class_exists( 'BuddyPress' )){
414
+    if (!class_exists('BuddyPress')) {
415 415
         return;
416 416
     }
417 417
 
418 418
     new WPInv_BP_Component();
419 419
 
420 420
 }
421
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
422 421
\ No newline at end of file
422
+add_action('bp_loaded', 'wpinv_bp_setup_component');
423 423
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,9 @@
 block discarded – undo
196 196
             foreach ( $types as $name => $type ) {
197 197
                 echo '<option value="' . esc_attr( $name ) . '"';
198 198
 
199
-                if ( isset( $_GET['discount_type'] ) )
200
-                    selected( $name, $_GET['discount_type'] );
199
+                if ( isset( $_GET['discount_type'] ) ) {
200
+                                    selected( $name, $_GET['discount_type'] );
201
+                }
201 202
 
202 203
                 echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
203 204
             }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_invoice' ) {
36
+    if ($post_type == 'wpi_invoice') {
37 37
         $actions = array();
38 38
     }
39 39
 
40
-    if ( $post_type == 'wpi_discount' ) {
41
-        $actions = wpinv_discount_row_actions( $post, $actions );
40
+    if ($post_type == 'wpi_discount') {
41
+        $actions = wpinv_discount_row_actions($post, $actions);
42 42
     }
43 43
 
44 44
     return $actions;
45 45
 }
46 46
 
47
-function wpinv_discount_row_actions( $discount, $row_actions ) {
48
-    $row_actions  = array();
49
-    $edit_link = get_edit_post_link( $discount->ID );
50
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
47
+function wpinv_discount_row_actions($discount, $row_actions) {
48
+    $row_actions = array();
49
+    $edit_link = get_edit_post_link($discount->ID);
50
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
51 51
 
52
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
53
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
54
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
55
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
52
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
53
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
54
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
55
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
56 56
     }
57 57
 
58 58
     $delete_url = esc_url(
@@ -66,110 +66,110 @@  discard block
 block discarded – undo
66 66
             'wpinv_discount_nonce'
67 67
         )
68 68
     );
69
-    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __( 'Delete', 'invoicing' ) . '</a>';
69
+    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __('Delete', 'invoicing') . '</a>';
70 70
 
71
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
71
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
72 72
 
73 73
     return $row_actions;
74 74
 }
75 75
 
76
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
77
-function wpinv_table_primary_column( $default, $screen_id ) {
78
-    if ( 'edit-wpi_invoice' === $screen_id ) {
76
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
77
+function wpinv_table_primary_column($default, $screen_id) {
78
+    if ('edit-wpi_invoice' === $screen_id) {
79 79
         return 'name';
80 80
     }
81 81
 
82 82
     return $default;
83 83
 }
84 84
 
85
-function wpinv_discount_bulk_actions( $actions, $display = false ) {
86
-    if ( !$display ) {
85
+function wpinv_discount_bulk_actions($actions, $display = false) {
86
+    if (!$display) {
87 87
         return array();
88 88
     }
89 89
 
90 90
     $actions = array(
91
-        'activate'   => __( 'Activate', 'invoicing' ),
92
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
93
-        'delete'     => __( 'Delete', 'invoicing' ),
91
+        'activate'   => __('Activate', 'invoicing'),
92
+        'deactivate' => __('Deactivate', 'invoicing'),
93
+        'delete'     => __('Delete', 'invoicing'),
94 94
     );
95 95
     $two = '';
96 96
     $which = 'top';
97 97
     echo '</div><div class="alignleft actions bulkactions">';
98
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
99
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
100
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
98
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
99
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
100
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
101 101
 
102
-    foreach ( $actions as $name => $title ) {
102
+    foreach ($actions as $name => $title) {
103 103
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
104 104
 
105 105
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
106 106
     }
107 107
     echo "</select>";
108 108
 
109
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
109
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
110 110
 
111 111
     echo '</div><div class="alignleft actions">';
112 112
 }
113
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
113
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
114 114
 
115
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
116
-    if ( $post_type == 'wpi_discount' ) {
115
+function wpinv_disable_months_dropdown($disable, $post_type) {
116
+    if ($post_type == 'wpi_discount') {
117 117
         $disable = true;
118 118
     }
119 119
 
120 120
     return $disable;
121 121
 }
122
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
122
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
123 123
 
124 124
 function wpinv_restrict_manage_posts() {
125 125
     global $typenow;
126 126
 
127
-    if( 'wpi_discount' == $typenow ) {
127
+    if ('wpi_discount' == $typenow) {
128 128
         wpinv_discount_filters();
129 129
     }
130 130
 }
131
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
131
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
132 132
 
133 133
 function wpinv_discount_filters() {
134
-    wpinv_discount_bulk_actions( array(), true );
134
+    wpinv_discount_bulk_actions(array(), true);
135 135
 
136 136
     ?>
137 137
     <select name="discount_type" id="dropdown_wpinv_discount_type">
138
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
138
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
139 139
         <?php
140 140
             $types = wpinv_get_discount_types();
141 141
 
142
-            foreach ( $types as $name => $type ) {
143
-                echo '<option value="' . esc_attr( $name ) . '"';
142
+            foreach ($types as $name => $type) {
143
+                echo '<option value="' . esc_attr($name) . '"';
144 144
 
145
-                if ( isset( $_GET['discount_type'] ) )
146
-                    selected( $name, $_GET['discount_type'] );
145
+                if (isset($_GET['discount_type']))
146
+                    selected($name, $_GET['discount_type']);
147 147
 
148
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
148
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
149 149
             }
150 150
         ?>
151 151
     </select>
152 152
     <?php
153 153
 }
154 154
 
155
-function wpinv_request( $vars ) {
155
+function wpinv_request($vars) {
156 156
     global $typenow, $wp_query, $wp_post_statuses;
157 157
 
158
-    if ( 'wpi_invoice' === $typenow ) {
159
-        if ( !isset( $vars['post_status'] ) ) {
158
+    if ('wpi_invoice' === $typenow) {
159
+        if (!isset($vars['post_status'])) {
160 160
             $post_statuses = wpinv_get_invoice_statuses();
161 161
 
162
-            foreach ( $post_statuses as $status => $value ) {
163
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
164
-                    unset( $post_statuses[ $status ] );
162
+            foreach ($post_statuses as $status => $value) {
163
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
164
+                    unset($post_statuses[$status]);
165 165
                 }
166 166
             }
167 167
 
168
-            $vars['post_status'] = array_keys( $post_statuses );
168
+            $vars['post_status'] = array_keys($post_statuses);
169 169
         }
170 170
 
171
-        if ( isset( $vars['orderby'] ) ) {
172
-            if ( 'amount' == $vars['orderby'] ) {
171
+        if (isset($vars['orderby'])) {
172
+            if ('amount' == $vars['orderby']) {
173 173
                 $vars = array_merge(
174 174
                     $vars,
175 175
                     array(
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                         'orderby'  => 'meta_value_num'
178 178
                     )
179 179
                 );
180
-            } else if ( 'customer' == $vars['orderby'] ) {
180
+            } else if ('customer' == $vars['orderby']) {
181 181
                 $vars = array_merge(
182 182
                     $vars,
183 183
                     array(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                         'orderby'  => 'meta_value'
186 186
                     )
187 187
                 );
188
-            } else if ( 'number' == $vars['orderby'] ) {
188
+            } else if ('number' == $vars['orderby']) {
189 189
                 $vars = array_merge(
190 190
                     $vars,
191 191
                     array(
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                         'orderby'  => 'meta_value'
194 194
                     )
195 195
                 );
196
-            } else if ( 'payment_date' == $vars['orderby'] ) {
196
+            } else if ('payment_date' == $vars['orderby']) {
197 197
                 $vars = array_merge(
198 198
                     $vars,
199 199
                     array(
@@ -203,73 +203,73 @@  discard block
 block discarded – undo
203 203
                 );
204 204
             }
205 205
         }
206
-    } else if ( 'wpi_discount' == $typenow ) {
207
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
206
+    } else if ('wpi_discount' == $typenow) {
207
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
208 208
         // Filter vat rule type
209
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
209
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
210 210
             $meta_query[] = array(
211 211
                     'key'   => '_wpi_discount_type',
212
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
212
+                    'value' => sanitize_text_field($_GET['discount_type']),
213 213
                     'compare' => '='
214 214
                 );
215 215
         }
216 216
 
217
-        if ( !empty( $meta_query ) ) {
217
+        if (!empty($meta_query)) {
218 218
             $vars['meta_query'] = $meta_query;
219 219
         }
220 220
     }
221 221
 
222 222
     return $vars;
223 223
 }
224
-add_filter( 'request', 'wpinv_request' );
224
+add_filter('request', 'wpinv_request');
225 225
 
226
-function wpinv_item_type_class( $classes, $class, $post_id ) {
226
+function wpinv_item_type_class($classes, $class, $post_id) {
227 227
     global $pagenow, $typenow;
228 228
 
229
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
230
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
231
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
229
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
230
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
231
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
232 232
         }
233 233
 
234
-        if ( !wpinv_item_is_editable( $post_id ) ) {
234
+        if (!wpinv_item_is_editable($post_id)) {
235 235
             $classes[] = 'wpi-editable-n';
236 236
         }
237 237
     }
238 238
     return $classes;
239 239
 }
240
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
240
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
241 241
 
242 242
 function wpinv_check_quick_edit() {
243 243
     global $pagenow, $current_screen, $wpinv_item_screen;
244 244
 
245
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
246
-        if ( empty( $wpinv_item_screen ) ) {
247
-            if ( $current_screen->post_type == 'wpi_item' ) {
245
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
246
+        if (empty($wpinv_item_screen)) {
247
+            if ($current_screen->post_type == 'wpi_item') {
248 248
                 $wpinv_item_screen = 'y';
249 249
             } else {
250 250
                 $wpinv_item_screen = 'n';
251 251
             }
252 252
         }
253 253
 
254
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
255
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
256
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
254
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
255
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
256
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
257 257
         }
258 258
     }
259 259
 }
260
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
260
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
261 261
 
262
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
263
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
264
-        unset( $actions['inline hide-if-no-js'] );
262
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
263
+    if (isset($actions['inline hide-if-no-js'])) {
264
+        unset($actions['inline hide-if-no-js']);
265 265
     }
266 266
 
267
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
268
-        if ( isset( $actions['trash'] ) ) {
269
-            unset( $actions['trash'] );
267
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
268
+        if (isset($actions['trash'])) {
269
+            unset($actions['trash']);
270 270
         }
271
-        if ( isset( $actions['delete'] ) ) {
272
-            unset( $actions['delete'] );
271
+        if (isset($actions['delete'])) {
272
+            unset($actions['delete']);
273 273
         }
274 274
     }
275 275
 
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
  * @param int $post_parent (default: 0) Parent for the new page
287 287
  * @return int page ID
288 288
  */
289
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
289
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
290 290
     global $wpdb;
291 291
 
292
-    $option_value = wpinv_get_option( $option );
292
+    $option_value = wpinv_get_option($option);
293 293
 
294
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
295
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
294
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
295
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
296 296
             // Valid page is already in place
297 297
             return $page_object->ID;
298 298
         }
299 299
     }
300 300
 
301
-    if(!empty($post_parent)){
301
+    if (!empty($post_parent)) {
302 302
         $page = get_page_by_path($post_parent);
303 303
         if ($page) {
304 304
             $post_parent = $page->ID;
@@ -307,40 +307,40 @@  discard block
 block discarded – undo
307 307
         }
308 308
     }
309 309
 
310
-    if ( strlen( $page_content ) > 0 ) {
310
+    if (strlen($page_content) > 0) {
311 311
         // Search for an existing page with the specified page content (typically a shortcode)
312
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
312
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
313 313
     } else {
314 314
         // Search for an existing page with the specified page slug
315
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
315
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
316 316
     }
317 317
 
318
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
318
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
319 319
 
320
-    if ( $valid_page_found ) {
321
-        if ( $option ) {
322
-            wpinv_update_option( $option, $valid_page_found );
320
+    if ($valid_page_found) {
321
+        if ($option) {
322
+            wpinv_update_option($option, $valid_page_found);
323 323
         }
324 324
         return $valid_page_found;
325 325
     }
326 326
 
327 327
     // Search for a matching valid trashed page
328
-    if ( strlen( $page_content ) > 0 ) {
328
+    if (strlen($page_content) > 0) {
329 329
         // Search for an existing page with the specified page content (typically a shortcode)
330
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
330
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
331 331
     } else {
332 332
         // Search for an existing page with the specified page slug
333
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
333
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
334 334
     }
335 335
 
336
-    if ( $trashed_page_found ) {
336
+    if ($trashed_page_found) {
337 337
         $page_id   = $trashed_page_found;
338 338
         $page_data = array(
339 339
             'ID'             => $page_id,
340 340
             'post_status'    => 'publish',
341 341
             'post_parent'    => $post_parent,
342 342
         );
343
-        wp_update_post( $page_data );
343
+        wp_update_post($page_data);
344 344
     } else {
345 345
         $page_data = array(
346 346
             'post_status'    => 'publish',
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
             'post_parent'    => $post_parent,
353 353
             'comment_status' => 'closed',
354 354
         );
355
-        $page_id = wp_insert_post( $page_data );
355
+        $page_id = wp_insert_post($page_data);
356 356
     }
357 357
 
358
-    if ( $option ) {
359
-        wpinv_update_option( $option, (int)$page_id );
358
+    if ($option) {
359
+        wpinv_update_option($option, (int) $page_id);
360 360
     }
361 361
 
362 362
     return $page_id;
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 3 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
 }
287 287
 
288 288
 function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
289
+    $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
290 290
 
291 291
     $chosen = false;
292 292
     if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+    $chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
-	}
298
+    if ( false !== $chosen ) {
299
+        $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
+    }
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
-		$enabled_gateway = 'manual';
306
-	} else {
307
-		$enabled_gateway = wpinv_get_default_gateway();
308
-	}
302
+    if ( ! empty ( $chosen ) ) {
303
+        $enabled_gateway = urldecode( $chosen );
304
+    } else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
+        $enabled_gateway = 'manual';
306
+    } else {
307
+        $enabled_gateway = wpinv_get_default_gateway();
308
+    }
309 309
     
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+    return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
320 320
 }
321 321
 
322 322
 function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 }
325 325
 
326 326
 function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
327
-	$ret  = 0;
328
-	$args = array(
329
-		'meta_key'    => '_wpinv_gateway',
330
-		'meta_value'  => $gateway_id,
331
-		'nopaging'    => true,
332
-		'post_type'   => 'wpi_invoice',
333
-		'post_status' => $status,
334
-		'fields'      => 'ids'
335
-	);
336
-
337
-	$payments = new WP_Query( $args );
338
-
339
-	if( $payments )
340
-		$ret = $payments->post_count;
341
-	return $ret;
327
+    $ret  = 0;
328
+    $args = array(
329
+        'meta_key'    => '_wpinv_gateway',
330
+        'meta_value'  => $gateway_id,
331
+        'nopaging'    => true,
332
+        'post_type'   => 'wpi_invoice',
333
+        'post_status' => $status,
334
+        'fields'      => 'ids'
335
+    );
336
+
337
+    $payments = new WP_Query( $args );
338
+
339
+    if( $payments )
340
+        $ret = $payments->post_count;
341
+    return $ret;
342 342
 }
343 343
 
344 344
 function wpinv_settings_update_gateways( $input ) {
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else{
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
@@ -336,8 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
 	$payments = new WP_Query( $args );
338 338
 
339
-	if( $payments )
340
-		$ret = $payments->post_count;
339
+	if( $payments ) {
340
+			$ret = $payments->post_count;
341
+	}
341 342
 	return $ret;
342 343
 }
343 344
 
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains gateway functions.
4 4
  *
5 5
  */
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Returns an array of payment gateways.
@@ -11,141 +11,141 @@  discard block
 block discarded – undo
11 11
  * @return array
12 12
  */
13 13
 function wpinv_get_payment_gateways() {
14
-    return apply_filters( 'wpinv_payment_gateways', array() );
14
+    return apply_filters('wpinv_payment_gateways', array());
15 15
 }
16 16
 
17
-function wpinv_payment_gateway_titles( $all_gateways ) {
17
+function wpinv_payment_gateway_titles($all_gateways) {
18 18
     global $wpinv_options;
19 19
 
20 20
     $gateways = array();
21
-    foreach ( $all_gateways as $key => $gateway ) {
22
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
23
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
21
+    foreach ($all_gateways as $key => $gateway) {
22
+        if (!empty($wpinv_options[$key . '_title'])) {
23
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
24 24
         }
25 25
 
26
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
26
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
27 27
     }
28 28
 
29
-    asort( $gateways );
29
+    asort($gateways);
30 30
 
31
-    foreach ( $gateways as $gateway => $key ) {
31
+    foreach ($gateways as $gateway => $key) {
32 32
         $gateways[$gateway] = $all_gateways[$gateway];
33 33
     }
34 34
 
35 35
     return $gateways;
36 36
 }
37
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
37
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
38 38
 
39
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
39
+function wpinv_get_enabled_payment_gateways($sort = false) {
40 40
     $gateways = wpinv_get_payment_gateways();
41
-    $enabled  = wpinv_get_option( 'gateways', false );
41
+    $enabled  = wpinv_get_option('gateways', false);
42 42
 
43 43
     $gateway_list = array();
44 44
 
45
-    foreach ( $gateways as $key => $gateway ) {
46
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
47
-            $gateway_list[ $key ] = $gateway;
45
+    foreach ($gateways as $key => $gateway) {
46
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
47
+            $gateway_list[$key] = $gateway;
48 48
         }
49 49
     }
50 50
 
51
-    if ( true === $sort ) {
52
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
51
+    if (true === $sort) {
52
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
53 53
         
54 54
         // Reorder our gateways so the default is first
55 55
         $default_gateway_id = wpinv_get_default_gateway();
56 56
 
57
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
58
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
59
-            unset( $gateway_list[ $default_gateway_id ] );
57
+        if (wpinv_is_gateway_active($default_gateway_id)) {
58
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
59
+            unset($gateway_list[$default_gateway_id]);
60 60
 
61
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
61
+            $gateway_list = array_merge($default_gateway, $gateway_list);
62 62
         }
63 63
     }
64 64
 
65
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
65
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
66 66
 }
67 67
 
68
-function wpinv_sort_gateway_order( $a, $b ) {
68
+function wpinv_sort_gateway_order($a, $b) {
69 69
     return $a['ordering'] - $b['ordering'];
70 70
 }
71 71
 
72
-function wpinv_is_gateway_active( $gateway ) {
72
+function wpinv_is_gateway_active($gateway) {
73 73
     $gateways = wpinv_get_enabled_payment_gateways();
74 74
 
75
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
75
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
76 76
 
77
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
77
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
78 78
 }
79 79
 
80 80
 function wpinv_get_default_gateway() {
81
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
81
+    $default = wpinv_get_option('default_gateway', 'paypal');
82 82
 
83
-    if ( !wpinv_is_gateway_active( $default ) ) {
83
+    if (!wpinv_is_gateway_active($default)) {
84 84
         $gateways = wpinv_get_enabled_payment_gateways();
85
-        $gateways = array_keys( $gateways );
86
-        $default  = reset( $gateways );
85
+        $gateways = array_keys($gateways);
86
+        $default  = reset($gateways);
87 87
     }
88 88
 
89
-    return apply_filters( 'wpinv_default_gateway', $default );
89
+    return apply_filters('wpinv_default_gateway', $default);
90 90
 }
91 91
 
92
-function wpinv_get_gateway_admin_label( $gateway ) {
92
+function wpinv_get_gateway_admin_label($gateway) {
93 93
     $gateways = wpinv_get_payment_gateways();
94
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
95
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
94
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
95
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
96 96
 
97
-    if( $gateway == 'manual' && $payment ) {
98
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
99
-            $label = __( 'Free Purchase', 'invoicing' );
97
+    if ($gateway == 'manual' && $payment) {
98
+        if (!((float) wpinv_payment_total($payment) > 0)) {
99
+            $label = __('Free Purchase', 'invoicing');
100 100
         }
101 101
     }
102 102
 
103
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
103
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
104 104
 }
105 105
 
106
-function wpinv_get_gateway_description( $gateway ) {
106
+function wpinv_get_gateway_description($gateway) {
107 107
     global $wpinv_options;
108 108
 
109
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
109
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
110 110
 
111
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
111
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
112 112
 }
113 113
 
114
-function wpinv_get_gateway_button_label( $gateway ) {
115
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
114
+function wpinv_get_gateway_button_label($gateway) {
115
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
116 116
 }
117 117
 
118
-function wpinv_get_gateway_checkout_label( $gateway ) {
118
+function wpinv_get_gateway_checkout_label($gateway) {
119 119
     $gateways = wpinv_get_payment_gateways();
120
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
120
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
121 121
 
122
-    if ( $gateway == 'none' ) {
123
-        $label = __( 'None', 'invoicing' );
122
+    if ($gateway == 'none') {
123
+        $label = __('None', 'invoicing');
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
126
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
127 127
 }
128 128
 
129
-function wpinv_settings_sections_gateways( $settings ) {
129
+function wpinv_settings_sections_gateways($settings) {
130 130
     $gateways = wpinv_get_payment_gateways();
131 131
     
132 132
     if (!empty($gateways)) {
133
-        foreach  ($gateways as $key => $gateway) {
133
+        foreach ($gateways as $key => $gateway) {
134 134
             $settings[$key] = $gateway['admin_label'];
135 135
         }
136 136
     }
137 137
     
138 138
     return $settings;    
139 139
 }
140
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
140
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
141 141
 
142 142
 /**
143 143
  * Adds GateWay settings.
144 144
  */
145
-function wpinv_settings_gateways( $settings ) {
145
+function wpinv_settings_gateways($settings) {
146 146
 
147 147
     // Loop through each gateway.
148
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
148
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
149 149
 
150 150
         $gateway_settings = array(
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             "{$key}_header" => array(
154 154
 
155 155
                 'id'     => "{$key}_gateway_header",
156
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
156
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
157 157
                 'custom' => $key,
158 158
                 'type'   => 'gateway_header',
159 159
 
@@ -162,56 +162,56 @@  discard block
 block discarded – undo
162 162
             // Activate/Deactivate a gateway.
163 163
             "{$key}_active" => array(
164 164
                 'id'   => $key . '_active',
165
-                'name' => __( 'Activate', 'invoicing' ),
166
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
165
+                'name' => __('Activate', 'invoicing'),
166
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
167 167
                 'type' => 'checkbox',
168 168
             ),
169 169
 
170 170
             // Activate/Deactivate sandbox.
171 171
             "{$key}_sandbox" => array(
172 172
                 'id'   => $key . '_sandbox',
173
-                'name' => __( 'Sandbox', 'invoicing' ),
174
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
173
+                'name' => __('Sandbox', 'invoicing'),
174
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
175 175
                 'type' => 'checkbox',
176 176
             ),
177 177
 
178 178
             // Checkout title.
179 179
             "{$key}_title" => array(
180 180
                 'id'   => $key . '_title',
181
-                'name' => __( 'Checkout Title', 'invoicing' ),
182
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
181
+                'name' => __('Checkout Title', 'invoicing'),
182
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
183 183
                 'type' => 'text',
184 184
             ),
185 185
 
186 186
             // Checkout description.
187 187
             "{$key}_desc" => array(
188 188
                 'id'   => $key . '_desc',
189
-                'name' => __( 'Checkout Description', 'invoicing' ),
190
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
189
+                'name' => __('Checkout Description', 'invoicing'),
190
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
191 191
                 'type' => 'text',
192 192
             ),
193 193
 
194 194
             // Checkout order.
195 195
             "{$key}_ordering" => array(
196 196
                 'id'   => $key . '_ordering',
197
-                'name' => __( 'Priority', 'invoicing' ),
198
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
197
+                'name' => __('Priority', 'invoicing'),
198
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
199 199
                 'type' => 'number',
200 200
                 'step' => '1',
201 201
                 'min'  => '-100000',
202 202
                 'max'  => '100000',
203
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
203
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
204 204
             ),
205 205
 
206 206
         );
207 207
 
208 208
         // Maybe remove the sandbox.
209
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
210
-            unset( $gateway_settings["{$key}_sandbox"] );
209
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
210
+            unset($gateway_settings["{$key}_sandbox"]);
211 211
         }
212 212
   
213
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
214
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
213
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
214
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
215 215
         
216 216
         $settings[$key] = $gateway_settings;
217 217
     }
@@ -219,57 +219,57 @@  discard block
 block discarded – undo
219 219
     return $settings;
220 220
 
221 221
 }
222
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
222
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
223 223
 
224
-function wpinv_gateway_header_callback( $args ) {
225
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
224
+function wpinv_gateway_header_callback($args) {
225
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
226 226
 }
227 227
 
228
-function wpinv_get_gateway_supports( $gateway ) {
228
+function wpinv_get_gateway_supports($gateway) {
229 229
     $gateways = wpinv_get_enabled_payment_gateways();
230
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
231
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
230
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
231
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
232 232
 }
233 233
 
234
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
235
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
234
+function wpinv_get_chosen_gateway($invoice_id = 0) {
235
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
236 236
 
237 237
     $chosen = false;
238
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
238
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
239 239
         $chosen = $invoice->get_gateway();
240 240
     }
241 241
 
242
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
242
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
243 243
 
244
-	if ( false !== $chosen ) {
245
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
244
+	if (false !== $chosen) {
245
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
246 246
 	}
247 247
 
248
-	if ( ! empty ( $chosen ) ) {
249
-		$enabled_gateway = urldecode( $chosen );
250
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
248
+	if (!empty ($chosen)) {
249
+		$enabled_gateway = urldecode($chosen);
250
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
251 251
 		$enabled_gateway = 'manual';
252 252
 	} else {
253 253
 		$enabled_gateway = wpinv_get_default_gateway();
254 254
 	}
255 255
     
256
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
257
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
256
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
257
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
258 258
             $enabled_gateway = wpinv_get_default_gateway();
259
-        }else{
259
+        } else {
260 260
             $enabled_gateway = $gateways[0];
261 261
         }
262 262
 
263 263
     }
264 264
 
265
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
265
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
266 266
 }
267 267
 
268
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
269
-    return wpinv_error_log( $message, $title );
268
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
269
+    return wpinv_error_log($message, $title);
270 270
 }
271 271
 
272
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
272
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
273 273
 	$ret  = 0;
274 274
 	$args = array(
275 275
 		'meta_key'    => '_wpinv_gateway',
@@ -280,48 +280,48 @@  discard block
 block discarded – undo
280 280
 		'fields'      => 'ids'
281 281
 	);
282 282
 
283
-	$payments = new WP_Query( $args );
283
+	$payments = new WP_Query($args);
284 284
 
285
-	if( $payments )
285
+	if ($payments)
286 286
 		$ret = $payments->post_count;
287 287
 	return $ret;
288 288
 }
289 289
 
290
-function wpinv_settings_update_gateways( $input ) {
290
+function wpinv_settings_update_gateways($input) {
291 291
     global $wpinv_options;
292 292
     
293
-    if ( !empty( $input['save_gateway'] ) ) {
294
-        $gateways = wpinv_get_option( 'gateways', false );
293
+    if (!empty($input['save_gateway'])) {
294
+        $gateways = wpinv_get_option('gateways', false);
295 295
         $gateways = !empty($gateways) ? $gateways : array();
296 296
         $gateway = $input['save_gateway'];
297 297
         
298
-        if ( !empty( $input[$gateway . '_active'] ) ) {
298
+        if (!empty($input[$gateway . '_active'])) {
299 299
             $gateways[$gateway] = 1;
300 300
         } else {
301
-            if ( isset( $gateways[$gateway] ) ) {
302
-                unset( $gateways[$gateway] );
301
+            if (isset($gateways[$gateway])) {
302
+                unset($gateways[$gateway]);
303 303
             }
304 304
         }
305 305
         
306 306
         $input['gateways'] = $gateways;
307 307
     }
308 308
     
309
-    if ( !empty( $input['default_gateway'] ) ) {
309
+    if (!empty($input['default_gateway'])) {
310 310
         $gateways = wpinv_get_payment_gateways();
311 311
         
312
-        foreach ( $gateways as $key => $gateway ) {
313
-            $active   = 0;
314
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
312
+        foreach ($gateways as $key => $gateway) {
313
+            $active = 0;
314
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
315 315
                 $active = 1;
316 316
             }
317 317
             
318 318
             $input[$key . '_active'] = $active;
319 319
             
320
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
320
+            if (empty($wpinv_options[$key . '_title'])) {
321 321
                 $input[$key . '_title'] = $gateway['checkout_label'];
322 322
             }
323 323
             
324
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
324
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
325 325
                 $input[$key . '_ordering'] = $gateway['ordering'];
326 326
             }
327 327
         }
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
     
330 330
     return $input;
331 331
 }
332
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
332
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
333 333
 
334 334
 // PayPal Standard settings
335
-function wpinv_gateway_settings_paypal( $setting ) {    
336
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
337
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
335
+function wpinv_gateway_settings_paypal($setting) {    
336
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
337
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
338 338
     
339 339
     $setting['paypal_sandbox'] = array(
340 340
             'type' => 'checkbox',
341 341
             'id'   => 'paypal_sandbox',
342
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
343
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
342
+            'name' => __('PayPal Sandbox', 'invoicing'),
343
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
344 344
             'std'  => 1
345 345
         );
346 346
         
347 347
     $setting['paypal_email'] = array(
348 348
             'type' => 'text',
349 349
             'id'   => 'paypal_email',
350
-            'name' => __( 'PayPal Email', 'invoicing' ),
351
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
352
-            'std' => __( '[email protected]', 'invoicing' ),
350
+            'name' => __('PayPal Email', 'invoicing'),
351
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
352
+            'std' => __('[email protected]', 'invoicing'),
353 353
         );
354 354
     /*
355 355
     $setting['paypal_ipn_url'] = array(
@@ -363,18 +363,18 @@  discard block
 block discarded – undo
363 363
         
364 364
     return $setting;
365 365
 }
366
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
366
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
367 367
 
368 368
 /**
369 369
  * Displays the ipn url field.
370 370
  */
371
-function wpinv_ipn_url_callback( $args ) {
372
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
371
+function wpinv_ipn_url_callback($args) {
372
+    $sanitize_id = wpinv_sanitize_key($args['id']);
373 373
     
374 374
     $attrs = $args['readonly'] ? ' readonly' : '';
375 375
 
376
-    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
377
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
376
+    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
377
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
378 378
 
379 379
     echo $html;
380 380
 }
@@ -386,9 +386,9 @@  discard block
 block discarded – undo
386 386
  * 
387 387
  * @return bool
388 388
  */
389
-function wpinv_is_test_mode( $gateway = '' ) {
390
-    $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false );
391
-    return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway );
389
+function wpinv_is_test_mode($gateway = '') {
390
+    $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false);
391
+    return apply_filters('wpinv_is_test_mode', $sandbox, $gateway);
392 392
 }
393 393
 
394 394
 /**
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
  * 
400 400
  * @return string
401 401
  */
402
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
402
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
403 403
     $args = wp_parse_args(
404 404
         array(
405 405
             'wpi-listener' => 'IPN',
@@ -408,37 +408,37 @@  discard block
 block discarded – undo
408 408
         $args
409 409
     );
410 410
 
411
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
411
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
412 412
 
413 413
 }
414 414
 
415 415
 /**
416 416
  * Retrieves request data with slashes removed slashes.
417 417
  */
418
-function wpinv_get_post_data( $method = 'request' ) {
418
+function wpinv_get_post_data($method = 'request') {
419 419
 
420
-    if ( $method == 'post' ) {
421
-        return wp_unslash( $_POST );
420
+    if ($method == 'post') {
421
+        return wp_unslash($_POST);
422 422
     }
423 423
 
424
-    if ( $method == 'get' ) {
425
-        return wp_unslash( $_GET );
424
+    if ($method == 'get') {
425
+        return wp_unslash($_GET);
426 426
     }
427 427
 
428
-    return wp_unslash( $_REQUEST );
428
+    return wp_unslash($_REQUEST);
429 429
   
430 430
 }
431 431
 
432 432
 /**
433 433
  * Checks if a given gateway supports subscription payments.
434 434
  */
435
-function wpinv_gateway_support_subscription( $gateway ) {
435
+function wpinv_gateway_support_subscription($gateway) {
436 436
     $supports = false;
437 437
 
438
-    if ( wpinv_is_gateway_active( $gateway ) ) {
439
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
438
+    if (wpinv_is_gateway_active($gateway)) {
439
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
440 440
 
441
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
441
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
442 442
     }
443 443
 
444 444
     return $supports;
@@ -450,14 +450,14 @@  discard block
 block discarded – undo
450 450
  * @param array $gateways an array of gateways.
451 451
  * @param GetPaid_Payment_Form $form payment form.
452 452
  */
453
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
453
+function wpinv_payment_gateways_on_cart($gateways, $form) {
454 454
 
455
-    if ( $form->is_recurring() ) {
455
+    if ($form->is_recurring()) {
456 456
 
457
-        foreach ( array_keys( $gateways ) as $gateway ) {
457
+        foreach (array_keys($gateways) as $gateway) {
458 458
 
459
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
460
-                unset( $gateways[$gateway] );
459
+            if (!wpinv_gateway_support_subscription($gateway)) {
460
+                unset($gateways[$gateway]);
461 461
             }
462 462
 
463 463
         }
@@ -466,4 +466,4 @@  discard block
 block discarded – undo
466 466
 
467 467
     return $gateways;
468 468
 }
469
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
469
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
Please login to merge, or discard this patch.
includes/wpinv-discount-functions.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -887,8 +887,8 @@
 block discarded – undo
887 887
     if ( !empty( $data ) && isset( $data['cart_discounts'] ) ) {
888 888
         unset( $data['cart_discounts'] );
889 889
         
890
-         wpinv_set_checkout_session( $data );
891
-         return true;
890
+            wpinv_set_checkout_session( $data );
891
+            return true;
892 892
     }
893 893
     
894 894
     return false;
Please login to merge, or discard this patch.
Spacing   +284 added lines, -284 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
  * Returns an array of discount type.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
     return apply_filters(
18 18
         'wpinv_discount_types',
19 19
         array(
20
-            'percent'   => __( 'Percentage', 'invoicing' ),
21
-            'flat'     => __( 'Flat Amount', 'invoicing' ),
20
+            'percent'   => __('Percentage', 'invoicing'),
21
+            'flat'     => __('Flat Amount', 'invoicing'),
22 22
         )
23 23
     );
24 24
 }
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
  * 
29 29
  * @return string
30 30
  */
31
-function wpinv_get_discount_type_name( $type = '' ) {
31
+function wpinv_get_discount_type_name($type = '') {
32 32
     $types = wpinv_get_discount_types();
33
-    return isset( $types[ $type ] ) ? $types[ $type ] : $type;
33
+    return isset($types[$type]) ? $types[$type] : $type;
34 34
 }
35 35
 
36 36
 /**
@@ -38,94 +38,94 @@  discard block
 block discarded – undo
38 38
  * 
39 39
  * @return string
40 40
  */
41
-function wpinv_delete_discount( $data ) {
41
+function wpinv_delete_discount($data) {
42 42
 
43
-    if ( ! isset( $data['_wpnonce'] ) || ! wp_verify_nonce( $data['_wpnonce'], 'wpinv_discount_nonce' ) ) {
43
+    if (!isset($data['_wpnonce']) || !wp_verify_nonce($data['_wpnonce'], 'wpinv_discount_nonce')) {
44 44
         exit;
45 45
     }
46 46
 
47
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
48
-        wp_die( __( 'You do not have permission to delete discount codes', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
47
+    if (!wpinv_current_user_can_manage_invoicing()) {
48
+        wp_die(__('You do not have permission to delete discount codes', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
49 49
     }
50 50
 
51 51
     $discount_id = $data['discount'];
52
-    wpinv_remove_discount( $discount_id );
52
+    wpinv_remove_discount($discount_id);
53 53
 }
54
-add_action( 'wpinv_delete_discount', 'wpinv_delete_discount' );
54
+add_action('wpinv_delete_discount', 'wpinv_delete_discount');
55 55
 
56
-function wpinv_activate_discount( $data ) {
57
-    if ( ! isset( $data['_wpnonce'] ) || ! wp_verify_nonce( $data['_wpnonce'], 'wpinv_discount_nonce' ) ) {
58
-        wp_die( __( 'Trying to cheat or something?', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
56
+function wpinv_activate_discount($data) {
57
+    if (!isset($data['_wpnonce']) || !wp_verify_nonce($data['_wpnonce'], 'wpinv_discount_nonce')) {
58
+        wp_die(__('Trying to cheat or something?', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
59 59
     }
60 60
 
61
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
62
-        wp_die( __( 'You do not have permission to edit discount codes', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
61
+    if (!wpinv_current_user_can_manage_invoicing()) {
62
+        wp_die(__('You do not have permission to edit discount codes', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
63 63
     }
64 64
 
65
-    $id = absint( $data['discount'] );
66
-    wpinv_update_discount_status( $id, 'publish' );
65
+    $id = absint($data['discount']);
66
+    wpinv_update_discount_status($id, 'publish');
67 67
 }
68
-add_action( 'wpinv_activate_discount', 'wpinv_activate_discount' );
68
+add_action('wpinv_activate_discount', 'wpinv_activate_discount');
69 69
 
70
-function wpinv_deactivate_discount( $data ) {
71
-    if ( ! isset( $data['_wpnonce'] ) || ! wp_verify_nonce( $data['_wpnonce'], 'wpinv_discount_nonce' ) ) {
72
-        wp_die( __( 'Trying to cheat or something?', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
70
+function wpinv_deactivate_discount($data) {
71
+    if (!isset($data['_wpnonce']) || !wp_verify_nonce($data['_wpnonce'], 'wpinv_discount_nonce')) {
72
+        wp_die(__('Trying to cheat or something?', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
73 73
     }
74 74
 
75
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
76
-        wp_die( __( 'You do not have permission to create discount codes', 'invoicing' ), array( 'response' => 403 ) );
75
+    if (!wpinv_current_user_can_manage_invoicing()) {
76
+        wp_die(__('You do not have permission to create discount codes', 'invoicing'), array('response' => 403));
77 77
     }
78 78
 
79
-    $id = absint( $data['discount'] );
80
-    wpinv_update_discount_status( $id, 'pending' );
79
+    $id = absint($data['discount']);
80
+    wpinv_update_discount_status($id, 'pending');
81 81
 }
82
-add_action( 'wpinv_deactivate_discount', 'wpinv_deactivate_discount' );
82
+add_action('wpinv_deactivate_discount', 'wpinv_deactivate_discount');
83 83
 
84
-function wpinv_get_discounts( $args = array() ) {
84
+function wpinv_get_discounts($args = array()) {
85 85
     $defaults = array(
86 86
         'post_type'      => 'wpi_discount',
87 87
         'posts_per_page' => 20,
88 88
         'paged'          => null,
89
-        'post_status'    => array( 'publish', 'pending', 'draft', 'expired' )
89
+        'post_status'    => array('publish', 'pending', 'draft', 'expired')
90 90
     );
91 91
 
92
-    $args = wp_parse_args( $args, $defaults );
92
+    $args = wp_parse_args($args, $defaults);
93 93
 
94
-    $discounts = get_posts( $args );
94
+    $discounts = get_posts($args);
95 95
 
96
-    if ( $discounts ) {
96
+    if ($discounts) {
97 97
         return $discounts;
98 98
     }
99 99
 
100
-    if( ! $discounts && ! empty( $args['s'] ) ) {
100
+    if (!$discounts && !empty($args['s'])) {
101 101
         $args['meta_key']     = '_wpi_discount_code';
102 102
         $args['meta_value']   = $args['s'];
103 103
         $args['meta_compare'] = 'LIKE';
104
-        unset( $args['s'] );
105
-        $discounts = get_posts( $args );
104
+        unset($args['s']);
105
+        $discounts = get_posts($args);
106 106
     }
107 107
 
108
-    if( $discounts ) {
108
+    if ($discounts) {
109 109
         return $discounts;
110 110
     }
111 111
 
112 112
     return false;
113 113
 }
114 114
 
115
-function wpinv_get_all_discounts( $args = array() ) {
115
+function wpinv_get_all_discounts($args = array()) {
116 116
 
117
-    $args = wp_parse_args( $args, array(
118
-        'status'         => array( 'publish' ),
119
-        'limit'          => get_option( 'posts_per_page' ),
117
+    $args = wp_parse_args($args, array(
118
+        'status'         => array('publish'),
119
+        'limit'          => get_option('posts_per_page'),
120 120
         'page'           => 1,
121 121
         'exclude'        => array(),
122 122
         'orderby'        => 'date',
123 123
         'order'          => 'DESC',
124
-        'type'           => array_keys( wpinv_get_discount_types() ),
124
+        'type'           => array_keys(wpinv_get_discount_types()),
125 125
         'meta_query'     => array(),
126 126
         'return'         => 'objects',
127 127
         'paginate'       => false,
128
-    ) );
128
+    ));
129 129
 
130 130
     $wp_query_args = array(
131 131
         'post_type'      => 'wpi_discount',
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
         'fields'         => 'ids',
136 136
         'orderby'        => $args['orderby'],
137 137
         'order'          => $args['order'],
138
-        'paged'          => absint( $args['page'] ),
138
+        'paged'          => absint($args['page']),
139 139
     );
140 140
 
141
-    if ( ! empty( $args['exclude'] ) ) {
142
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
141
+    if (!empty($args['exclude'])) {
142
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
143 143
     }
144 144
 
145
-    if ( ! $args['paginate' ] ) {
145
+    if (!$args['paginate']) {
146 146
         $wp_query_args['no_found_rows'] = true;
147 147
     }
148 148
 
149
-    if ( ! empty( $args['search'] ) ) {
149
+    if (!empty($args['search'])) {
150 150
 
151 151
         $wp_query_args['meta_query'][] = array(
152 152
             'key'     => '_wpi_discount_code',
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
 
157 157
     }
158 158
 
159
-    if ( ! empty( $args['type'] ) ) {
160
-        $types = wpinv_parse_list( $args['type'] );
159
+    if (!empty($args['type'])) {
160
+        $types = wpinv_parse_list($args['type']);
161 161
         $wp_query_args['meta_query'][] = array(
162 162
             'key'     => '_wpi_discount_type',
163
-            'value'   => implode( ',', $types ),
163
+            'value'   => implode(',', $types),
164 164
             'compare' => 'IN',
165 165
         );
166 166
     }
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
     $wp_query_args = apply_filters('wpinv_get_discount_args', $wp_query_args, $args);
169 169
 
170 170
     // Get results.
171
-    $discounts = new WP_Query( $wp_query_args );
171
+    $discounts = new WP_Query($wp_query_args);
172 172
 
173
-    if ( 'objects' === $args['return'] ) {
174
-        $return = array_map( 'get_post', $discounts->posts );
175
-    } elseif ( 'self' === $args['return'] ) {
173
+    if ('objects' === $args['return']) {
174
+        $return = array_map('get_post', $discounts->posts);
175
+    } elseif ('self' === $args['return']) {
176 176
         return $discounts;
177 177
     } else {
178 178
         $return = $discounts->posts;
179 179
     }
180 180
 
181
-    if ( $args['paginate' ] ) {
181
+    if ($args['paginate']) {
182 182
         return (object) array(
183 183
             'discounts'      => $return,
184 184
             'total'         => $discounts->found_posts,
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 
196 196
     $discounts  = wpinv_get_discounts();
197 197
 
198
-    if ( $discounts) {
199
-        foreach ( $discounts as $discount ) {
200
-            if ( wpinv_is_discount_active( $discount->ID, true ) ) {
198
+    if ($discounts) {
199
+        foreach ($discounts as $discount) {
200
+            if (wpinv_is_discount_active($discount->ID, true)) {
201 201
                 $has_active = true;
202 202
                 break;
203 203
             }
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
     return $has_active;
207 207
 }
208 208
 
209
-function wpinv_get_discount( $discount_id = 0 ) {
210
-    if( empty( $discount_id ) ) {
209
+function wpinv_get_discount($discount_id = 0) {
210
+    if (empty($discount_id)) {
211 211
         return false;
212 212
     }
213 213
 
214
-    if ( get_post_type( $discount_id ) != 'wpi_discount' ) {
214
+    if (get_post_type($discount_id) != 'wpi_discount') {
215 215
         return false;
216 216
     }
217 217
 
218
-    $discount = get_post( $discount_id );
218
+    $discount = get_post($discount_id);
219 219
 
220 220
     return $discount;
221 221
 }
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
  * @since 1.0.15
228 228
  * @return WPInv_Discount
229 229
  */
230
-function wpinv_get_discount_obj( $discount = 0 ) {
231
-    return new WPInv_Discount( $discount );
230
+function wpinv_get_discount_obj($discount = 0) {
231
+    return new WPInv_Discount($discount);
232 232
 }
233 233
 
234 234
 /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
  * @param string $code The discount code.
238 238
  * @return bool|WPInv_Discount
239 239
  */
240
-function wpinv_get_discount_by_code( $code = '' ) {
241
-    return wpinv_get_discount_by( null, $code );
240
+function wpinv_get_discount_by_code($code = '') {
241
+    return wpinv_get_discount_by(null, $code);
242 242
 }
243 243
 
244 244
 /**
@@ -248,10 +248,10 @@  discard block
 block discarded – undo
248 248
  * @param string|int $value The field value
249 249
  * @return bool|WPInv_Discount
250 250
  */
251
-function wpinv_get_discount_by( $deprecated = null, $value = '' ) {
252
-    $discount = new WPInv_Discount( $value );
251
+function wpinv_get_discount_by($deprecated = null, $value = '') {
252
+    $discount = new WPInv_Discount($value);
253 253
 
254
-    if ( $discount->get_id() != 0 ) {
254
+    if ($discount->get_id() != 0) {
255 255
         return $discount;
256 256
     }
257 257
 
@@ -265,68 +265,68 @@  discard block
 block discarded – undo
265 265
  * @param array $data The discount's properties.
266 266
  * @return bool
267 267
  */
268
-function wpinv_store_discount( $post_id, $data, $post, $update = false ) {
268
+function wpinv_store_discount($post_id, $data, $post, $update = false) {
269 269
     $meta = array(
270
-        'code'              => isset( $data['code'] )             ? sanitize_text_field( $data['code'] )              : '',
271
-        'type'              => isset( $data['type'] )             ? sanitize_text_field( $data['type'] )              : 'percent',
272
-        'amount'            => isset( $data['amount'] )           ? wpinv_sanitize_amount( $data['amount'] )          : '',
273
-        'start'             => isset( $data['start'] )            ? sanitize_text_field( $data['start'] )             : '',
274
-        'expiration'        => isset( $data['expiration'] )       ? sanitize_text_field( $data['expiration'] )        : '',
275
-        'min_total'         => isset( $data['min_total'] )        ? wpinv_sanitize_amount( $data['min_total'] )       : '',
276
-        'max_total'         => isset( $data['max_total'] )        ? wpinv_sanitize_amount( $data['max_total'] )       : '',
277
-        'max_uses'          => isset( $data['max_uses'] )         ? absint( $data['max_uses'] )                       : '',
278
-        'items'             => isset( $data['items'] )            ? $data['items']                                    : array(),
279
-        'excluded_items'    => isset( $data['excluded_items'] )   ? $data['excluded_items']                           : array(),
280
-        'is_recurring'      => isset( $data['recurring'] )        ? (bool)$data['recurring']                          : false,
281
-        'is_single_use'     => isset( $data['single_use'] )       ? (bool)$data['single_use']                         : false,
282
-        'uses'              => isset( $data['uses'] )             ? (int)$data['uses']                                : false,
270
+        'code'              => isset($data['code']) ? sanitize_text_field($data['code']) : '',
271
+        'type'              => isset($data['type']) ? sanitize_text_field($data['type']) : 'percent',
272
+        'amount'            => isset($data['amount']) ? wpinv_sanitize_amount($data['amount']) : '',
273
+        'start'             => isset($data['start']) ? sanitize_text_field($data['start']) : '',
274
+        'expiration'        => isset($data['expiration']) ? sanitize_text_field($data['expiration']) : '',
275
+        'min_total'         => isset($data['min_total']) ? wpinv_sanitize_amount($data['min_total']) : '',
276
+        'max_total'         => isset($data['max_total']) ? wpinv_sanitize_amount($data['max_total']) : '',
277
+        'max_uses'          => isset($data['max_uses']) ? absint($data['max_uses']) : '',
278
+        'items'             => isset($data['items']) ? $data['items'] : array(),
279
+        'excluded_items'    => isset($data['excluded_items']) ? $data['excluded_items'] : array(),
280
+        'is_recurring'      => isset($data['recurring']) ? (bool) $data['recurring'] : false,
281
+        'is_single_use'     => isset($data['single_use']) ? (bool) $data['single_use'] : false,
282
+        'uses'              => isset($data['uses']) ? (int) $data['uses'] : false,
283 283
     );
284 284
 
285
-    if ( $meta['type'] == 'percent' && (float)$meta['amount'] > 100 ) {
285
+    if ($meta['type'] == 'percent' && (float) $meta['amount'] > 100) {
286 286
         $meta['amount'] = 100;
287 287
     }
288 288
 
289
-    if ( !empty( $meta['start'] ) ) {
290
-        $meta['start']      = date_i18n( 'Y-m-d H:i:s', strtotime( $meta['start'] ) );
289
+    if (!empty($meta['start'])) {
290
+        $meta['start'] = date_i18n('Y-m-d H:i:s', strtotime($meta['start']));
291 291
     }
292 292
 
293
-    if ( !empty( $meta['expiration'] ) ) {
294
-        $meta['expiration'] = date_i18n( 'Y-m-d H:i:s', strtotime( $meta['expiration'] ) );
293
+    if (!empty($meta['expiration'])) {
294
+        $meta['expiration'] = date_i18n('Y-m-d H:i:s', strtotime($meta['expiration']));
295 295
 
296
-        if ( !empty( $meta['start'] ) && strtotime( $meta['start'] ) > strtotime( $meta['expiration'] ) ) {
296
+        if (!empty($meta['start']) && strtotime($meta['start']) > strtotime($meta['expiration'])) {
297 297
             $meta['expiration'] = $meta['start'];
298 298
         }
299 299
     }
300 300
 
301
-    if ( $meta['uses'] === false ) {
302
-        unset( $meta['uses'] );
301
+    if ($meta['uses'] === false) {
302
+        unset($meta['uses']);
303 303
     }
304 304
 
305
-    if ( ! empty( $meta['items'] ) ) {
306
-        foreach ( $meta['items'] as $key => $item ) {
307
-            if ( 0 === intval( $item ) ) {
308
-                unset( $meta['items'][ $key ] );
305
+    if (!empty($meta['items'])) {
306
+        foreach ($meta['items'] as $key => $item) {
307
+            if (0 === intval($item)) {
308
+                unset($meta['items'][$key]);
309 309
             }
310 310
         }
311 311
     }
312 312
 
313
-    if ( ! empty( $meta['excluded_items'] ) ) {
314
-        foreach ( $meta['excluded_items'] as $key => $item ) {
315
-            if ( 0 === intval( $item ) ) {
316
-                unset( $meta['excluded_items'][ $key ] );
313
+    if (!empty($meta['excluded_items'])) {
314
+        foreach ($meta['excluded_items'] as $key => $item) {
315
+            if (0 === intval($item)) {
316
+                unset($meta['excluded_items'][$key]);
317 317
             }
318 318
         }
319 319
     }
320 320
 
321
-    $meta = apply_filters( 'wpinv_update_discount', $meta, $post_id, $post );
321
+    $meta = apply_filters('wpinv_update_discount', $meta, $post_id, $post);
322 322
 
323
-    do_action( 'wpinv_pre_update_discount', $meta, $post_id, $post );
323
+    do_action('wpinv_pre_update_discount', $meta, $post_id, $post);
324 324
 
325
-    foreach( $meta as $key => $value ) {
326
-        update_post_meta( $post_id, '_wpi_discount_' . $key, $value );
325
+    foreach ($meta as $key => $value) {
326
+        update_post_meta($post_id, '_wpi_discount_' . $key, $value);
327 327
     }
328 328
 
329
-    do_action( 'wpinv_post_update_discount', $meta, $post_id, $post );
329
+    do_action('wpinv_post_update_discount', $meta, $post_id, $post);
330 330
 
331 331
     return $post_id;
332 332
 }
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
338 338
  * @return bool
339 339
  */
340
-function wpinv_remove_discount( $discount = 0 ) {
340
+function wpinv_remove_discount($discount = 0) {
341 341
 
342
-    $discount = wpinv_get_discount_obj( $discount );
343
-    if( ! $discount->exists() ) {
342
+    $discount = wpinv_get_discount_obj($discount);
343
+    if (!$discount->exists()) {
344 344
         return false;
345 345
     }
346 346
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
  * @param string $new_status
356 356
  * @return bool
357 357
  */
358
-function wpinv_update_discount_status( $discount = 0, $new_status = 'publish' ) {
359
-    $discount = wpinv_get_discount_obj( $discount );
360
-    return $discount->update_status( $new_status );
358
+function wpinv_update_discount_status($discount = 0, $new_status = 'publish') {
359
+    $discount = wpinv_get_discount_obj($discount);
360
+    return $discount->update_status($new_status);
361 361
 }
362 362
 
363 363
 /**
@@ -366,48 +366,48 @@  discard block
 block discarded – undo
366 366
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
367 367
  * @return bool
368 368
  */
369
-function wpinv_discount_exists( $discount ) {
370
-    $discount = wpinv_get_discount_obj( $discount );
369
+function wpinv_discount_exists($discount) {
370
+    $discount = wpinv_get_discount_obj($discount);
371 371
     return $discount->exists();
372 372
 }
373 373
 
374
-function wpinv_is_discount_active( $code_id = null, $silent = false ) {
375
-    $discount = wpinv_get_discount(  $code_id );
374
+function wpinv_is_discount_active($code_id = null, $silent = false) {
375
+    $discount = wpinv_get_discount($code_id);
376 376
     $return   = false;
377 377
 
378
-    if ( $discount ) {
379
-        if ( wpinv_is_discount_expired( $code_id, $silent ) ) {
380
-            if( defined( 'DOING_AJAX' ) && ! $silent ) {
381
-                wpinv_set_error( 'wpinv-discount-error', __( 'This discount is expired.', 'invoicing' ) );
378
+    if ($discount) {
379
+        if (wpinv_is_discount_expired($code_id, $silent)) {
380
+            if (defined('DOING_AJAX') && !$silent) {
381
+                wpinv_set_error('wpinv-discount-error', __('This discount is expired.', 'invoicing'));
382 382
             }
383
-        } elseif ( $discount->post_status == 'publish' ) {
383
+        } elseif ($discount->post_status == 'publish') {
384 384
             $return = true;
385 385
         } else {
386
-            if( defined( 'DOING_AJAX' ) && ! $silent ) {
387
-                wpinv_set_error( 'wpinv-discount-error', __( 'This discount is not active.', 'invoicing' ) );
386
+            if (defined('DOING_AJAX') && !$silent) {
387
+                wpinv_set_error('wpinv-discount-error', __('This discount is not active.', 'invoicing'));
388 388
             }
389 389
         }
390 390
     }
391 391
 
392
-    return apply_filters( 'wpinv_is_discount_active', $return, $code_id );
392
+    return apply_filters('wpinv_is_discount_active', $return, $code_id);
393 393
 }
394 394
 
395
-function wpinv_get_discount_code( $code_id = null ) {
396
-    $code = get_post_meta( $code_id, '_wpi_discount_code', true );
395
+function wpinv_get_discount_code($code_id = null) {
396
+    $code = get_post_meta($code_id, '_wpi_discount_code', true);
397 397
 
398
-    return apply_filters( 'wpinv_get_discount_code', $code, $code_id );
398
+    return apply_filters('wpinv_get_discount_code', $code, $code_id);
399 399
 }
400 400
 
401
-function wpinv_get_discount_start_date( $code_id = null ) {
402
-    $start_date = get_post_meta( $code_id, '_wpi_discount_start', true );
401
+function wpinv_get_discount_start_date($code_id = null) {
402
+    $start_date = get_post_meta($code_id, '_wpi_discount_start', true);
403 403
 
404
-    return apply_filters( 'wpinv_get_discount_start_date', $start_date, $code_id );
404
+    return apply_filters('wpinv_get_discount_start_date', $start_date, $code_id);
405 405
 }
406 406
 
407
-function wpinv_get_discount_expiration( $code_id = null ) {
408
-    $expiration = get_post_meta( $code_id, '_wpi_discount_expiration', true );
407
+function wpinv_get_discount_expiration($code_id = null) {
408
+    $expiration = get_post_meta($code_id, '_wpi_discount_expiration', true);
409 409
 
410
-    return apply_filters( 'wpinv_get_discount_expiration', $expiration, $code_id );
410
+    return apply_filters('wpinv_get_discount_expiration', $expiration, $code_id);
411 411
 }
412 412
 
413 413
 /**
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
417 417
  * @return int
418 418
  */
419
-function wpinv_get_discount_max_uses( $discount = array() ) {
420
-    $discount = wpinv_get_discount_obj( $discount );
419
+function wpinv_get_discount_max_uses($discount = array()) {
420
+    $discount = wpinv_get_discount_obj($discount);
421 421
     return (int) $discount->max_uses;
422 422
 }
423 423
 
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
428 428
  * @return int
429 429
  */
430
-function wpinv_get_discount_uses( $discount = array() ) {
431
-    $discount = wpinv_get_discount_obj( $discount );
430
+function wpinv_get_discount_uses($discount = array()) {
431
+    $discount = wpinv_get_discount_obj($discount);
432 432
     return (int) $discount->uses;
433 433
 }
434 434
 
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
439 439
  * @return float
440 440
  */
441
-function wpinv_get_discount_min_total( $discount = array() ) {
442
-    $discount = wpinv_get_discount_obj( $discount );
441
+function wpinv_get_discount_min_total($discount = array()) {
442
+    $discount = wpinv_get_discount_obj($discount);
443 443
     return (float) $discount->min_total;
444 444
 }
445 445
 
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
450 450
  * @return float
451 451
  */
452
-function wpinv_get_discount_max_total( $discount = array() ) {
453
-    $discount = wpinv_get_discount_obj( $discount );
452
+function wpinv_get_discount_max_total($discount = array()) {
453
+    $discount = wpinv_get_discount_obj($discount);
454 454
     return (float) $discount->max_total;
455 455
 }
456 456
 
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
461 461
  * @return float
462 462
  */
463
-function wpinv_get_discount_amount( $discount = array() ) {
464
-    $discount = wpinv_get_discount_obj( $discount );
463
+function wpinv_get_discount_amount($discount = array()) {
464
+    $discount = wpinv_get_discount_obj($discount);
465 465
     return (float) $discount->amount;
466 466
 }
467 467
 
@@ -472,28 +472,28 @@  discard block
 block discarded – undo
472 472
  * @param bool $name
473 473
  * @return string
474 474
  */
475
-function wpinv_get_discount_type( $discount = array(), $name = false ) {
476
-    $discount = wpinv_get_discount_obj( $discount );
475
+function wpinv_get_discount_type($discount = array(), $name = false) {
476
+    $discount = wpinv_get_discount_obj($discount);
477 477
 
478 478
     // Are we returning the name or just the type.
479
-    if( $name ) {
479
+    if ($name) {
480 480
         return $discount->type_name;
481 481
     }
482 482
 
483 483
     return $discount->type;
484 484
 }
485 485
 
486
-function wpinv_discount_status( $status ) {
487
-    switch( $status ){
486
+function wpinv_discount_status($status) {
487
+    switch ($status) {
488 488
         case 'expired' :
489
-            $name = __( 'Expired', 'invoicing' );
489
+            $name = __('Expired', 'invoicing');
490 490
             break;
491 491
         case 'publish' :
492 492
         case 'active' :
493
-            $name = __( 'Active', 'invoicing' );
493
+            $name = __('Active', 'invoicing');
494 494
             break;
495 495
         default :
496
-            $name = __( 'Inactive', 'invoicing' );
496
+            $name = __('Inactive', 'invoicing');
497 497
             break;
498 498
     }
499 499
     return $name;
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
506 506
  * @return array
507 507
  */
508
-function wpinv_get_discount_excluded_items( $discount = array() ) {
509
-    $discount = wpinv_get_discount_obj( $discount );
508
+function wpinv_get_discount_excluded_items($discount = array()) {
509
+    $discount = wpinv_get_discount_obj($discount);
510 510
     return $discount->excluded_items;
511 511
 }
512 512
 
@@ -516,17 +516,17 @@  discard block
 block discarded – undo
516 516
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
517 517
  * @return array
518 518
  */
519
-function wpinv_get_discount_item_reqs( $discount = array() ) {
520
-    $discount = wpinv_get_discount_obj( $discount );
519
+function wpinv_get_discount_item_reqs($discount = array()) {
520
+    $discount = wpinv_get_discount_obj($discount);
521 521
     return $discount->items;
522 522
 }
523 523
 
524
-function wpinv_get_discount_item_condition( $code_id = 0 ) {
525
-    return get_post_meta( $code_id, '_wpi_discount_item_condition', true );
524
+function wpinv_get_discount_item_condition($code_id = 0) {
525
+    return get_post_meta($code_id, '_wpi_discount_item_condition', true);
526 526
 }
527 527
 
528
-function wpinv_is_discount_not_global( $code_id = 0 ) {
529
-    return (bool) get_post_meta( $code_id, '_wpi_discount_is_not_global', true );
528
+function wpinv_is_discount_not_global($code_id = 0) {
529
+    return (bool) get_post_meta($code_id, '_wpi_discount_is_not_global', true);
530 530
 }
531 531
 
532 532
 /**
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
536 536
  * @return bool
537 537
  */
538
-function wpinv_is_discount_expired( $discount = array(), $silent = false ) {
539
-    $discount = wpinv_get_discount_obj( $discount );
538
+function wpinv_is_discount_expired($discount = array(), $silent = false) {
539
+    $discount = wpinv_get_discount_obj($discount);
540 540
 
541
-    if ( $discount->is_expired() ) {
542
-        $discount->update_status( 'pending' );
541
+    if ($discount->is_expired()) {
542
+        $discount->update_status('pending');
543 543
 
544
-        if( empty( $silent ) ) {
545
-            wpinv_set_error( 'wpinv-discount-error', __( 'This discount has expired.', 'invoicing' ) );
544
+        if (empty($silent)) {
545
+            wpinv_set_error('wpinv-discount-error', __('This discount has expired.', 'invoicing'));
546 546
         }
547 547
         return true;
548 548
     }
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
557 557
  * @return bool
558 558
  */
559
-function wpinv_is_discount_started( $discount = array() ) {
560
-    $discount = wpinv_get_discount_obj( $discount );
559
+function wpinv_is_discount_started($discount = array()) {
560
+    $discount = wpinv_get_discount_obj($discount);
561 561
     $started  = $discount->has_started();
562 562
 
563
-    if( empty( $started ) ) {
564
-        wpinv_set_error( 'wpinv-discount-error', __( 'This discount is not active yet.', 'invoicing' ) );
563
+    if (empty($started)) {
564
+        wpinv_set_error('wpinv-discount-error', __('This discount is not active yet.', 'invoicing'));
565 565
     }
566 566
 
567 567
     return $started;
@@ -573,10 +573,10 @@  discard block
 block discarded – undo
573 573
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
574 574
  * @return bool
575 575
  */
576
-function wpinv_check_discount_dates( $discount ) {
577
-    $discount = wpinv_get_discount_obj( $discount );
578
-    $return   = wpinv_is_discount_started( $discount ) && ! wpinv_is_discount_expired( $discount );
579
-    return apply_filters( 'wpinv_check_discount_dates', $return, $discount->ID, $discount, $discount->code );
576
+function wpinv_check_discount_dates($discount) {
577
+    $discount = wpinv_get_discount_obj($discount);
578
+    $return   = wpinv_is_discount_started($discount) && !wpinv_is_discount_expired($discount);
579
+    return apply_filters('wpinv_check_discount_dates', $return, $discount->ID, $discount, $discount->code);
580 580
 }
581 581
 
582 582
 /**
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
586 586
  * @return bool
587 587
  */
588
-function wpinv_is_discount_maxed_out( $discount ) {
589
-    $discount    = wpinv_get_discount_obj( $discount );
588
+function wpinv_is_discount_maxed_out($discount) {
589
+    $discount    = wpinv_get_discount_obj($discount);
590 590
     $maxed_out   = $discount->has_exceeded_limit();
591 591
 
592
-    if ( $maxed_out ) {
593
-        wpinv_set_error( 'wpinv-discount-error', __( 'This discount has reached its maximum usage.', 'invoicing' ) );
592
+    if ($maxed_out) {
593
+        wpinv_set_error('wpinv-discount-error', __('This discount has reached its maximum usage.', 'invoicing'));
594 594
     }
595 595
 
596 596
     return $maxed_out;
@@ -603,9 +603,9 @@  discard block
 block discarded – undo
603 603
  * @param float $amount The amount to check for.
604 604
  * @return bool
605 605
  */
606
-function wpinv_discount_is_min_met( $discount, $amount = 0 ) {
607
-    $discount = wpinv_get_discount_obj( $discount );
608
-    return $discount->is_minimum_amount_met( $amount );
606
+function wpinv_discount_is_min_met($discount, $amount = 0) {
607
+    $discount = wpinv_get_discount_obj($discount);
608
+    return $discount->is_minimum_amount_met($amount);
609 609
 }
610 610
 
611 611
 /**
@@ -614,13 +614,13 @@  discard block
 block discarded – undo
614 614
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
615 615
  * @return bool
616 616
  */
617
-function wpinv_discount_is_max_met( $discount ) {
618
-    $discount    = wpinv_get_discount_obj( $discount );
619
-    $cart_amount = (float)wpinv_get_cart_discountable_subtotal( $discount->ID );
620
-    $max_met     = $discount->is_maximum_amount_met( $cart_amount );
617
+function wpinv_discount_is_max_met($discount) {
618
+    $discount    = wpinv_get_discount_obj($discount);
619
+    $cart_amount = (float) wpinv_get_cart_discountable_subtotal($discount->ID);
620
+    $max_met     = $discount->is_maximum_amount_met($cart_amount);
621 621
 
622
-    if ( ! $max_met ) {
623
-        wpinv_set_error( 'wpinv-discount-error', sprintf( __( 'Maximum invoice amount should be %s', 'invoicing' ), wpinv_price( wpinv_format_amount( $discount->max_total ) ) ) );
622
+    if (!$max_met) {
623
+        wpinv_set_error('wpinv-discount-error', sprintf(__('Maximum invoice amount should be %s', 'invoicing'), wpinv_price(wpinv_format_amount($discount->max_total))));
624 624
     }
625 625
 
626 626
     return $max_met;
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
  * @param int|array|string|WPInv_Discount $discount discount data, object, ID or code.
633 633
  * @return bool
634 634
  */
635
-function wpinv_discount_is_single_use( $discount ) {
636
-    $discount    = wpinv_get_discount_obj( $discount );
635
+function wpinv_discount_is_single_use($discount) {
636
+    $discount = wpinv_get_discount_obj($discount);
637 637
     return $discount->is_single_use;
638 638
 }
639 639
 
@@ -644,53 +644,53 @@  discard block
 block discarded – undo
644 644
  * @param int|array|string|WPInv_Discount $code discount data, object, ID or code.
645 645
  * @return bool
646 646
  */
647
-function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) {
647
+function wpinv_discount_is_recurring($discount = 0, $code = 0) {
648 648
 
649
-    if( ! empty( $discount ) ) {
650
-        $discount    = wpinv_get_discount_obj( $discount );
649
+    if (!empty($discount)) {
650
+        $discount    = wpinv_get_discount_obj($discount);
651 651
     } else {
652
-        $discount    = wpinv_get_discount_obj( $code );
652
+        $discount    = wpinv_get_discount_obj($code);
653 653
     }
654 654
 
655 655
     return $discount->get_is_recurring();
656 656
 }
657 657
 
658
-function wpinv_discount_item_reqs_met( $code_id = null ) {
659
-    $item_reqs    = wpinv_get_discount_item_reqs( $code_id );
660
-    $condition    = wpinv_get_discount_item_condition( $code_id );
661
-    $excluded_ps  = wpinv_get_discount_excluded_items( $code_id );
658
+function wpinv_discount_item_reqs_met($code_id = null) {
659
+    $item_reqs    = wpinv_get_discount_item_reqs($code_id);
660
+    $condition    = wpinv_get_discount_item_condition($code_id);
661
+    $excluded_ps  = wpinv_get_discount_excluded_items($code_id);
662 662
     $cart_items   = wpinv_get_cart_contents();
663
-    $cart_ids     = $cart_items ? wp_list_pluck( $cart_items, 'id' ) : null;
663
+    $cart_ids     = $cart_items ? wp_list_pluck($cart_items, 'id') : null;
664 664
     $ret          = false;
665 665
 
666
-    if ( empty( $item_reqs ) && empty( $excluded_ps ) ) {
666
+    if (empty($item_reqs) && empty($excluded_ps)) {
667 667
         $ret = true;
668 668
     }
669 669
 
670 670
     // Normalize our data for item requirements, exclusions and cart data
671 671
     // First absint the items, then sort, and reset the array keys
672
-    $item_reqs = array_map( 'absint', $item_reqs );
673
-    asort( $item_reqs );
674
-    $item_reqs = array_values( $item_reqs );
672
+    $item_reqs = array_map('absint', $item_reqs);
673
+    asort($item_reqs);
674
+    $item_reqs = array_values($item_reqs);
675 675
 
676
-    $excluded_ps  = array_map( 'absint', $excluded_ps );
677
-    asort( $excluded_ps );
678
-    $excluded_ps  = array_values( $excluded_ps );
676
+    $excluded_ps  = array_map('absint', $excluded_ps);
677
+    asort($excluded_ps);
678
+    $excluded_ps  = array_values($excluded_ps);
679 679
 
680
-    $cart_ids     = array_map( 'absint', $cart_ids );
681
-    asort( $cart_ids );
682
-    $cart_ids     = array_values( $cart_ids );
680
+    $cart_ids     = array_map('absint', $cart_ids);
681
+    asort($cart_ids);
682
+    $cart_ids     = array_values($cart_ids);
683 683
 
684 684
     // Ensure we have requirements before proceeding
685
-    if ( !$ret && ! empty( $item_reqs ) ) {
686
-        switch( $condition ) {
685
+    if (!$ret && !empty($item_reqs)) {
686
+        switch ($condition) {
687 687
             case 'all' :
688 688
                 // Default back to true
689 689
                 $ret = true;
690 690
 
691
-                foreach ( $item_reqs as $item_id ) {
692
-                    if ( !wpinv_item_in_cart( $item_id ) ) {
693
-                        wpinv_set_error( 'wpinv-discount-error', __( 'The item requirements for this discount are not met.', 'invoicing' ) );
691
+                foreach ($item_reqs as $item_id) {
692
+                    if (!wpinv_item_in_cart($item_id)) {
693
+                        wpinv_set_error('wpinv-discount-error', __('The item requirements for this discount are not met.', 'invoicing'));
694 694
                         $ret = false;
695 695
                         break;
696 696
                     }
@@ -699,15 +699,15 @@  discard block
 block discarded – undo
699 699
                 break;
700 700
 
701 701
             default : // Any
702
-                foreach ( $item_reqs as $item_id ) {
703
-                    if ( wpinv_item_in_cart( $item_id ) ) {
702
+                foreach ($item_reqs as $item_id) {
703
+                    if (wpinv_item_in_cart($item_id)) {
704 704
                         $ret = true;
705 705
                         break;
706 706
                     }
707 707
                 }
708 708
 
709
-                if( ! $ret ) {
710
-                    wpinv_set_error( 'wpinv-discount-error', __( 'The item requirements for this discount are not met.', 'invoicing' ) );
709
+                if (!$ret) {
710
+                    wpinv_set_error('wpinv-discount-error', __('The item requirements for this discount are not met.', 'invoicing'));
711 711
                 }
712 712
 
713 713
                 break;
@@ -716,15 +716,15 @@  discard block
 block discarded – undo
716 716
         $ret = true;
717 717
     }
718 718
 
719
-    if( ! empty( $excluded_ps ) ) {
719
+    if (!empty($excluded_ps)) {
720 720
         // Check that there are items other than excluded ones in the cart
721
-        if( $cart_ids == $excluded_ps ) {
722
-            wpinv_set_error( 'wpinv-discount-error', __( 'This discount is not valid for the cart contents.', 'invoicing' ) );
721
+        if ($cart_ids == $excluded_ps) {
722
+            wpinv_set_error('wpinv-discount-error', __('This discount is not valid for the cart contents.', 'invoicing'));
723 723
             $ret = false;
724 724
         }
725 725
     }
726 726
 
727
-    return (bool) apply_filters( 'wpinv_is_discount_item_req_met', $ret, $code_id, $condition );
727
+    return (bool) apply_filters('wpinv_is_discount_item_req_met', $ret, $code_id, $condition);
728 728
 }
729 729
 
730 730
 /**
@@ -735,54 +735,54 @@  discard block
 block discarded – undo
735 735
  * @param int|array|string|WPInv_Discount $code_id discount data, object, ID or code.
736 736
  * @return bool
737 737
  */
738
-function wpinv_is_discount_used( $discount = array(), $user = '', $code_id = array() ) {
738
+function wpinv_is_discount_used($discount = array(), $user = '', $code_id = array()) {
739 739
 
740
-    if( ! empty( $discount ) ) {
741
-        $discount = wpinv_get_discount_obj( $discount );
740
+    if (!empty($discount)) {
741
+        $discount = wpinv_get_discount_obj($discount);
742 742
     } else {
743
-        $discount = wpinv_get_discount_obj( $code_id );
743
+        $discount = wpinv_get_discount_obj($code_id);
744 744
     }
745 745
 
746
-    $is_used = ! $discount->is_valid_for_user( $user );
747
-    $is_used = apply_filters( 'wpinv_is_discount_used', $is_used, $discount->code, $user, $discount->ID, $discount );
746
+    $is_used = !$discount->is_valid_for_user($user);
747
+    $is_used = apply_filters('wpinv_is_discount_used', $is_used, $discount->code, $user, $discount->ID, $discount);
748 748
 
749
-    if( $is_used ) {
750
-        wpinv_set_error( 'wpinv-discount-error', __( 'This discount has already been redeemed.', 'invoicing' ) );
749
+    if ($is_used) {
750
+        wpinv_set_error('wpinv-discount-error', __('This discount has already been redeemed.', 'invoicing'));
751 751
     }
752 752
 
753 753
     return $is_used;
754 754
 }
755 755
 
756
-function wpinv_is_discount_valid( $code = '', $user = '', $set_error = true ) {
756
+function wpinv_is_discount_valid($code = '', $user = '', $set_error = true) {
757 757
 
758 758
     // Abort early if there is no discount code.
759
-    if ( empty( $code ) ) {
759
+    if (empty($code)) {
760 760
         return false;
761 761
     }
762 762
 
763 763
     $return      = false;
764
-    $discount_id = wpinv_get_discount_id_by_code( $code );
765
-    $user        = trim( $user );
764
+    $discount_id = wpinv_get_discount_id_by_code($code);
765
+    $user        = trim($user);
766 766
 
767
-    if ( wpinv_get_cart_contents() ) {
768
-        if ( $discount_id !== false ) {
767
+    if (wpinv_get_cart_contents()) {
768
+        if ($discount_id !== false) {
769 769
             if (
770
-                wpinv_is_discount_active( $discount_id ) &&
771
-                wpinv_check_discount_dates( $discount_id ) &&
772
-                !wpinv_is_discount_maxed_out( $discount_id ) &&
773
-                !wpinv_is_discount_used( $code, $user, $discount_id ) &&
774
-                wpinv_discount_is_min_met( $discount_id ) &&
775
-                wpinv_discount_is_max_met( $discount_id ) &&
776
-                wpinv_discount_item_reqs_met( $discount_id )
770
+                wpinv_is_discount_active($discount_id) &&
771
+                wpinv_check_discount_dates($discount_id) &&
772
+                !wpinv_is_discount_maxed_out($discount_id) &&
773
+                !wpinv_is_discount_used($code, $user, $discount_id) &&
774
+                wpinv_discount_is_min_met($discount_id) &&
775
+                wpinv_discount_is_max_met($discount_id) &&
776
+                wpinv_discount_item_reqs_met($discount_id)
777 777
             ) {
778 778
                 $return = true;
779 779
             }
780
-        } elseif( $set_error ) {
781
-            wpinv_set_error( 'wpinv-discount-error', __( 'This discount is invalid.', 'invoicing' ) );
780
+        } elseif ($set_error) {
781
+            wpinv_set_error('wpinv-discount-error', __('This discount is invalid.', 'invoicing'));
782 782
         }
783 783
     }
784 784
 
785
-    return apply_filters( 'wpinv_is_discount_valid', $return, $discount_id, $code, $user );
785
+    return apply_filters('wpinv_is_discount_valid', $return, $discount_id, $code, $user);
786 786
 }
787 787
 
788 788
 /**
@@ -791,9 +791,9 @@  discard block
 block discarded – undo
791 791
  * @param string $code
792 792
  * @return bool|false
793 793
  */
794
-function wpinv_get_discount_id_by_code( $code ) {
795
-    $discount = wpinv_get_discount_by_code( $code );
796
-    if ( $discount ) {
794
+function wpinv_get_discount_id_by_code($code) {
795
+    $discount = wpinv_get_discount_by_code($code);
796
+    if ($discount) {
797 797
         return $discount->get_id();
798 798
     }
799 799
     return false;
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
  * @param float $base_price The number of usages to increase by
807 807
  * @return float
808 808
  */
809
-function wpinv_get_discounted_amount( $discount, $base_price ) {
810
-    $discount = wpinv_get_discount_obj( $discount );
811
-    return $discount->get_discounted_amount( $base_price );
809
+function wpinv_get_discounted_amount($discount, $base_price) {
810
+    $discount = wpinv_get_discount_obj($discount);
811
+    return $discount->get_discounted_amount($base_price);
812 812
 }
813 813
 
814 814
 /**
@@ -818,9 +818,9 @@  discard block
 block discarded – undo
818 818
  * @param int $by The number of usages to increase by.
819 819
  * @return int the new number of uses.
820 820
  */
821
-function wpinv_increase_discount_usage( $discount, $by = 1 ) {
822
-    $discount   = wpinv_get_discount_obj( $discount );
823
-    return $discount->increase_usage( $by );
821
+function wpinv_increase_discount_usage($discount, $by = 1) {
822
+    $discount = wpinv_get_discount_obj($discount);
823
+    return $discount->increase_usage($by);
824 824
 }
825 825
 
826 826
 /**
@@ -830,28 +830,28 @@  discard block
 block discarded – undo
830 830
  * @param int $by The number of usages to decrease by.
831 831
  * @return int the new number of uses.
832 832
  */
833
-function wpinv_decrease_discount_usage( $discount, $by = 1 ) {
834
-    $discount   = wpinv_get_discount_obj( $discount );
835
-    return $discount->increase_usage( 0 - $by );
833
+function wpinv_decrease_discount_usage($discount, $by = 1) {
834
+    $discount = wpinv_get_discount_obj($discount);
835
+    return $discount->increase_usage(0 - $by);
836 836
 }
837 837
 
838
-function wpinv_format_discount_rate( $type, $amount ) {
839
-    if ( $type == 'flat' ) {
840
-        $rate = wpinv_price( wpinv_format_amount( $amount ) );
838
+function wpinv_format_discount_rate($type, $amount) {
839
+    if ($type == 'flat') {
840
+        $rate = wpinv_price(wpinv_format_amount($amount));
841 841
     } else {
842 842
         $rate = $amount . '%';
843 843
     }
844 844
 
845
-    return apply_filters( 'wpinv_format_discount_rate', $rate, $type, $amount );
845
+    return apply_filters('wpinv_format_discount_rate', $rate, $type, $amount);
846 846
 }
847 847
 
848 848
 function wpinv_unset_all_cart_discounts() {
849 849
     $data = wpinv_get_checkout_session();
850 850
 
851
-    if ( !empty( $data ) && isset( $data['cart_discounts'] ) ) {
852
-        unset( $data['cart_discounts'] );
851
+    if (!empty($data) && isset($data['cart_discounts'])) {
852
+        unset($data['cart_discounts']);
853 853
 
854
-         wpinv_set_checkout_session( $data );
854
+         wpinv_set_checkout_session($data);
855 855
          return true;
856 856
     }
857 857
 
@@ -860,13 +860,13 @@  discard block
 block discarded – undo
860 860
 
861 861
 function wpinv_get_cart_discounts() {
862 862
     $session = wpinv_get_checkout_session();
863
-    return empty( $session['cart_discounts'] ) ? false : $session['cart_discounts'];
863
+    return empty($session['cart_discounts']) ? false : $session['cart_discounts'];
864 864
 }
865 865
 
866
-function wpinv_cart_has_discounts( $items = array() ) {
866
+function wpinv_cart_has_discounts($items = array()) {
867 867
     $ret = false;
868 868
 
869
-    if ( wpinv_get_cart_discounts( $items ) ) {
869
+    if (wpinv_get_cart_discounts($items)) {
870 870
         $ret = true;
871 871
     }
872 872
 
@@ -877,49 +877,49 @@  discard block
 block discarded – undo
877 877
     }
878 878
     */
879 879
 
880
-    return apply_filters( 'wpinv_cart_has_discounts', $ret );
880
+    return apply_filters('wpinv_cart_has_discounts', $ret);
881 881
 }
882 882
 
883
-function wpinv_get_cart_discounted_amount( $items = array(), $discounts = false ) {
883
+function wpinv_get_cart_discounted_amount($items = array(), $discounts = false) {
884 884
     $amount = 0.00;
885
-    $items  = !empty( $items ) ? $items : wpinv_get_cart_content_details();
885
+    $items  = !empty($items) ? $items : wpinv_get_cart_content_details();
886 886
 
887
-    if ( $items ) {
888
-        $discounts = wp_list_pluck( $items, 'discount' );
887
+    if ($items) {
888
+        $discounts = wp_list_pluck($items, 'discount');
889 889
 
890
-        if ( is_array( $discounts ) ) {
891
-            $discounts = array_map( 'floatval', $discounts );
892
-            $amount    = array_sum( $discounts );
890
+        if (is_array($discounts)) {
891
+            $discounts = array_map('floatval', $discounts);
892
+            $amount    = array_sum($discounts);
893 893
         }
894 894
     }
895 895
 
896
-    return apply_filters( 'wpinv_get_cart_discounted_amount', $amount );
896
+    return apply_filters('wpinv_get_cart_discounted_amount', $amount);
897 897
 }
898 898
 
899
-function wpinv_get_discount_label( $code, $echo = true ) {
900
-    $label = wp_sprintf( __( 'Discount%1$s', 'invoicing' ), ( $code != '' && $code != 'none' ? ' (<code>' . $code . '</code>)': '' ) );
901
-    $label = apply_filters( 'wpinv_get_discount_label', $label, $code );
899
+function wpinv_get_discount_label($code, $echo = true) {
900
+    $label = wp_sprintf(__('Discount%1$s', 'invoicing'), ($code != '' && $code != 'none' ? ' (<code>' . $code . '</code>)' : ''));
901
+    $label = apply_filters('wpinv_get_discount_label', $label, $code);
902 902
 
903
-    if ( $echo ) {
903
+    if ($echo) {
904 904
         echo $label;
905 905
     } else {
906 906
         return $label;
907 907
     }
908 908
 }
909 909
 
910
-function wpinv_cart_discount_label( $code, $rate, $echo = true ) {
911
-    $label = wp_sprintf( __( 'Discount: %s', 'invoicing' ), $code );
912
-    $label = apply_filters( 'wpinv_cart_discount_label', $label, $code, $rate );
910
+function wpinv_cart_discount_label($code, $rate, $echo = true) {
911
+    $label = wp_sprintf(__('Discount: %s', 'invoicing'), $code);
912
+    $label = apply_filters('wpinv_cart_discount_label', $label, $code, $rate);
913 913
 
914
-    if ( $echo ) {
914
+    if ($echo) {
915 915
         echo $label;
916 916
     } else {
917 917
         return $label;
918 918
     }
919 919
 }
920 920
 
921
-function wpinv_check_delete_discount( $check, $post ) {
922
-    if ( $post->post_type == 'wpi_discount' && wpinv_get_discount_uses( $post->ID ) > 0 ) {
921
+function wpinv_check_delete_discount($check, $post) {
922
+    if ($post->post_type == 'wpi_discount' && wpinv_get_discount_uses($post->ID) > 0) {
923 923
         return true;
924 924
     }
925 925
 
@@ -929,5 +929,5 @@  discard block
 block discarded – undo
929 929
 function wpinv_discount_amount() {
930 930
     $output = 0.00;
931 931
 
932
-    return apply_filters( 'wpinv_discount_amount', $output );
932
+    return apply_filters('wpinv_discount_amount', $output);
933 933
 }
Please login to merge, or discard this patch.