Passed
Pull Request — master (#322)
by Brian
09:18
created
vendor/composer/autoload_static.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php',
11 11
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
12 12
     );
13 13
 
14
-    public static $prefixLengthsPsr4 = array (
14
+    public static $prefixLengthsPsr4 = array(
15 15
         'C' => 
16
-        array (
16
+        array(
17 17
             'Composer\\Installers\\' => 20,
18 18
         ),
19 19
     );
20 20
 
21
-    public static $prefixDirsPsr4 = array (
21
+    public static $prefixDirsPsr4 = array(
22 22
         'Composer\\Installers\\' => 
23
-        array (
23
+        array(
24 24
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
25 25
         ),
26 26
     );
27 27
 
28
-    public static $classMap = array (
28
+    public static $classMap = array(
29 29
         'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php',
30 30
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
31 31
     );
32 32
 
33 33
     public static function getInitializer(ClassLoader $loader)
34 34
     {
35
-        return \Closure::bind(function () use ($loader) {
35
+        return \Closure::bind(function() use ($loader) {
36 36
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
37 37
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
38 38
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  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_filter( 'manage_wpi_payment_form_posts_columns', 'wpinv_payment_form_columns' );
8
-function wpinv_payment_form_columns( $existing_columns ) {
7
+add_filter('manage_wpi_payment_form_posts_columns', 'wpinv_payment_form_columns');
8
+function wpinv_payment_form_columns($existing_columns) {
9 9
     $date = $existing_columns['date'];
10
-    unset( $existing_columns['date'] );
11
-    $existing_columns['shortcode'] = __( 'Shortcode', 'invoicing' );
10
+    unset($existing_columns['date']);
11
+    $existing_columns['shortcode'] = __('Shortcode', 'invoicing');
12 12
     $existing_columns['date'] = $date;
13 13
     return $existing_columns;
14 14
 }
15 15
 
16
-add_action( 'manage_wpi_payment_form_posts_custom_column', 'wpinv_payment_form_custom_column' );
17
-function wpinv_payment_form_custom_column( $column ) {
16
+add_action('manage_wpi_payment_form_posts_custom_column', 'wpinv_payment_form_custom_column');
17
+function wpinv_payment_form_custom_column($column) {
18 18
     global $post;
19 19
 
20
-    if( 'shortcode' == $column ) {
21
-        WPInv_Meta_Box_Payment_Form::output_shortcode( $post );
20
+    if ('shortcode' == $column) {
21
+        WPInv_Meta_Box_Payment_Form::output_shortcode($post);
22 22
     }
23 23
 
24 24
 }
25 25
 
26
-add_filter( 'manage_wpi_discount_posts_columns', 'wpinv_discount_columns' );
27
-function wpinv_discount_columns( $existing_columns ) {
26
+add_filter('manage_wpi_discount_posts_columns', 'wpinv_discount_columns');
27
+function wpinv_discount_columns($existing_columns) {
28 28
     $columns                = array();
29 29
     $columns['cb']          = $existing_columns['cb'];
30
-    $columns['name']        = __( 'Name', 'invoicing' );
31
-    $columns['code']        = __( 'Code', 'invoicing' );
32
-    $columns['amount']      = __( 'Amount', 'invoicing' );
33
-    $columns['usage']       = __( 'Usage / Limit', 'invoicing' );
34
-    $columns['start_date']  = __( 'Start Date', 'invoicing' );
35
-    $columns['expiry_date'] = __( 'Expiry Date', 'invoicing' );
36
-    $columns['status']      = __( 'Status', 'invoicing' );
30
+    $columns['name']        = __('Name', 'invoicing');
31
+    $columns['code']        = __('Code', 'invoicing');
32
+    $columns['amount']      = __('Amount', 'invoicing');
33
+    $columns['usage']       = __('Usage / Limit', 'invoicing');
34
+    $columns['start_date']  = __('Start Date', 'invoicing');
35
+    $columns['expiry_date'] = __('Expiry Date', 'invoicing');
36
+    $columns['status']      = __('Status', 'invoicing');
37 37
 
38 38
     return $columns;
39 39
 }
40 40
 
41
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
42
-function wpinv_discount_custom_column( $column ) {
41
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
42
+function wpinv_discount_custom_column($column) {
43 43
     global $post;
44 44
 
45 45
     $discount = $post;
46 46
 
47
-    switch ( $column ) {
47
+    switch ($column) {
48 48
         case 'name' :
49
-            echo get_the_title( $discount->ID );
49
+            echo get_the_title($discount->ID);
50 50
         break;
51 51
         case 'code' :
52
-            echo wpinv_get_discount_code( $discount->ID );
52
+            echo wpinv_get_discount_code($discount->ID);
53 53
         break;
54 54
         case 'amount' :
55
-            echo wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
55
+            echo wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
56 56
         break;
57 57
         case 'usage_limit' :
58
-            echo wpinv_get_discount_uses( $discount->ID );
58
+            echo wpinv_get_discount_uses($discount->ID);
59 59
         break;
60 60
         case 'usage' :
61
-            $usage = wpinv_get_discount_uses( $discount->ID ) . ' / ';
62
-            if ( wpinv_get_discount_max_uses( $discount->ID ) ) {
63
-                $usage .= wpinv_get_discount_max_uses( $discount->ID );
61
+            $usage = wpinv_get_discount_uses($discount->ID) . ' / ';
62
+            if (wpinv_get_discount_max_uses($discount->ID)) {
63
+                $usage .= wpinv_get_discount_max_uses($discount->ID);
64 64
             } else {
65 65
                 $usage .= ' &infin;';
66 66
             }
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
             echo $usage;
69 69
         break;
70 70
         case 'start_date' :
71
-            if ( $start_date = wpinv_get_discount_start_date( $discount->ID ) ) {
72
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $start_date ) );
71
+            if ($start_date = wpinv_get_discount_start_date($discount->ID)) {
72
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($start_date));
73 73
             } else {
74 74
                 $value = '-';
75 75
             }
@@ -77,163 +77,163 @@  discard block
 block discarded – undo
77 77
             echo $value;
78 78
         break;
79 79
         case 'expiry_date' :
80
-            if ( $expiration = wpinv_get_discount_expiration( $discount->ID ) ) {
81
-                $value = date_i18n( get_option( 'date_format' ) . ' @ ' . get_option( 'time_format' ), strtotime( $expiration ) );
80
+            if ($expiration = wpinv_get_discount_expiration($discount->ID)) {
81
+                $value = date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'), strtotime($expiration));
82 82
             } else {
83
-                $value = __( 'Never', 'invoicing' );
83
+                $value = __('Never', 'invoicing');
84 84
             }
85 85
                 
86 86
             echo $value;
87 87
         break;
88 88
         break;
89 89
         case 'description' :
90
-            echo wp_kses_post( $post->post_excerpt );
90
+            echo wp_kses_post($post->post_excerpt);
91 91
         break;
92 92
         case 'status' :
93
-            $status = wpinv_is_discount_expired( $discount->ID ) ? 'expired' : $discount->post_status;
93
+            $status = wpinv_is_discount_expired($discount->ID) ? 'expired' : $discount->post_status;
94 94
             
95
-            echo wpinv_discount_status( $status );
95
+            echo wpinv_discount_status($status);
96 96
         break;
97 97
     }
98 98
 }
99 99
 
100
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
101
-function wpinv_post_row_actions( $actions, $post ) {
102
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
100
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
101
+function wpinv_post_row_actions($actions, $post) {
102
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
103 103
     
104
-    if ( $post_type == 'wpi_invoice' ) {
104
+    if ($post_type == 'wpi_invoice') {
105 105
         $actions = array();
106 106
     }
107 107
     
108
-    if ( $post_type == 'wpi_discount' ) {
109
-        $actions = wpinv_discount_row_actions( $post, $actions );
108
+    if ($post_type == 'wpi_discount') {
109
+        $actions = wpinv_discount_row_actions($post, $actions);
110 110
     }
111 111
     
112 112
     return $actions;
113 113
 }
114 114
 
115
-function wpinv_discount_row_actions( $discount, $row_actions ) {
116
-    $row_actions  = array();
117
-    $edit_link = get_edit_post_link( $discount->ID );
118
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
115
+function wpinv_discount_row_actions($discount, $row_actions) {
116
+    $row_actions = array();
117
+    $edit_link = get_edit_post_link($discount->ID);
118
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
119 119
 
120
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
121
-        $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>';
122
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
123
-        $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>';
120
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
121
+        $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>';
122
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
123
+        $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>';
124 124
     }
125 125
 
126
-    if ( wpinv_get_discount_uses( $discount->ID ) > 0 ) {
127
-        if ( isset( $row_actions['delete'] ) ) {
128
-            unset( $row_actions['delete'] ); // Don't delete used discounts.
126
+    if (wpinv_get_discount_uses($discount->ID) > 0) {
127
+        if (isset($row_actions['delete'])) {
128
+            unset($row_actions['delete']); // Don't delete used discounts.
129 129
         }
130 130
     } else {
131
-        $row_actions['delete'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'delete_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Delete', 'invoicing' ) . '</a>';
131
+        $row_actions['delete'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'delete_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Delete', 'invoicing') . '</a>';
132 132
     }
133 133
     
134 134
 
135
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
135
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
136 136
 
137 137
     return $row_actions;
138 138
 }
139 139
 
140
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
141
-function wpinv_table_primary_column( $default, $screen_id ) {
142
-    if ( 'edit-wpi_invoice' === $screen_id ) {
140
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
141
+function wpinv_table_primary_column($default, $screen_id) {
142
+    if ('edit-wpi_invoice' === $screen_id) {
143 143
         return 'name';
144 144
     }
145 145
     
146 146
     return $default;
147 147
 }
148 148
 
149
-function wpinv_discount_bulk_actions( $actions, $display = false ) {    
150
-    if ( !$display ) {
149
+function wpinv_discount_bulk_actions($actions, $display = false) {    
150
+    if (!$display) {
151 151
         return array();
152 152
     }
153 153
     
154 154
     $actions = array(
155
-        'activate'   => __( 'Activate', 'invoicing' ),
156
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
157
-        'delete'     => __( 'Delete', 'invoicing' ),
155
+        'activate'   => __('Activate', 'invoicing'),
156
+        'deactivate' => __('Deactivate', 'invoicing'),
157
+        'delete'     => __('Delete', 'invoicing'),
158 158
     );
159 159
     $two = '';
160 160
     $which = 'top';
161 161
     echo '</div><div class="alignleft actions bulkactions">';
162
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
163
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
164
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
162
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
163
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
164
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
165 165
 
166
-    foreach ( $actions as $name => $title ) {
166
+    foreach ($actions as $name => $title) {
167 167
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
168 168
 
169 169
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
170 170
     }
171 171
     echo "</select>";
172 172
 
173
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
173
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
174 174
     
175 175
     echo '</div><div class="alignleft actions">';
176 176
 }
177
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
177
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
178 178
 
179
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
180
-    if ( $post_type == 'wpi_discount' ) {
179
+function wpinv_disable_months_dropdown($disable, $post_type) {
180
+    if ($post_type == 'wpi_discount') {
181 181
         $disable = true;
182 182
     }
183 183
     
184 184
     return $disable;
185 185
 }
186
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
186
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
187 187
 
188 188
 function wpinv_restrict_manage_posts() {
189 189
     global $typenow;
190 190
 
191
-    if( 'wpi_discount' == $typenow ) {
191
+    if ('wpi_discount' == $typenow) {
192 192
         wpinv_discount_filters();
193 193
     }
194 194
 }
195
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
195
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
196 196
 
197 197
 function wpinv_discount_filters() {
198
-    echo wpinv_discount_bulk_actions( array(), true );
198
+    echo wpinv_discount_bulk_actions(array(), true);
199 199
     
200 200
     ?>
201 201
     <select name="discount_type" id="dropdown_wpinv_discount_type">
202
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
202
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
203 203
         <?php
204 204
             $types = wpinv_get_discount_types();
205 205
 
206
-            foreach ( $types as $name => $type ) {
207
-                echo '<option value="' . esc_attr( $name ) . '"';
206
+            foreach ($types as $name => $type) {
207
+                echo '<option value="' . esc_attr($name) . '"';
208 208
 
209
-                if ( isset( $_GET['discount_type'] ) )
210
-                    selected( $name, $_GET['discount_type'] );
209
+                if (isset($_GET['discount_type']))
210
+                    selected($name, $_GET['discount_type']);
211 211
 
212
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
212
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
213 213
             }
214 214
         ?>
215 215
     </select>
216 216
     <?php
217 217
 }
218 218
 
219
-function wpinv_request( $vars ) {
219
+function wpinv_request($vars) {
220 220
     global $typenow, $wp_query, $wp_post_statuses;
221 221
 
222
-    if ( 'wpi_invoice' === $typenow ) {
223
-        if ( !isset( $vars['post_status'] ) ) {
222
+    if ('wpi_invoice' === $typenow) {
223
+        if (!isset($vars['post_status'])) {
224 224
             $post_statuses = wpinv_get_invoice_statuses();
225 225
 
226
-            foreach ( $post_statuses as $status => $value ) {
227
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
228
-                    unset( $post_statuses[ $status ] );
226
+            foreach ($post_statuses as $status => $value) {
227
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
228
+                    unset($post_statuses[$status]);
229 229
                 }
230 230
             }
231 231
 
232
-            $vars['post_status'] = array_keys( $post_statuses );
232
+            $vars['post_status'] = array_keys($post_statuses);
233 233
         }
234 234
         
235
-        if ( isset( $vars['orderby'] ) ) {
236
-            if ( 'amount' == $vars['orderby'] ) {
235
+        if (isset($vars['orderby'])) {
236
+            if ('amount' == $vars['orderby']) {
237 237
                 $vars = array_merge(
238 238
                     $vars,
239 239
                     array(
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
                         'orderby'  => 'meta_value_num'
242 242
                     )
243 243
                 );
244
-            } else if ( 'customer' == $vars['orderby'] ) {
244
+            } else if ('customer' == $vars['orderby']) {
245 245
                 $vars = array_merge(
246 246
                     $vars,
247 247
                     array(
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                         'orderby'  => 'meta_value'
250 250
                     )
251 251
                 );
252
-            } else if ( 'number' == $vars['orderby'] ) {
252
+            } else if ('number' == $vars['orderby']) {
253 253
                 $vars = array_merge(
254 254
                     $vars,
255 255
                     array(
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                         'orderby'  => 'meta_value'
258 258
                     )
259 259
                 );
260
-            } else if ( 'payment_date' == $vars['orderby'] ) {
260
+            } else if ('payment_date' == $vars['orderby']) {
261 261
                 $vars = array_merge(
262 262
                     $vars,
263 263
                     array(
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
                 );
268 268
             }
269 269
         }
270
-    } else if ( 'wpi_item' == $typenow ) {
270
+    } else if ('wpi_item' == $typenow) {
271 271
         // Check if 'orderby' is set to "price"
272
-        if ( isset( $vars['orderby'] ) && 'price' == $vars['orderby'] ) {
272
+        if (isset($vars['orderby']) && 'price' == $vars['orderby']) {
273 273
             $vars = array_merge(
274 274
                 $vars,
275 275
                 array(
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         // Check if "orderby" is set to "vat_rule"
283
-        if ( isset( $vars['orderby'] ) && 'vat_rule' == $vars['orderby'] ) {
283
+        if (isset($vars['orderby']) && 'vat_rule' == $vars['orderby']) {
284 284
             $vars = array_merge(
285 285
                 $vars,
286 286
                 array(
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         }
292 292
 
293 293
         // Check if "orderby" is set to "vat_class"
294
-        if ( isset( $vars['orderby'] ) && 'vat_class' == $vars['orderby'] ) {
294
+        if (isset($vars['orderby']) && 'vat_class' == $vars['orderby']) {
295 295
             $vars = array_merge(
296 296
                 $vars,
297 297
                 array(
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
         }
303 303
         
304 304
         // Check if "orderby" is set to "type"
305
-        if ( isset( $vars['orderby'] ) && 'type' == $vars['orderby'] ) {
305
+        if (isset($vars['orderby']) && 'type' == $vars['orderby']) {
306 306
             $vars = array_merge(
307 307
                 $vars,
308 308
                 array(
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         }
314 314
         
315 315
         // Check if "orderby" is set to "recurring"
316
-        if ( isset( $vars['orderby'] ) && 'recurring' == $vars['orderby'] ) {
316
+        if (isset($vars['orderby']) && 'recurring' == $vars['orderby']) {
317 317
             $vars = array_merge(
318 318
                 $vars,
319 319
                 array(
@@ -323,104 +323,104 @@  discard block
 block discarded – undo
323 323
             );
324 324
         }
325 325
 
326
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
326
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
327 327
         // Filter vat rule type
328
-        if ( isset( $_GET['vat_rule'] ) && $_GET['vat_rule'] !== '' ) {
328
+        if (isset($_GET['vat_rule']) && $_GET['vat_rule'] !== '') {
329 329
             $meta_query[] = array(
330 330
                     'key'   => '_wpinv_vat_rule',
331
-                    'value' => sanitize_text_field( $_GET['vat_rule'] ),
331
+                    'value' => sanitize_text_field($_GET['vat_rule']),
332 332
                     'compare' => '='
333 333
                 );
334 334
         }
335 335
         
336 336
         // Filter vat class
337
-        if ( isset( $_GET['vat_class'] ) && $_GET['vat_class'] !== '' ) {
337
+        if (isset($_GET['vat_class']) && $_GET['vat_class'] !== '') {
338 338
             $meta_query[] = array(
339 339
                     'key'   => '_wpinv_vat_class',
340
-                    'value' => sanitize_text_field( $_GET['vat_class'] ),
340
+                    'value' => sanitize_text_field($_GET['vat_class']),
341 341
                     'compare' => '='
342 342
                 );
343 343
         }
344 344
         
345 345
         // Filter item type
346
-        if ( isset( $_GET['type'] ) && $_GET['type'] !== '' ) {
346
+        if (isset($_GET['type']) && $_GET['type'] !== '') {
347 347
             $meta_query[] = array(
348 348
                     'key'   => '_wpinv_type',
349
-                    'value' => sanitize_text_field( $_GET['type'] ),
349
+                    'value' => sanitize_text_field($_GET['type']),
350 350
                     'compare' => '='
351 351
                 );
352 352
         }
353 353
         
354
-        if ( !empty( $meta_query ) ) {
354
+        if (!empty($meta_query)) {
355 355
             $vars['meta_query'] = $meta_query;
356 356
         }
357
-    } else if ( 'wpi_discount' == $typenow ) {
358
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
357
+    } else if ('wpi_discount' == $typenow) {
358
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
359 359
         // Filter vat rule type
360
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
360
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
361 361
             $meta_query[] = array(
362 362
                     'key'   => '_wpi_discount_type',
363
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
363
+                    'value' => sanitize_text_field($_GET['discount_type']),
364 364
                     'compare' => '='
365 365
                 );
366 366
         }
367 367
         
368
-        if ( !empty( $meta_query ) ) {
368
+        if (!empty($meta_query)) {
369 369
             $vars['meta_query'] = $meta_query;
370 370
         }
371 371
     }
372 372
 
373 373
     return $vars;
374 374
 }
375
-add_filter( 'request', 'wpinv_request' );
375
+add_filter('request', 'wpinv_request');
376 376
 
377
-function wpinv_item_type_class( $classes, $class, $post_id ) {
377
+function wpinv_item_type_class($classes, $class, $post_id) {
378 378
     global $pagenow, $typenow;
379 379
 
380
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
381
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
382
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
380
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
381
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
382
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
383 383
         }
384 384
         
385
-        if ( !wpinv_item_is_editable( $post_id ) ) {
385
+        if (!wpinv_item_is_editable($post_id)) {
386 386
             $classes[] = 'wpi-editable-n';
387 387
         }
388 388
     }
389 389
     return $classes;
390 390
 }
391
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
391
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
392 392
 
393 393
 function wpinv_check_quick_edit() {
394 394
     global $pagenow, $current_screen, $wpinv_item_screen;
395 395
 
396
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
397
-        if ( empty( $wpinv_item_screen ) ) {
398
-            if ( $current_screen->post_type == 'wpi_item' ) {
396
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
397
+        if (empty($wpinv_item_screen)) {
398
+            if ($current_screen->post_type == 'wpi_item') {
399 399
                 $wpinv_item_screen = 'y';
400 400
             } else {
401 401
                 $wpinv_item_screen = 'n';
402 402
             }
403 403
         }
404 404
 
405
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
406
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
407
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
405
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
406
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
407
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
408 408
         }
409 409
     }
410 410
 }
411
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
411
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
412 412
 
413
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
414
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
415
-        unset( $actions['inline hide-if-no-js'] );
413
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
414
+    if (isset($actions['inline hide-if-no-js'])) {
415
+        unset($actions['inline hide-if-no-js']);
416 416
     }
417 417
     
418
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
419
-        if ( isset( $actions['trash'] ) ) {
420
-            unset( $actions['trash'] );
418
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
419
+        if (isset($actions['trash'])) {
420
+            unset($actions['trash']);
421 421
         }
422
-        if ( isset( $actions['delete'] ) ) {
423
-            unset( $actions['delete'] );
422
+        if (isset($actions['delete'])) {
423
+            unset($actions['delete']);
424 424
         }
425 425
     }
426 426
 
@@ -437,19 +437,19 @@  discard block
 block discarded – undo
437 437
  * @param int $post_parent (default: 0) Parent for the new page
438 438
  * @return int page ID
439 439
  */
440
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
440
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
441 441
     global $wpdb;
442 442
 
443
-    $option_value = wpinv_get_option( $option );
443
+    $option_value = wpinv_get_option($option);
444 444
 
445
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
446
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
445
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
446
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
447 447
             // Valid page is already in place
448 448
             return $page_object->ID;
449 449
         }
450 450
     }
451 451
 
452
-    if(!empty($post_parent)){
452
+    if (!empty($post_parent)) {
453 453
         $page = get_page_by_path($post_parent);
454 454
         if ($page) {
455 455
             $post_parent = $page->ID;
@@ -458,40 +458,40 @@  discard block
 block discarded – undo
458 458
         }
459 459
     }
460 460
 
461
-    if ( strlen( $page_content ) > 0 ) {
461
+    if (strlen($page_content) > 0) {
462 462
         // Search for an existing page with the specified page content (typically a shortcode)
463
-        $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}%" ) );
463
+        $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}%"));
464 464
     } else {
465 465
         // Search for an existing page with the specified page slug
466
-        $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 ) );
466
+        $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));
467 467
     }
468 468
 
469
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
469
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
470 470
 
471
-    if ( $valid_page_found ) {
472
-        if ( $option ) {
473
-            wpinv_update_option( $option, $valid_page_found );
471
+    if ($valid_page_found) {
472
+        if ($option) {
473
+            wpinv_update_option($option, $valid_page_found);
474 474
         }
475 475
         return $valid_page_found;
476 476
     }
477 477
 
478 478
     // Search for a matching valid trashed page
479
-    if ( strlen( $page_content ) > 0 ) {
479
+    if (strlen($page_content) > 0) {
480 480
         // Search for an existing page with the specified page content (typically a shortcode)
481
-        $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}%" ) );
481
+        $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}%"));
482 482
     } else {
483 483
         // Search for an existing page with the specified page slug
484
-        $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 ) );
484
+        $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));
485 485
     }
486 486
 
487
-    if ( $trashed_page_found ) {
487
+    if ($trashed_page_found) {
488 488
         $page_id   = $trashed_page_found;
489 489
         $page_data = array(
490 490
             'ID'             => $page_id,
491 491
             'post_status'    => 'publish',
492 492
             'post_parent'    => $post_parent,
493 493
         );
494
-        wp_update_post( $page_data );
494
+        wp_update_post($page_data);
495 495
     } else {
496 496
         $page_data = array(
497 497
             'post_status'    => 'publish',
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
             'post_parent'    => $post_parent,
504 504
             'comment_status' => 'closed',
505 505
         );
506
-        $page_id = wp_insert_post( $page_data );
506
+        $page_id = wp_insert_post($page_data);
507 507
     }
508 508
 
509
-    if ( $option ) {
510
-        wpinv_update_option( $option, (int)$page_id );
509
+    if ($option) {
510
+        wpinv_update_option($option, (int) $page_id);
511 511
     }
512 512
 
513 513
     return $page_id;
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +588 added lines, -588 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -30,381 +30,381 @@  discard block
 block discarded – undo
30 30
         'wpinv_fully_refunded',
31 31
         'wpinv_partially_refunded',
32 32
         'wpinv_new_invoice_note'
33
-    ) );
33
+    ));
34 34
 
35
-    foreach ( $email_actions as $action ) {
36
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
35
+    foreach ($email_actions as $action) {
36
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
37 37
     }
38 38
 }
39
-add_action( 'init', 'wpinv_init_transactional_emails' );
39
+add_action('init', 'wpinv_init_transactional_emails');
40 40
 
41 41
 // New invoice email
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
46
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
47
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
42
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
46
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
47
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
48 48
 
49 49
 // Cancelled invoice email
50
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
51
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
50
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
51
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
52 52
 
53 53
 // Failed invoice email
54
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
55
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
54
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
55
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
56 56
 
57 57
 // On hold invoice email
58
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
59
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
58
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
59
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
60 60
 
61 61
 // Processing invoice email
62
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
62
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
63 63
 
64 64
 // Paid invoice email
65
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
65
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
66 66
 
67 67
 // Refunded invoice email
68
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
69
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
70
-add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
71
-add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
68
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
69
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
70
+add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
71
+add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
72 72
 
73 73
 // Invoice note
74
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
74
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
75 75
 
76
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
77
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
78
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
79
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
80
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
76
+add_action('wpinv_email_header', 'wpinv_email_header');
77
+add_action('wpinv_email_footer', 'wpinv_email_footer');
78
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
79
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
80
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
81 81
 
82 82
 function wpinv_send_transactional_email() {
83 83
     $args       = func_get_args();
84 84
     $function   = current_filter() . '_notification';
85
-    do_action_ref_array( $function, $args );
85
+    do_action_ref_array($function, $args);
86 86
 }
87 87
 
88
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
88
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
89 89
     $email_type = 'new_invoice';
90
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
90
+    if (!wpinv_email_is_enabled($email_type)) {
91 91
         return false;
92 92
     }
93 93
 
94
-    $invoice = wpinv_get_invoice( $invoice_id );
95
-    if ( empty( $invoice ) ) {
94
+    $invoice = wpinv_get_invoice($invoice_id);
95
+    if (empty($invoice)) {
96 96
         return false;
97 97
     }
98 98
 
99
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
99
+    if (!("wpi_invoice" === $invoice->post_type)) {
100 100
         return false;
101 101
     }
102 102
 
103
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
104
-    if ( !is_email( $recipient ) ) {
103
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
104
+    if (!is_email($recipient)) {
105 105
         return false;
106 106
     }
107 107
 
108
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
108
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
109 109
 
110
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
111
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
112
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
113
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
114
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
110
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
111
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
112
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
113
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
114
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
115 115
 
116
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
116
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
117 117
             'invoice'       => $invoice,
118 118
             'email_type'    => $email_type,
119 119
             'email_heading' => $email_heading,
120 120
             'sent_to_admin' => true,
121 121
             'plain_text'    => false,
122 122
             'message_body'  => $message_body,
123
-        ) );
123
+        ));
124 124
 
125
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
125
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
126 126
 
127
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
127
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
128 128
 
129 129
     return $sent;
130 130
 }
131 131
 
132
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
132
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
133 133
     $email_type = 'cancelled_invoice';
134
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
134
+    if (!wpinv_email_is_enabled($email_type)) {
135 135
         return false;
136 136
     }
137 137
 
138
-    $invoice = wpinv_get_invoice( $invoice_id );
139
-    if ( empty( $invoice ) ) {
138
+    $invoice = wpinv_get_invoice($invoice_id);
139
+    if (empty($invoice)) {
140 140
         return false;
141 141
     }
142 142
 
143
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
143
+    if (!("wpi_invoice" === $invoice->post_type)) {
144 144
         return false;
145 145
     }
146 146
 
147
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
148
-    if ( !is_email( $recipient ) ) {
147
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
148
+    if (!is_email($recipient)) {
149 149
         return false;
150 150
     }
151 151
 
152
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
152
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
153 153
 
154
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
155
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
156
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
157
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
158
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
154
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
155
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
156
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
157
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
158
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
159 159
 
160
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
160
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
161 161
             'invoice'       => $invoice,
162 162
             'email_type'    => $email_type,
163 163
             'email_heading' => $email_heading,
164 164
             'sent_to_admin' => true,
165 165
             'plain_text'    => false,
166 166
             'message_body'  => $message_body,
167
-        ) );
167
+        ));
168 168
 
169
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
169
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
170 170
 
171
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
171
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
172 172
 
173 173
     return $sent;
174 174
 }
175 175
 
176
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
176
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
177 177
     $email_type = 'failed_invoice';
178
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
178
+    if (!wpinv_email_is_enabled($email_type)) {
179 179
         return false;
180 180
     }
181 181
     
182
-    $invoice = wpinv_get_invoice( $invoice_id );
183
-    if ( empty( $invoice ) ) {
182
+    $invoice = wpinv_get_invoice($invoice_id);
183
+    if (empty($invoice)) {
184 184
         return false;
185 185
     }
186 186
 
187
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
187
+    if (!("wpi_invoice" === $invoice->post_type)) {
188 188
         return false;
189 189
     }
190 190
 
191
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
192
-    if ( !is_email( $recipient ) ) {
191
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
192
+    if (!is_email($recipient)) {
193 193
         return false;
194 194
     }
195 195
 
196
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
196
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
197 197
 
198
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
199
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
200
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
201
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
202
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
198
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
199
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
200
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
201
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
202
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
203 203
     
204
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
204
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
205 205
             'invoice'       => $invoice,
206 206
             'email_type'    => $email_type,
207 207
             'email_heading' => $email_heading,
208 208
             'sent_to_admin' => true,
209 209
             'plain_text'    => false,
210 210
             'message_body'  => $message_body,
211
-        ) );
211
+        ));
212 212
 
213
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
213
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
214 214
 
215
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
215
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
216 216
 
217 217
     return $sent;
218 218
 }
219 219
 
220
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
220
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
221 221
     $email_type = 'onhold_invoice';
222
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
222
+    if (!wpinv_email_is_enabled($email_type)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $invoice = wpinv_get_invoice( $invoice_id );
227
-    if ( empty( $invoice ) ) {
226
+    $invoice = wpinv_get_invoice($invoice_id);
227
+    if (empty($invoice)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
231
+    if (!("wpi_invoice" === $invoice->post_type)) {
232 232
         return false;
233 233
     }
234 234
 
235
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
236
-    if ( !is_email( $recipient ) ) {
235
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
236
+    if (!is_email($recipient)) {
237 237
         return false;
238 238
     }
239 239
 
240
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
240
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
241 241
 
242
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
243
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
244
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
245
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
246
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
242
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
243
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
244
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
245
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
246
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
247 247
     
248
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
248
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
249 249
             'invoice'       => $invoice,
250 250
             'email_type'    => $email_type,
251 251
             'email_heading' => $email_heading,
252 252
             'sent_to_admin' => false,
253 253
             'plain_text'    => false,
254 254
             'message_body'  => $message_body,
255
-        ) );
255
+        ));
256 256
     
257
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
257
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
258 258
     
259
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
260
-        $recipient  = wpinv_get_admin_email();
261
-        $subject    .= ' - ADMIN BCC COPY';
262
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
259
+    if (wpinv_mail_admin_bcc_active($email_type)) {
260
+        $recipient = wpinv_get_admin_email();
261
+        $subject .= ' - ADMIN BCC COPY';
262
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
263 263
     }
264 264
 
265
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
265
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
266 266
 
267 267
     return $sent;
268 268
 }
269 269
 
270
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
270
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
271 271
     $email_type = 'processing_invoice';
272
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
272
+    if (!wpinv_email_is_enabled($email_type)) {
273 273
         return false;
274 274
     }
275 275
 
276
-    $invoice = wpinv_get_invoice( $invoice_id );
277
-    if ( empty( $invoice ) ) {
276
+    $invoice = wpinv_get_invoice($invoice_id);
277
+    if (empty($invoice)) {
278 278
         return false;
279 279
     }
280 280
 
281
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
281
+    if (!("wpi_invoice" === $invoice->post_type)) {
282 282
         return false;
283 283
     }
284 284
 
285
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
286
-    if ( !is_email( $recipient ) ) {
285
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
286
+    if (!is_email($recipient)) {
287 287
         return false;
288 288
     }
289 289
 
290
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
290
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
291 291
 
292 292
     $search                     = array();
293 293
     $search['invoice_number']   = '{invoice_number}';
294 294
     $search['invoice_date']     = '{invoice_date}';
295 295
     $search['name']             = '{name}';
296 296
 
297
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
298
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
299
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
300
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
301
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
297
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
298
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
299
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
300
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
301
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
302 302
     
303
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
303
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
304 304
             'invoice'       => $invoice,
305 305
             'email_type'    => $email_type,
306 306
             'email_heading' => $email_heading,
307 307
             'sent_to_admin' => false,
308 308
             'plain_text'    => false,
309 309
             'message_body'  => $message_body,
310
-        ) );
310
+        ));
311 311
 
312
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
312
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
313 313
 
314
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
315
-        $recipient  = wpinv_get_admin_email();
316
-        $subject    .= ' - ADMIN BCC COPY';
317
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
314
+    if (wpinv_mail_admin_bcc_active($email_type)) {
315
+        $recipient = wpinv_get_admin_email();
316
+        $subject .= ' - ADMIN BCC COPY';
317
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
318 318
     }
319 319
 
320
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
320
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
321 321
 
322 322
     return $sent;
323 323
 }
324 324
 
325
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
325
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
326 326
     $email_type = 'completed_invoice';
327
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
327
+    if (!wpinv_email_is_enabled($email_type)) {
328 328
         return false;
329 329
     }
330 330
 
331
-    $invoice = wpinv_get_invoice( $invoice_id );
332
-    if ( empty( $invoice ) ) {
331
+    $invoice = wpinv_get_invoice($invoice_id);
332
+    if (empty($invoice)) {
333 333
         return false;
334 334
     }
335 335
 
336
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
336
+    if (!("wpi_invoice" === $invoice->post_type)) {
337 337
         return false;
338 338
     }
339 339
 
340
-    if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){
340
+    if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) {
341 341
         return false;
342 342
     }
343 343
 
344
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
345
-    if ( !is_email( $recipient ) ) {
344
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
345
+    if (!is_email($recipient)) {
346 346
         return false;
347 347
     }
348 348
 
349
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
349
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
350 350
 
351
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
352
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
353
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
354
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
355
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
351
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
352
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
353
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
354
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
355
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
356 356
 
357
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
357
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
358 358
             'invoice'       => $invoice,
359 359
             'email_type'    => $email_type,
360 360
             'email_heading' => $email_heading,
361 361
             'sent_to_admin' => false,
362 362
             'plain_text'    => false,
363 363
             'message_body'  => $message_body,
364
-        ) );
364
+        ));
365 365
 
366
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
366
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
367 367
 
368
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
369
-        $recipient  = wpinv_get_admin_email();
370
-        $subject    .= ' - ADMIN BCC COPY';
371
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
368
+    if (wpinv_mail_admin_bcc_active($email_type)) {
369
+        $recipient = wpinv_get_admin_email();
370
+        $subject .= ' - ADMIN BCC COPY';
371
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
372 372
     }
373 373
 
374
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
374
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
375 375
 
376 376
     return $sent;
377 377
 }
378 378
 
379
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
379
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
380 380
     $email_type = 'refunded_invoice';
381
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
381
+    if (!wpinv_email_is_enabled($email_type)) {
382 382
         return false;
383 383
     }
384 384
 
385
-    $invoice = wpinv_get_invoice( $invoice_id );
386
-    if ( empty( $invoice ) ) {
385
+    $invoice = wpinv_get_invoice($invoice_id);
386
+    if (empty($invoice)) {
387 387
         return false;
388 388
     }
389 389
 
390
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
390
+    if (!("wpi_invoice" === $invoice->post_type)) {
391 391
         return false;
392 392
     }
393 393
 
394
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
395
-    if ( !is_email( $recipient ) ) {
394
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
395
+    if (!is_email($recipient)) {
396 396
         return false;
397 397
     }
398 398
 
399
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
399
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
400 400
 
401
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
402
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
403
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
404
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
405
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
401
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
402
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
403
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
404
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
405
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
406 406
 
407
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
407
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
408 408
             'invoice'           => $invoice,
409 409
             'email_type'        => $email_type,
410 410
             'email_heading'     => $email_heading,
@@ -412,50 +412,50 @@  discard block
 block discarded – undo
412 412
             'plain_text'        => false,
413 413
             'partial_refund'    => false,
414 414
             'message_body'      => $message_body,
415
-        ) );
415
+        ));
416 416
 
417
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
417
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
418 418
 
419
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
420
-        $recipient  = wpinv_get_admin_email();
421
-        $subject    .= ' - ADMIN BCC COPY';
422
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
419
+    if (wpinv_mail_admin_bcc_active($email_type)) {
420
+        $recipient = wpinv_get_admin_email();
421
+        $subject .= ' - ADMIN BCC COPY';
422
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
423 423
     }
424 424
 
425
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
425
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
426 426
 
427 427
     return $sent;
428 428
 }
429 429
 
430
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
430
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
431 431
     $email_type = 'refunded_invoice';
432
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
432
+    if (!wpinv_email_is_enabled($email_type)) {
433 433
         return false;
434 434
     }
435 435
 
436
-    $invoice = wpinv_get_invoice( $invoice_id );
437
-    if ( empty( $invoice ) ) {
436
+    $invoice = wpinv_get_invoice($invoice_id);
437
+    if (empty($invoice)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
441
+    if (!("wpi_invoice" === $invoice->post_type)) {
442 442
         return false;
443 443
     }
444 444
 
445
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
446
-    if ( !is_email( $recipient ) ) {
445
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
446
+    if (!is_email($recipient)) {
447 447
         return false;
448 448
     }
449 449
 
450
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
450
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
451 451
 
452
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
453
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
454
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
455
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
456
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
452
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
453
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
454
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
455
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
456
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
457 457
 
458
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
458
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
459 459
             'invoice'           => $invoice,
460 460
             'email_type'        => $email_type,
461 461
             'email_heading'     => $email_heading,
@@ -463,95 +463,95 @@  discard block
 block discarded – undo
463 463
             'plain_text'        => false,
464 464
             'partial_refund'    => true,
465 465
             'message_body'      => $message_body,
466
-        ) );
466
+        ));
467 467
 
468
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
468
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
469 469
 
470
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
471
-        $recipient  = wpinv_get_admin_email();
472
-        $subject    .= ' - ADMIN BCC COPY';
473
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
470
+    if (wpinv_mail_admin_bcc_active($email_type)) {
471
+        $recipient = wpinv_get_admin_email();
472
+        $subject .= ' - ADMIN BCC COPY';
473
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
474 474
     }
475 475
 
476
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
476
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
477 477
 
478 478
     return $sent;
479 479
 }
480 480
 
481
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
481
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
482 482
 }
483 483
 
484
-function wpinv_user_invoice_notification( $invoice_id ) {
484
+function wpinv_user_invoice_notification($invoice_id) {
485 485
     $email_type = 'user_invoice';
486
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
486
+    if (!wpinv_email_is_enabled($email_type)) {
487 487
         return -1;
488 488
     }
489 489
 
490
-    $invoice = wpinv_get_invoice( $invoice_id );
491
-    if ( empty( $invoice ) ) {
490
+    $invoice = wpinv_get_invoice($invoice_id);
491
+    if (empty($invoice)) {
492 492
         return false;
493 493
     }
494 494
 
495
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
495
+    if (!("wpi_invoice" === $invoice->post_type)) {
496 496
         return false;
497 497
     }
498 498
 
499
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
500
-    if ( !is_email( $recipient ) ) {
499
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
500
+    if (!is_email($recipient)) {
501 501
         return false;
502 502
     }
503 503
 
504
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
504
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
505 505
 
506
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
507
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
508
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
509
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
510
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
506
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
507
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
508
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
509
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
510
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
511 511
     
512
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
512
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
513 513
             'invoice'       => $invoice,
514 514
             'email_type'    => $email_type,
515 515
             'email_heading' => $email_heading,
516 516
             'sent_to_admin' => false,
517 517
             'plain_text'    => false,
518 518
             'message_body'  => $message_body,
519
-        ) );
519
+        ));
520 520
 
521
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
521
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
522 522
 
523
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
524
-        $recipient  = wpinv_get_admin_email();
525
-        $subject    .= ' - ADMIN BCC COPY';
526
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
523
+    if (wpinv_mail_admin_bcc_active($email_type)) {
524
+        $recipient = wpinv_get_admin_email();
525
+        $subject .= ' - ADMIN BCC COPY';
526
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
527 527
     }
528 528
 
529
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
529
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
530 530
 
531
-    if ( $sent ) {
532
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
531
+    if ($sent) {
532
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
533 533
     } else {
534
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
534
+        $note = __('Fail to send invoice to the user!', 'invoicing');
535 535
     }
536 536
 
537
-    $invoice->add_note( $note, '', '', true ); // Add system note.
537
+    $invoice->add_note($note, '', '', true); // Add system note.
538 538
 
539 539
     return $sent;
540 540
 }
541 541
 
542
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
542
+function wpinv_user_note_notification($invoice_id, $args = array()) {
543 543
     $email_type = 'user_note';
544
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
544
+    if (!wpinv_email_is_enabled($email_type)) {
545 545
         return false;
546 546
     }
547 547
 
548
-    $invoice = wpinv_get_invoice( $invoice_id );
549
-    if ( empty( $invoice ) ) {
548
+    $invoice = wpinv_get_invoice($invoice_id);
549
+    if (empty($invoice)) {
550 550
         return false;
551 551
     }
552 552
 
553
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
554
-    if ( !is_email( $recipient ) ) {
553
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
554
+    if (!is_email($recipient)) {
555 555
         return false;
556 556
     }
557 557
 
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
         'user_note' => ''
560 560
     );
561 561
 
562
-    $args = wp_parse_args( $args, $defaults );
562
+    $args = wp_parse_args($args, $defaults);
563 563
 
564
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
564
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
565 565
 
566
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
567
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
568
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
569
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
570
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
566
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
567
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
568
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
569
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
570
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
571 571
 
572
-    $message_body   = str_replace( '{customer_note}', $args['user_note'], $message_body );
572
+    $message_body   = str_replace('{customer_note}', $args['user_note'], $message_body);
573 573
 
574
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
574
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
575 575
             'invoice'       => $invoice,
576 576
             'email_type'    => $email_type,
577 577
             'email_heading' => $email_heading,
@@ -579,36 +579,36 @@  discard block
 block discarded – undo
579 579
             'plain_text'    => false,
580 580
             'message_body'  => $message_body,
581 581
             'customer_note' => $args['user_note']
582
-        ) );
582
+        ));
583 583
 
584
-    $content        = wpinv_email_format_text( $content, $invoice );
584
+    $content = wpinv_email_format_text($content, $invoice);
585 585
 
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
 
588
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
588
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
589 589
 
590 590
     return $sent;
591 591
 }
592 592
 
593 593
 function wpinv_mail_get_from_address() {
594
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
595
-    return sanitize_email( $from_address );
594
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
595
+    return sanitize_email($from_address);
596 596
 }
597 597
 
598 598
 function wpinv_mail_get_from_name() {
599
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
600
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
599
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
600
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
601 601
 }
602 602
 
603
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
604
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
605
-    return ( $active ? true : false );
603
+function wpinv_mail_admin_bcc_active($mail_type = '') {
604
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
605
+    return ($active ? true : false);
606 606
 }
607 607
     
608
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
609
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
608
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
609
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
610 610
 
611
-    switch ( $email_type ) {
611
+    switch ($email_type) {
612 612
         case 'html' :
613 613
             $content_type = 'text/html';
614 614
             break;
@@ -623,35 +623,35 @@  discard block
 block discarded – undo
623 623
     return $content_type;
624 624
 }
625 625
     
626
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
627
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
628
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
629
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
626
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
627
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
628
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
629
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
630 630
 
631
-    $message = wpinv_email_style_body( $message );
632
-    $message = apply_filters( 'wpinv_mail_content', $message );
631
+    $message = wpinv_email_style_body($message);
632
+    $message = apply_filters('wpinv_mail_content', $message);
633 633
 
634
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
634
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
635 635
 
636
-    if ( !$sent ) {
637
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
638
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
636
+    if (!$sent) {
637
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
638
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
639 639
     }
640 640
 
641
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
642
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
643
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
641
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
642
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
643
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
644 644
 
645 645
     return $sent;
646 646
 }
647 647
     
648 648
 function wpinv_get_emails() {
649 649
     $overdue_days_options       = array();
650
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
651
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
650
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
651
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
652 652
 
653
-    for ( $i = 2; $i <= 10; $i++ ) {
654
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
653
+    for ($i = 2; $i <= 10; $i++) {
654
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
655 655
     }
656 656
 
657 657
     // Default, built-in gateways
@@ -659,39 +659,39 @@  discard block
 block discarded – undo
659 659
             'new_invoice' => array(
660 660
             'email_new_invoice_header' => array(
661 661
                 'id'   => 'email_new_invoice_header',
662
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
663
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
662
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
663
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
664 664
                 'type' => 'header',
665 665
             ),
666 666
             'email_new_invoice_active' => array(
667 667
                 'id'   => 'email_new_invoice_active',
668
-                'name' => __( 'Enable/Disable', 'invoicing' ),
669
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
668
+                'name' => __('Enable/Disable', 'invoicing'),
669
+                'desc' => __('Enable this email notification', 'invoicing'),
670 670
                 'type' => 'checkbox',
671 671
                 'std'  => 1
672 672
             ),
673 673
             'email_new_invoice_subject' => array(
674 674
                 'id'   => 'email_new_invoice_subject',
675
-                'name' => __( 'Subject', 'invoicing' ),
676
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
675
+                'name' => __('Subject', 'invoicing'),
676
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
677 677
                 'type' => 'text',
678
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
678
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
679 679
                 'size' => 'large'
680 680
             ),
681 681
             'email_new_invoice_heading' => array(
682 682
                 'id'   => 'email_new_invoice_heading',
683
-                'name' => __( 'Email Heading', 'invoicing' ),
684
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
683
+                'name' => __('Email Heading', 'invoicing'),
684
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
685 685
                 'type' => 'text',
686
-                'std'  => __( 'New payment invoice', 'invoicing' ),
686
+                'std'  => __('New payment invoice', 'invoicing'),
687 687
                 'size' => 'large'
688 688
             ),
689 689
             'email_new_invoice_body' => array(
690 690
                 'id'   => 'email_new_invoice_body',
691
-                'name' => __( 'Email Content', 'invoicing' ),
692
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
691
+                'name' => __('Email Content', 'invoicing'),
692
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
693 693
                 'type' => 'rich_editor',
694
-                'std'  => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
694
+                'std'  => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
695 695
                 'class' => 'large',
696 696
                 'size' => '10'
697 697
             ),
@@ -699,39 +699,39 @@  discard block
 block discarded – undo
699 699
         'cancelled_invoice' => array(
700 700
             'email_cancelled_invoice_header' => array(
701 701
                 'id'   => 'email_cancelled_invoice_header',
702
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
703
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
702
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
703
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
704 704
                 'type' => 'header',
705 705
             ),
706 706
             'email_cancelled_invoice_active' => array(
707 707
                 'id'   => 'email_cancelled_invoice_active',
708
-                'name' => __( 'Enable/Disable', 'invoicing' ),
709
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
708
+                'name' => __('Enable/Disable', 'invoicing'),
709
+                'desc' => __('Enable this email notification', 'invoicing'),
710 710
                 'type' => 'checkbox',
711 711
                 'std'  => 1
712 712
             ),
713 713
             'email_cancelled_invoice_subject' => array(
714 714
                 'id'   => 'email_cancelled_invoice_subject',
715
-                'name' => __( 'Subject', 'invoicing' ),
716
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
715
+                'name' => __('Subject', 'invoicing'),
716
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
717 717
                 'type' => 'text',
718
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
718
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
719 719
                 'size' => 'large'
720 720
             ),
721 721
             'email_cancelled_invoice_heading' => array(
722 722
                 'id'   => 'email_cancelled_invoice_heading',
723
-                'name' => __( 'Email Heading', 'invoicing' ),
724
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
723
+                'name' => __('Email Heading', 'invoicing'),
724
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
725 725
                 'type' => 'text',
726
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
726
+                'std'  => __('Cancelled invoice', 'invoicing'),
727 727
                 'size' => 'large'
728 728
             ),
729 729
             'email_cancelled_invoice_body' => array(
730 730
                 'id'   => 'email_cancelled_invoice_body',
731
-                'name' => __( 'Email Content', 'invoicing' ),
732
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
731
+                'name' => __('Email Content', 'invoicing'),
732
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
733 733
                 'type' => 'rich_editor',
734
-                'std'  => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
734
+                'std'  => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
735 735
                 'class' => 'large',
736 736
                 'size' => '10'
737 737
             ),
@@ -739,39 +739,39 @@  discard block
 block discarded – undo
739 739
         'failed_invoice' => array(
740 740
             'email_failed_invoice_header' => array(
741 741
                 'id'   => 'email_failed_invoice_header',
742
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
743
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
742
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
743
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
744 744
                 'type' => 'header',
745 745
             ),
746 746
             'email_failed_invoice_active' => array(
747 747
                 'id'   => 'email_failed_invoice_active',
748
-                'name' => __( 'Enable/Disable', 'invoicing' ),
749
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
748
+                'name' => __('Enable/Disable', 'invoicing'),
749
+                'desc' => __('Enable this email notification', 'invoicing'),
750 750
                 'type' => 'checkbox',
751 751
                 'std'  => 1
752 752
             ),
753 753
             'email_failed_invoice_subject' => array(
754 754
                 'id'   => 'email_failed_invoice_subject',
755
-                'name' => __( 'Subject', 'invoicing' ),
756
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
755
+                'name' => __('Subject', 'invoicing'),
756
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
757 757
                 'type' => 'text',
758
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
758
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
759 759
                 'size' => 'large'
760 760
             ),
761 761
             'email_failed_invoice_heading' => array(
762 762
                 'id'   => 'email_failed_invoice_heading',
763
-                'name' => __( 'Email Heading', 'invoicing' ),
764
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
763
+                'name' => __('Email Heading', 'invoicing'),
764
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
765 765
                 'type' => 'text',
766
-                'std'  => __( 'Failed invoice', 'invoicing' ),
766
+                'std'  => __('Failed invoice', 'invoicing'),
767 767
                 'size' => 'large'
768 768
             ),
769 769
             'email_failed_invoice_body' => array(
770 770
                 'id'   => 'email_failed_invoice_body',
771
-                'name' => __( 'Email Content', 'invoicing' ),
772
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
771
+                'name' => __('Email Content', 'invoicing'),
772
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
773 773
                 'type' => 'rich_editor',
774
-                'std'  => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
774
+                'std'  => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
775 775
                 'class' => 'large',
776 776
                 'size' => '10'
777 777
             ),
@@ -779,46 +779,46 @@  discard block
 block discarded – undo
779 779
         'onhold_invoice' => array(
780 780
             'email_onhold_invoice_header' => array(
781 781
                 'id'   => 'email_onhold_invoice_header',
782
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
783
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
782
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
783
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
784 784
                 'type' => 'header',
785 785
             ),
786 786
             'email_onhold_invoice_active' => array(
787 787
                 'id'   => 'email_onhold_invoice_active',
788
-                'name' => __( 'Enable/Disable', 'invoicing' ),
789
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
788
+                'name' => __('Enable/Disable', 'invoicing'),
789
+                'desc' => __('Enable this email notification', 'invoicing'),
790 790
                 'type' => 'checkbox',
791 791
                 'std'  => 1
792 792
             ),
793 793
             'email_onhold_invoice_subject' => array(
794 794
                 'id'   => 'email_onhold_invoice_subject',
795
-                'name' => __( 'Subject', 'invoicing' ),
796
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
795
+                'name' => __('Subject', 'invoicing'),
796
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
797 797
                 'type' => 'text',
798
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
798
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
799 799
                 'size' => 'large'
800 800
             ),
801 801
             'email_onhold_invoice_heading' => array(
802 802
                 'id'   => 'email_onhold_invoice_heading',
803
-                'name' => __( 'Email Heading', 'invoicing' ),
804
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
803
+                'name' => __('Email Heading', 'invoicing'),
804
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
805 805
                 'type' => 'text',
806
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
806
+                'std'  => __('Thank you for your invoice', 'invoicing'),
807 807
                 'size' => 'large'
808 808
             ),
809 809
             'email_onhold_invoice_admin_bcc' => array(
810 810
                 'id'   => 'email_onhold_invoice_admin_bcc',
811
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
812
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
811
+                'name' => __('Enable Admin BCC', 'invoicing'),
812
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
813 813
                 'type' => 'checkbox',
814 814
                 'std'  => 1
815 815
             ),
816 816
             'email_onhold_invoice_body' => array(
817 817
                 'id'   => 'email_onhold_invoice_body',
818
-                'name' => __( 'Email Content', 'invoicing' ),
819
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
818
+                'name' => __('Email Content', 'invoicing'),
819
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
820 820
                 'type' => 'rich_editor',
821
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
821
+                'std'  => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
822 822
                 'class' => 'large',
823 823
                 'size' => '10'
824 824
             ),
@@ -826,46 +826,46 @@  discard block
 block discarded – undo
826 826
         'processing_invoice' => array(
827 827
             'email_processing_invoice_header' => array(
828 828
                 'id'   => 'email_processing_invoice_header',
829
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
829
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_processing_invoice_active' => array(
834 834
                 'id'   => 'email_processing_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_processing_invoice_subject' => array(
841 841
                 'id'   => 'email_processing_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_processing_invoice_heading' => array(
849 849
                 'id'   => 'email_processing_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_processing_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_processing_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
863 863
             'email_processing_invoice_body' => array(
864 864
                 'id'   => 'email_processing_invoice_body',
865
-                'name' => __( 'Email Content', 'invoicing' ),
866
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
865
+                'name' => __('Email Content', 'invoicing'),
866
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
867 867
                 'type' => 'rich_editor',
868
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
868
+                'std'  => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
869 869
                 'class' => 'large',
870 870
                 'size' => '10'
871 871
             ),
@@ -873,52 +873,52 @@  discard block
 block discarded – undo
873 873
         'completed_invoice' => array(
874 874
             'email_completed_invoice_header' => array(
875 875
                 'id'   => 'email_completed_invoice_header',
876
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
877
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
876
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
877
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
878 878
                 'type' => 'header',
879 879
             ),
880 880
             'email_completed_invoice_active' => array(
881 881
                 'id'   => 'email_completed_invoice_active',
882
-                'name' => __( 'Enable/Disable', 'invoicing' ),
883
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
882
+                'name' => __('Enable/Disable', 'invoicing'),
883
+                'desc' => __('Enable this email notification', 'invoicing'),
884 884
                 'type' => 'checkbox',
885 885
                 'std'  => 1
886 886
             ),
887 887
             'email_completed_invoice_renewal_active' => array(
888 888
                 'id'   => 'email_completed_invoice_renewal_active',
889
-                'name' => __( 'Enable renewal notification', 'invoicing' ),
890
-                'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ),
889
+                'name' => __('Enable renewal notification', 'invoicing'),
890
+                'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'),
891 891
                 'type' => 'checkbox',
892 892
                 'std'  => 0
893 893
             ),
894 894
             'email_completed_invoice_subject' => array(
895 895
                 'id'   => 'email_completed_invoice_subject',
896
-                'name' => __( 'Subject', 'invoicing' ),
897
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
896
+                'name' => __('Subject', 'invoicing'),
897
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
898 898
                 'type' => 'text',
899
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
899
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
900 900
                 'size' => 'large'
901 901
             ),
902 902
             'email_completed_invoice_heading' => array(
903 903
                 'id'   => 'email_completed_invoice_heading',
904
-                'name' => __( 'Email Heading', 'invoicing' ),
905
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
904
+                'name' => __('Email Heading', 'invoicing'),
905
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
906 906
                 'type' => 'text',
907
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
907
+                'std'  => __('Your invoice has been paid', 'invoicing'),
908 908
                 'size' => 'large'
909 909
             ),
910 910
             'email_completed_invoice_admin_bcc' => array(
911 911
                 'id'   => 'email_completed_invoice_admin_bcc',
912
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
913
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
912
+                'name' => __('Enable Admin BCC', 'invoicing'),
913
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
914 914
                 'type' => 'checkbox',
915 915
             ),
916 916
             'email_completed_invoice_body' => array(
917 917
                 'id'   => 'email_completed_invoice_body',
918
-                'name' => __( 'Email Content', 'invoicing' ),
919
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
918
+                'name' => __('Email Content', 'invoicing'),
919
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
920 920
                 'type' => 'rich_editor',
921
-                'std'  => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
921
+                'std'  => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
922 922
                 'class' => 'large',
923 923
                 'size' => '10'
924 924
             ),
@@ -927,46 +927,46 @@  discard block
 block discarded – undo
927 927
         'refunded_invoice' => array(
928 928
             'email_refunded_invoice_header' => array(
929 929
                 'id'   => 'email_refunded_invoice_header',
930
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
931
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
930
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
931
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
932 932
                 'type' => 'header',
933 933
             ),
934 934
             'email_refunded_invoice_active' => array(
935 935
                 'id'   => 'email_refunded_invoice_active',
936
-                'name' => __( 'Enable/Disable', 'invoicing' ),
937
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
936
+                'name' => __('Enable/Disable', 'invoicing'),
937
+                'desc' => __('Enable this email notification', 'invoicing'),
938 938
                 'type' => 'checkbox',
939 939
                 'std'  => 1
940 940
             ),
941 941
             'email_refunded_invoice_subject' => array(
942 942
                 'id'   => 'email_refunded_invoice_subject',
943
-                'name' => __( 'Subject', 'invoicing' ),
944
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
943
+                'name' => __('Subject', 'invoicing'),
944
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
945 945
                 'type' => 'text',
946
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
946
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
947 947
                 'size' => 'large'
948 948
             ),
949 949
             'email_refunded_invoice_heading' => array(
950 950
                 'id'   => 'email_refunded_invoice_heading',
951
-                'name' => __( 'Email Heading', 'invoicing' ),
952
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
951
+                'name' => __('Email Heading', 'invoicing'),
952
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
953 953
                 'type' => 'text',
954
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
954
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
955 955
                 'size' => 'large'
956 956
             ),
957 957
             'email_refunded_invoice_admin_bcc' => array(
958 958
                 'id'   => 'email_refunded_invoice_admin_bcc',
959
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
960
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
959
+                'name' => __('Enable Admin BCC', 'invoicing'),
960
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
961 961
                 'type' => 'checkbox',
962 962
                 'std'  => 1
963 963
             ),
964 964
             'email_refunded_invoice_body' => array(
965 965
                 'id'   => 'email_refunded_invoice_body',
966
-                'name' => __( 'Email Content', 'invoicing' ),
967
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
966
+                'name' => __('Email Content', 'invoicing'),
967
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
968 968
                 'type' => 'rich_editor',
969
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
969
+                'std'  => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
970 970
                 'class' => 'large',
971 971
                 'size' => '10'
972 972
             ),
@@ -974,46 +974,46 @@  discard block
 block discarded – undo
974 974
         'user_invoice' => array(
975 975
             'email_user_invoice_header' => array(
976 976
                 'id'   => 'email_user_invoice_header',
977
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
978
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
977
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
978
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
979 979
                 'type' => 'header',
980 980
             ),
981 981
             'email_user_invoice_active' => array(
982 982
                 'id'   => 'email_user_invoice_active',
983
-                'name' => __( 'Enable/Disable', 'invoicing' ),
984
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
983
+                'name' => __('Enable/Disable', 'invoicing'),
984
+                'desc' => __('Enable this email notification', 'invoicing'),
985 985
                 'type' => 'checkbox',
986 986
                 'std'  => 1
987 987
             ),
988 988
             'email_user_invoice_subject' => array(
989 989
                 'id'   => 'email_user_invoice_subject',
990
-                'name' => __( 'Subject', 'invoicing' ),
991
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
990
+                'name' => __('Subject', 'invoicing'),
991
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
992 992
                 'type' => 'text',
993
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
993
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
994 994
                 'size' => 'large'
995 995
             ),
996 996
             'email_user_invoice_heading' => array(
997 997
                 'id'   => 'email_user_invoice_heading',
998
-                'name' => __( 'Email Heading', 'invoicing' ),
999
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
998
+                'name' => __('Email Heading', 'invoicing'),
999
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1000 1000
                 'type' => 'text',
1001
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1001
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1002 1002
                 'size' => 'large'
1003 1003
             ),
1004 1004
             'email_user_invoice_admin_bcc' => array(
1005 1005
                 'id'   => 'email_user_invoice_admin_bcc',
1006
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1007
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1006
+                'name' => __('Enable Admin BCC', 'invoicing'),
1007
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1008 1008
                 'type' => 'checkbox',
1009 1009
                 'std'  => 1
1010 1010
             ),
1011 1011
             'email_user_invoice_body' => array(
1012 1012
                 'id'   => 'email_user_invoice_body',
1013
-                'name' => __( 'Email Content', 'invoicing' ),
1014
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1013
+                'name' => __('Email Content', 'invoicing'),
1014
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1015 1015
                 'type' => 'rich_editor',
1016
-                'std'  => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1016
+                'std'  => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1017 1017
                 'class' => 'large',
1018 1018
                 'size' => '10'
1019 1019
             ),
@@ -1021,39 +1021,39 @@  discard block
 block discarded – undo
1021 1021
         'user_note' => array(
1022 1022
             'email_user_note_header' => array(
1023 1023
                 'id'   => 'email_user_note_header',
1024
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1025
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1024
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1025
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1026 1026
                 'type' => 'header',
1027 1027
             ),
1028 1028
             'email_user_note_active' => array(
1029 1029
                 'id'   => 'email_user_note_active',
1030
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1031
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1030
+                'name' => __('Enable/Disable', 'invoicing'),
1031
+                'desc' => __('Enable this email notification', 'invoicing'),
1032 1032
                 'type' => 'checkbox',
1033 1033
                 'std'  => 1
1034 1034
             ),
1035 1035
             'email_user_note_subject' => array(
1036 1036
                 'id'   => 'email_user_note_subject',
1037
-                'name' => __( 'Subject', 'invoicing' ),
1038
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1037
+                'name' => __('Subject', 'invoicing'),
1038
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1039 1039
                 'type' => 'text',
1040
-                'std'  => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
1040
+                'std'  => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
1041 1041
                 'size' => 'large'
1042 1042
             ),
1043 1043
             'email_user_note_heading' => array(
1044 1044
                 'id'   => 'email_user_note_heading',
1045
-                'name' => __( 'Email Heading', 'invoicing' ),
1046
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1045
+                'name' => __('Email Heading', 'invoicing'),
1046
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1047 1047
                 'type' => 'text',
1048
-                'std'  => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
1048
+                'std'  => __('A note has been added to your {invoice_label}', 'invoicing'),
1049 1049
                 'size' => 'large'
1050 1050
             ),
1051 1051
             'email_user_note_body' => array(
1052 1052
                 'id'   => 'email_user_note_body',
1053
-                'name' => __( 'Email Content', 'invoicing' ),
1054
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1053
+                'name' => __('Email Content', 'invoicing'),
1054
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1055 1055
                 'type' => 'rich_editor',
1056
-                'std'  => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
1056
+                'std'  => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
1057 1057
                 'class' => 'large',
1058 1058
                 'size' => '10'
1059 1059
             ),
@@ -1062,165 +1062,165 @@  discard block
 block discarded – undo
1062 1062
         'overdue' => array(
1063 1063
             'email_overdue_header' => array(
1064 1064
                 'id'   => 'email_overdue_header',
1065
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1066
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1065
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1066
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1067 1067
                 'type' => 'header',
1068 1068
             ),
1069 1069
             'email_overdue_active' => array(
1070 1070
                 'id'   => 'email_overdue_active',
1071
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1072
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1071
+                'name' => __('Enable/Disable', 'invoicing'),
1072
+                'desc' => __('Enable this email notification', 'invoicing'),
1073 1073
                 'type' => 'checkbox',
1074 1074
                 'std'  => 1
1075 1075
             ),
1076 1076
             'email_due_reminder_days' => array(
1077 1077
                 'id'        => 'email_due_reminder_days',
1078
-                'name'      => __( 'When to Send', 'invoicing' ),
1079
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1078
+                'name'      => __('When to Send', 'invoicing'),
1079
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1080 1080
                 'default'   => '',
1081 1081
                 'type'      => 'multicheck',
1082 1082
                 'options'   => $overdue_days_options,
1083 1083
             ),
1084 1084
             'email_overdue_subject' => array(
1085 1085
                 'id'   => 'email_overdue_subject',
1086
-                'name' => __( 'Subject', 'invoicing' ),
1087
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1086
+                'name' => __('Subject', 'invoicing'),
1087
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1088 1088
                 'type' => 'text',
1089
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1089
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1090 1090
                 'size' => 'large'
1091 1091
             ),
1092 1092
             'email_overdue_heading' => array(
1093 1093
                 'id'   => 'email_overdue_heading',
1094
-                'name' => __( 'Email Heading', 'invoicing' ),
1095
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1094
+                'name' => __('Email Heading', 'invoicing'),
1095
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1096 1096
                 'type' => 'text',
1097
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1097
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1098 1098
                 'size' => 'large'
1099 1099
             ),
1100 1100
             'email_overdue_admin_bcc' => array(
1101 1101
                 'id'   => 'email_overdue_admin_bcc',
1102
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1103
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1102
+                'name' => __('Enable Admin BCC', 'invoicing'),
1103
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1104 1104
                 'type' => 'checkbox',
1105 1105
                 'std'  => 1
1106 1106
             ),
1107 1107
             'email_overdue_body' => array(
1108 1108
                 'id'   => 'email_overdue_body',
1109
-                'name' => __( 'Email Content', 'invoicing' ),
1110
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1109
+                'name' => __('Email Content', 'invoicing'),
1110
+                'desc' => __('The content of the email.', 'invoicing'),
1111 1111
                 'type' => 'rich_editor',
1112
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1112
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1113 1113
                 'class' => 'large',
1114 1114
                 'size'  => 10,
1115 1115
             ),
1116 1116
         ),
1117 1117
     );
1118 1118
 
1119
-    return apply_filters( 'wpinv_get_emails', $emails );
1119
+    return apply_filters('wpinv_get_emails', $emails);
1120 1120
 }
1121 1121
 
1122
-function wpinv_settings_emails( $settings = array() ) {
1122
+function wpinv_settings_emails($settings = array()) {
1123 1123
     $emails = wpinv_get_emails();
1124 1124
 
1125
-    if ( !empty( $emails ) ) {
1126
-        foreach ( $emails as $key => $email ) {
1125
+    if (!empty($emails)) {
1126
+        foreach ($emails as $key => $email) {
1127 1127
             $settings[$key] = $email;
1128 1128
         }
1129 1129
     }
1130 1130
 
1131
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1131
+    return apply_filters('wpinv_settings_get_emails', $settings);
1132 1132
 }
1133
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1133
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1134 1134
 
1135
-function wpinv_settings_sections_emails( $settings ) {
1135
+function wpinv_settings_sections_emails($settings) {
1136 1136
     $emails = wpinv_get_emails();
1137 1137
 
1138 1138
     if (!empty($emails)) {
1139
-        foreach  ($emails as $key => $email) {
1140
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1139
+        foreach ($emails as $key => $email) {
1140
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1141 1141
         }
1142 1142
     }
1143 1143
 
1144 1144
     return $settings;    
1145 1145
 }
1146
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1146
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1147 1147
 
1148
-function wpinv_email_is_enabled( $email_type ) {
1148
+function wpinv_email_is_enabled($email_type) {
1149 1149
     $emails = wpinv_get_emails();
1150
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1150
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1151 1151
 
1152
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1152
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1153 1153
 }
1154 1154
 
1155
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1156
-    switch ( $email_type ) {
1155
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1156
+    switch ($email_type) {
1157 1157
         case 'new_invoice':
1158 1158
         case 'cancelled_invoice':
1159 1159
         case 'failed_invoice':
1160 1160
             $recipient  = wpinv_get_admin_email();
1161 1161
         break;
1162 1162
         default:
1163
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1164
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1163
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1164
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1165 1165
         break;
1166 1166
     }
1167 1167
 
1168
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1168
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1169 1169
 }
1170 1170
 
1171
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1172
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1173
-    $subject    = __( $subject, 'invoicing' );
1171
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1172
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1173
+    $subject    = __($subject, 'invoicing');
1174 1174
 
1175
-    $subject    = wpinv_email_format_text( $subject, $invoice );
1175
+    $subject    = wpinv_email_format_text($subject, $invoice);
1176 1176
 
1177
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1177
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1178 1178
 }
1179 1179
 
1180
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1181
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1182
-    $email_heading = __( $email_heading, 'invoicing' );
1180
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1181
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1182
+    $email_heading = __($email_heading, 'invoicing');
1183 1183
 
1184
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
1184
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
1185 1185
 
1186
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1186
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1187 1187
 }
1188 1188
 
1189
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1190
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1191
-    $content    = __( $content, 'invoicing' );
1189
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1190
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1191
+    $content    = __($content, 'invoicing');
1192 1192
 
1193
-    $content    = wpinv_email_format_text( $content, $invoice );
1193
+    $content    = wpinv_email_format_text($content, $invoice);
1194 1194
 
1195
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1195
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1196 1196
 }
1197 1197
 
1198
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1198
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1199 1199
     $from_name = wpinv_mail_get_from_address();
1200 1200
     $from_email = wpinv_mail_get_from_address();
1201 1201
     
1202
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1202
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1203 1203
     
1204
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1205
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1204
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1205
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1206 1206
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1207 1207
     
1208
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1208
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1209 1209
 }
1210 1210
 
1211
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1211
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1212 1212
     $attachments = array();
1213 1213
     
1214
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1214
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1215 1215
 }
1216 1216
 
1217
-function wpinv_email_format_text( $content, $invoice ) {
1217
+function wpinv_email_format_text($content, $invoice) {
1218 1218
     $replace_array = array(
1219 1219
         '{site_title}'      => wpinv_get_blogname(),
1220
-        '{date}'            => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ),
1220
+        '{date}'            => date_i18n(get_option('date_format'), (int) current_time('timestamp')),
1221 1221
     );
1222 1222
     
1223
-    if ( !empty( $invoice->ID ) ) {
1223
+    if (!empty($invoice->ID)) {
1224 1224
         $replace_array = array_merge(
1225 1225
             $replace_array, 
1226 1226
             array(
@@ -1230,65 +1230,65 @@  discard block
 block discarded – undo
1230 1230
                 '{last_name}'       => $invoice->get_last_name(),
1231 1231
                 '{email}'           => $invoice->get_email(),
1232 1232
                 '{invoice_number}'  => $invoice->get_number(),
1233
-                '{invoice_total}'   => $invoice->get_total( true ),
1234
-                '{invoice_link}'    => $invoice->get_view_url( true ),
1235
-                '{invoice_pay_link}'=> $invoice->get_view_url( true ),
1236
-                '{invoice_date}'    => $invoice->get_invoice_date( true ),
1237
-                '{invoice_due_date}'=> $invoice->get_due_date( true ),
1238
-                '{invoice_quote}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1239
-                '{invoice_label}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1240
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
1233
+                '{invoice_total}'   => $invoice->get_total(true),
1234
+                '{invoice_link}'    => $invoice->get_view_url(true),
1235
+                '{invoice_pay_link}'=> $invoice->get_view_url(true),
1236
+                '{invoice_date}'    => $invoice->get_invoice_date(true),
1237
+                '{invoice_due_date}'=> $invoice->get_due_date(true),
1238
+                '{invoice_quote}'   => $invoice->get_invoice_quote_type($invoice->ID),
1239
+                '{invoice_label}'   => $invoice->get_invoice_quote_type($invoice->ID),
1240
+                '{is_was}'          => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'),
1241 1241
             )
1242 1242
         );
1243 1243
     }
1244 1244
 
1245
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
1245
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
1246 1246
 
1247
-    foreach ( $replace_array as $key => $value ) {
1248
-        $content = str_replace( $key, $value, $content );
1247
+    foreach ($replace_array as $key => $value) {
1248
+        $content = str_replace($key, $value, $content);
1249 1249
     }
1250 1250
 
1251
-    return apply_filters( 'wpinv_email_content_replace', $content );
1251
+    return apply_filters('wpinv_email_content_replace', $content);
1252 1252
 }
1253 1253
 
1254
-function wpinv_email_style_body( $content ) {
1254
+function wpinv_email_style_body($content) {
1255 1255
     // make sure we only inline CSS for html emails
1256
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1256
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1257 1257
         ob_start();
1258
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1259
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1258
+        wpinv_get_template('emails/wpinv-email-styles.php');
1259
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1260 1260
 
1261 1261
         // apply CSS styles inline for picky email clients
1262 1262
         try {
1263
-            $emogrifier = new Emogrifier( $content, $css );
1263
+            $emogrifier = new Emogrifier($content, $css);
1264 1264
             $content    = $emogrifier->emogrify();
1265
-        } catch ( Exception $e ) {
1266
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1265
+        } catch (Exception $e) {
1266
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1267 1267
         }
1268 1268
     }
1269 1269
     return $content;
1270 1270
 }
1271 1271
 
1272
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1273
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1272
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1273
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1274 1274
 }
1275 1275
 
1276 1276
 /**
1277 1277
  * Get the email footer.
1278 1278
  */
1279
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1280
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1279
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1280
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1281 1281
 }
1282 1282
 
1283
-function wpinv_email_wrap_message( $message ) {
1283
+function wpinv_email_wrap_message($message) {
1284 1284
     // Buffer
1285 1285
     ob_start();
1286 1286
 
1287
-    do_action( 'wpinv_email_header' );
1287
+    do_action('wpinv_email_header');
1288 1288
 
1289
-    echo wpautop( wptexturize( $message ) );
1289
+    echo wpautop(wptexturize($message));
1290 1290
 
1291
-    do_action( 'wpinv_email_footer' );
1291
+    do_action('wpinv_email_footer');
1292 1292
 
1293 1293
     // Get contents
1294 1294
     $message = ob_get_clean();
@@ -1296,92 +1296,92 @@  discard block
 block discarded – undo
1296 1296
     return $message;
1297 1297
 }
1298 1298
 
1299
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1300
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1299
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1300
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1301 1301
 }
1302 1302
 
1303
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1304
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1303
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1304
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1305 1305
 }
1306 1306
 
1307
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1308
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1307
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1308
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1309 1309
 }
1310 1310
 
1311
-function wpinv_send_customer_invoice( $data = array() ) {
1312
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1311
+function wpinv_send_customer_invoice($data = array()) {
1312
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1313 1313
 
1314
-    if ( empty( $invoice_id ) ) {
1314
+    if (empty($invoice_id)) {
1315 1315
         return;
1316 1316
     }
1317 1317
 
1318
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
1319
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1318
+    if (!wpinv_current_user_can_manage_invoicing()) {
1319
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1320 1320
     }
1321 1321
     
1322
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1322
+    $sent = wpinv_user_invoice_notification($invoice_id);
1323 1323
 
1324 1324
     if ( -1 === $sent ) {
1325 1325
         $status = 'email_disabled';
1326
-    } elseif ( $sent ) {
1326
+    } elseif ($sent) {
1327 1327
         $status = 'email_sent';
1328 1328
     } else {
1329 1329
         $status = 'email_fail';
1330 1330
     }
1331 1331
 
1332
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1333
-    wp_redirect( $redirect );
1332
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1333
+    wp_redirect($redirect);
1334 1334
     exit;
1335 1335
 }
1336
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1336
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1337 1337
 
1338
-function wpinv_send_overdue_reminder( $data = array() ) {
1339
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1338
+function wpinv_send_overdue_reminder($data = array()) {
1339
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1340 1340
 
1341
-    if ( empty( $invoice_id ) ) {
1341
+    if (empty($invoice_id)) {
1342 1342
         return;
1343 1343
     }
1344 1344
 
1345
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
1346
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1345
+    if (!wpinv_current_user_can_manage_invoicing()) {
1346
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1347 1347
     }
1348 1348
 
1349
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1349
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1350 1350
     
1351 1351
     $status = $sent ? 'email_sent' : 'email_fail';
1352 1352
 
1353
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1354
-    wp_redirect( $redirect );
1353
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1354
+    wp_redirect($redirect);
1355 1355
     exit;
1356 1356
 }
1357
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1357
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1358 1358
 
1359
-function wpinv_send_customer_note_email( $data ) {
1360
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1359
+function wpinv_send_customer_note_email($data) {
1360
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1361 1361
 
1362
-    if ( empty( $invoice_id ) ) {
1362
+    if (empty($invoice_id)) {
1363 1363
         return;
1364 1364
     }
1365 1365
 
1366
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1366
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1367 1367
 }
1368
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1368
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1369 1369
 
1370
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1371
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1372
-        $date_format = get_option( 'date_format' );
1373
-        $time_format = get_option( 'time_format' );
1370
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1371
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1372
+        $date_format = get_option('date_format');
1373
+        $time_format = get_option('time_format');
1374 1374
         ?>
1375 1375
         <div id="wpinv-email-notes">
1376
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1376
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1377 1377
             <ol class="wpinv-notes-lists">
1378 1378
         <?php
1379
-        foreach ( $invoice_notes as $note ) {
1380
-            $note_time = strtotime( $note->comment_date );
1379
+        foreach ($invoice_notes as $note) {
1380
+            $note_time = strtotime($note->comment_date);
1381 1381
             ?>
1382 1382
             <li class="comment wpinv-note">
1383
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1384
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1383
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1384
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1385 1385
             </li>
1386 1386
             <?php
1387 1387
         }
@@ -1390,21 +1390,21 @@  discard block
 block discarded – undo
1390 1390
         <?php
1391 1391
     }
1392 1392
 }
1393
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1393
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1394 1394
 
1395 1395
 function wpinv_email_payment_reminders() {
1396 1396
     global $wpi_auto_reminder;
1397
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1397
+    if (!wpinv_get_option('email_overdue_active')) {
1398 1398
         return;
1399 1399
     }
1400 1400
 
1401
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1402
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1401
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1402
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1403 1403
 
1404
-        if ( empty( $reminder_days ) ) {
1404
+        if (empty($reminder_days)) {
1405 1405
             return;
1406 1406
         }
1407
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1407
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1408 1408
 
1409 1409
         $args = array(
1410 1410
             'post_type'     => 'wpi_invoice',
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
             'meta_query'    => array(
1415 1415
                 array(
1416 1416
                     'key'       =>  '_wpinv_due_date',
1417
-                    'value'     =>  array( '', 'none' ),
1417
+                    'value'     =>  array('', 'none'),
1418 1418
                     'compare'   =>  'NOT IN',
1419 1419
                 )
1420 1420
             ),
@@ -1423,149 +1423,149 @@  discard block
 block discarded – undo
1423 1423
             'order'         => 'ASC',
1424 1424
         );
1425 1425
 
1426
-        $invoices = get_posts( $args );
1426
+        $invoices = get_posts($args);
1427 1427
 
1428
-        if ( empty( $invoices ) ) {
1428
+        if (empty($invoices)) {
1429 1429
             return;
1430 1430
         }
1431 1431
 
1432
-        $date_to_send   = array();
1432
+        $date_to_send = array();
1433 1433
 
1434
-        foreach ( $invoices as $id ) {
1435
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1434
+        foreach ($invoices as $id) {
1435
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1436 1436
 
1437
-            foreach ( $reminder_days as $key => $days ) {
1438
-                if ( $days !== '' ) {
1439
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1437
+            foreach ($reminder_days as $key => $days) {
1438
+                if ($days !== '') {
1439
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1440 1440
                 }
1441 1441
             }
1442 1442
         }
1443 1443
 
1444
-        $today              = date_i18n( 'Y-m-d' );
1444
+        $today              = date_i18n('Y-m-d');
1445 1445
         $wpi_auto_reminder  = true;
1446 1446
 
1447
-        foreach ( $date_to_send as $id => $values ) {
1448
-            if ( in_array( $today, $values ) ) {
1449
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1447
+        foreach ($date_to_send as $id => $values) {
1448
+            if (in_array($today, $values)) {
1449
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1450 1450
 
1451
-                if ( isset( $sent ) && !empty( $sent ) ) {
1452
-                    if ( !in_array( $today, $sent ) ) {
1453
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1451
+                if (isset($sent) && !empty($sent)) {
1452
+                    if (!in_array($today, $sent)) {
1453
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1454 1454
                     }
1455 1455
                 } else {
1456
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1456
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1457 1457
                 }
1458 1458
             }
1459 1459
         }
1460 1460
 
1461
-        $wpi_auto_reminder  = false;
1461
+        $wpi_auto_reminder = false;
1462 1462
     }
1463 1463
 }
1464 1464
 
1465
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1465
+function wpinv_send_payment_reminder_notification($invoice_id) {
1466 1466
     $email_type = 'overdue';
1467
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1467
+    if (!wpinv_email_is_enabled($email_type)) {
1468 1468
         return false;
1469 1469
     }
1470 1470
 
1471
-    $invoice    = wpinv_get_invoice( $invoice_id );
1472
-    if ( empty( $invoice ) ) {
1471
+    $invoice = wpinv_get_invoice($invoice_id);
1472
+    if (empty($invoice)) {
1473 1473
         return false;
1474 1474
     }
1475 1475
 
1476
-    if ( !$invoice->needs_payment() ) {
1476
+    if (!$invoice->needs_payment()) {
1477 1477
         return false;
1478 1478
     }
1479 1479
 
1480
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1481
-    if ( !is_email( $recipient ) ) {
1480
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1481
+    if (!is_email($recipient)) {
1482 1482
         return false;
1483 1483
     }
1484 1484
 
1485
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
1485
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
1486 1486
 
1487
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1488
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1489
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1490
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1491
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1487
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1488
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1489
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1490
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1491
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1492 1492
 
1493
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1493
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1494 1494
             'invoice'       => $invoice,
1495 1495
             'email_type'    => $email_type,
1496 1496
             'email_heading' => $email_heading,
1497 1497
             'sent_to_admin' => false,
1498 1498
             'plain_text'    => false,
1499 1499
             'message_body'  => $message_body
1500
-        ) );
1500
+        ));
1501 1501
 
1502
-    $content        = wpinv_email_format_text( $content, $invoice );
1502
+    $content = wpinv_email_format_text($content, $invoice);
1503 1503
 
1504
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1505
-    if ( $sent ) {
1506
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1504
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1505
+    if ($sent) {
1506
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1507 1507
     }
1508 1508
 
1509
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
1510
-        $recipient  = wpinv_get_admin_email();
1511
-        $subject    .= ' - ADMIN BCC COPY';
1512
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1509
+    if (wpinv_mail_admin_bcc_active($email_type)) {
1510
+        $recipient = wpinv_get_admin_email();
1511
+        $subject .= ' - ADMIN BCC COPY';
1512
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1513 1513
     }
1514 1514
 
1515
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
1515
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
1516 1516
 
1517 1517
     return $sent;
1518 1518
 }
1519
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1519
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1520 1520
 
1521
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1521
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1522 1522
     global $wpi_auto_reminder;
1523 1523
 
1524
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1524
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1525 1525
 
1526
-    if ( empty( $sent ) ) {
1526
+    if (empty($sent)) {
1527 1527
         $sent = array();
1528 1528
     }
1529
-    $sent[] = date_i18n( 'Y-m-d' );
1529
+    $sent[] = date_i18n('Y-m-d');
1530 1530
 
1531
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1531
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1532 1532
 
1533
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1534
-        $note = __( 'Automated reminder sent to the user.', 'invoicing' );
1535
-        $invoice->add_note( $note, false, false, true );
1533
+    if ($wpi_auto_reminder) { // Auto reminder note.
1534
+        $note = __('Automated reminder sent to the user.', 'invoicing');
1535
+        $invoice->add_note($note, false, false, true);
1536 1536
     } else { // Menual reminder note.
1537
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1538
-        $invoice->add_note( $note );
1537
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1538
+        $invoice->add_note($note);
1539 1539
     }
1540 1540
 }
1541
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1541
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1542 1542
 
1543
-function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) {
1544
-    if ( empty( $invoice ) ) {
1543
+function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) {
1544
+    if (empty($invoice)) {
1545 1545
         return;
1546 1546
     }
1547 1547
 
1548
-    if ( is_int( $invoice ) ) {
1549
-        $invoice = wpinv_get_invoice( $invoice );
1548
+    if (is_int($invoice)) {
1549
+        $invoice = wpinv_get_invoice($invoice);
1550 1550
     }
1551 1551
 
1552
-    if ( ! empty( $invoice ) && is_object( $invoice ) ) {
1553
-        if ( ! $site && function_exists( 'get_user_locale' ) ) {
1554
-            $locale = get_user_locale( $invoice->get_user_id() );
1552
+    if (!empty($invoice) && is_object($invoice)) {
1553
+        if (!$site && function_exists('get_user_locale')) {
1554
+            $locale = get_user_locale($invoice->get_user_id());
1555 1555
         } else {
1556 1556
             $locale = get_locale();
1557 1557
         }
1558 1558
 
1559
-        wpinv_switch_to_locale( $locale );
1559
+        wpinv_switch_to_locale($locale);
1560 1560
     }
1561 1561
 }
1562
-add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 );
1562
+add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3);
1563 1563
 
1564
-function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) {
1565
-    if ( empty( $invoice ) ) {
1564
+function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) {
1565
+    if (empty($invoice)) {
1566 1566
         return;
1567 1567
     }
1568 1568
 
1569 1569
     wpinv_restore_locale();
1570 1570
 }
1571
-add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 );
1571
+add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3);
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,74 +1,74 @@  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
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-shortcode', __( 'Shortcode', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-shortcode', __('Shortcode', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_shortcode', 'wpi_payment_form', 'side');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
     
35
-    if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
36
-        add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
35
+    if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
36
+        add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
37 37
     }
38 38
 
39 39
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40 40
 }
41
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
41
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
42 42
 
43
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
44
-    remove_action( 'save_post', __FUNCTION__ );
43
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
44
+    remove_action('save_post', __FUNCTION__);
45 45
     
46 46
     // $post_id and $post are required
47
-    if ( empty( $post_id ) || empty( $post ) ) {
47
+    if (empty($post_id) || empty($post)) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
51
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
52 52
         return;
53 53
     }
54 54
     
55 55
     // Dont' save meta boxes for revisions or autosaves
56
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
56
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
57 57
         return;
58 58
     }
59 59
         
60
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
61
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
60
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
61
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
62 62
             return;
63 63
         }
64 64
     
65
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
66
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
65
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
66
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
67 67
         }
68
-    } else if ( $post->post_type == 'wpi_item' ) {
68
+    } else if ($post->post_type == 'wpi_item') {
69 69
         // verify nonce
70
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
71
-            $fields                                 = array();
70
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
71
+            $fields = array();
72 72
             $fields['_wpinv_price']              = 'wpinv_item_price';
73 73
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
74 74
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -83,96 +83,96 @@  discard block
 block discarded – undo
83 83
             $fields['_wpinv_dynamic_pricing']    = 'wpinv_name_your_price';
84 84
             $fields['_minimum_price']            = 'wpinv_minimum_price';
85 85
             
86
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
86
+            if (!isset($_POST['wpinv_is_recurring'])) {
87 87
                 $_POST['wpinv_is_recurring'] = 0;
88 88
             }
89 89
 
90
-            if ( !isset( $_POST['wpinv_name_your_price'] ) ) {
90
+            if (!isset($_POST['wpinv_name_your_price'])) {
91 91
                 $_POST['wpinv_name_your_price'] = 0;
92 92
             }
93 93
             
94
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
94
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
95 95
                 $_POST['wpinv_free_trial'] = 0;
96 96
             }
97 97
             
98
-            foreach ( $fields as $field => $name ) {
99
-                if ( isset( $_POST[ $name ] ) ) {
100
-                    $allowed = apply_filters( 'wpinv_item_allowed_save_meta_value', true, $field, $post_id );
98
+            foreach ($fields as $field => $name) {
99
+                if (isset($_POST[$name])) {
100
+                    $allowed = apply_filters('wpinv_item_allowed_save_meta_value', true, $field, $post_id);
101 101
 
102
-                    if ( !$allowed ) {
102
+                    if (!$allowed) {
103 103
                         continue;
104 104
                     }
105 105
 
106
-                    if ( $field == '_wpinv_price' ) {
107
-                        $value = wpinv_sanitize_amount( $_POST[ $name ] );
106
+                    if ($field == '_wpinv_price') {
107
+                        $value = wpinv_sanitize_amount($_POST[$name]);
108 108
                     } else {
109
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
109
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
110 110
                     }
111 111
                     
112
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
113
-                    update_post_meta( $post_id, $field, $value );
112
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
113
+                    update_post_meta($post_id, $field, $value);
114 114
                 }
115 115
             }
116 116
             
117
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
118
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
117
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
118
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
119 119
             }
120 120
         }
121 121
     }
122 122
 }
123
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
123
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
124 124
 
125 125
 function wpinv_register_item_meta_boxes() {    
126 126
     global $wpinv_euvat;
127 127
     
128
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
128
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
129 129
 
130
-    if ( $wpinv_euvat->allow_vat_rules() ) {
131
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
130
+    if ($wpinv_euvat->allow_vat_rules()) {
131
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
132 132
     }
133 133
     
134
-    if ( $wpinv_euvat->allow_vat_classes() ) {
135
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
134
+    if ($wpinv_euvat->allow_vat_classes()) {
135
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
136 136
     }
137 137
     
138
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
139
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
138
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
139
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
140 140
 }
141 141
 
142 142
 function wpinv_register_discount_meta_boxes() {
143
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
143
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
144 144
 }
145 145
 
146
-function wpinv_discount_metabox_details( $post ) {
146
+function wpinv_discount_metabox_details($post) {
147 147
     $discount_id    = $post->ID;
148
-    $discount       = wpinv_get_discount( $discount_id );
148
+    $discount       = wpinv_get_discount($discount_id);
149 149
     
150
-    $type               = wpinv_get_discount_type( $discount_id );
151
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
152
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
153
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
154
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
155
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
156
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
157
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
158
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
159
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
150
+    $type               = wpinv_get_discount_type($discount_id);
151
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
152
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
153
+    $min_total          = wpinv_get_discount_min_total($discount_id);
154
+    $max_total          = wpinv_get_discount_max_total($discount_id);
155
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
156
+    $single_use         = wpinv_discount_is_single_use($discount_id);
157
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
158
+    $start_date         = wpinv_get_discount_start_date($discount_id);
159
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
160 160
     
161
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
162
-        $start_time         = strtotime( $start_date );
163
-        $start_h            = date_i18n( 'H', $start_time );
164
-        $start_m            = date_i18n( 'i', $start_time );
165
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
161
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
162
+        $start_time         = strtotime($start_date);
163
+        $start_h            = date_i18n('H', $start_time);
164
+        $start_m            = date_i18n('i', $start_time);
165
+        $start_date         = date_i18n('Y-m-d', $start_time);
166 166
     } else {
167 167
         $start_h            = '00';
168 168
         $start_m            = '00';
169 169
     }
170 170
 
171
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
172
-        $expiration_time    = strtotime( $expiration_date );
173
-        $expiration_h       = date_i18n( 'H', $expiration_time );
174
-        $expiration_m       = date_i18n( 'i', $expiration_time );
175
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
171
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
172
+        $expiration_time    = strtotime($expiration_date);
173
+        $expiration_h       = date_i18n('H', $expiration_time);
174
+        $expiration_m       = date_i18n('i', $expiration_time);
175
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
176 176
     } else {
177 177
         $expiration_h       = '23';
178 178
         $expiration_m       = '59';
@@ -182,207 +182,207 @@  discard block
 block discarded – undo
182 182
     $max_total          = $max_total > 0 ? $max_total : '';
183 183
     $max_uses           = $max_uses > 0 ? $max_uses : '';
184 184
 ?>
185
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
186
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
185
+<?php do_action('wpinv_discount_form_top', $post); ?>
186
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
187 187
 <table class="form-table wpi-form-table">
188 188
     <tbody>
189
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
190
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
189
+        <?php do_action('wpinv_discount_form_first', $post); ?>
190
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
191 191
         <tr>
192 192
             <th valign="top" scope="row">
193
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
193
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
194 194
             </th>
195 195
             <td>
196
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
197
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
196
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
197
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
198 198
             </td>
199 199
         </tr>
200
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
200
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
201 201
         <tr>
202 202
             <th valign="top" scope="row">
203
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
203
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
204 204
             </th>
205 205
             <td>
206 206
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
207
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
208
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
207
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
208
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
209 209
                     <?php } ?>
210 210
                 </select>
211
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
211
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
212 212
             </td>
213 213
         </tr>
214
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
214
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
215 215
         <tr>
216 216
             <th valign="top" scope="row">
217
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
217
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
218 218
             </th>
219 219
             <td>
220
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
221
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
222
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
220
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
221
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
222
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
223 223
             </td>
224 224
         </tr>
225
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
225
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
226 226
         <tr>
227 227
             <th valign="top" scope="row">
228
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
228
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
229 229
             </th>
230 230
             <td>
231
-                <p><?php echo wpinv_item_dropdown( array(
231
+                <p><?php echo wpinv_item_dropdown(array(
232 232
                         'name'              => 'items[]',
233 233
                         'id'                => 'items',
234 234
                         'selected'          => $item_reqs,
235 235
                         'multiple'          => true,
236 236
                         'class'             => 'medium-text wpi_select2',
237
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
237
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
238 238
                         'show_recurring'    => true,
239
-                    ) ); ?>
239
+                    )); ?>
240 240
                 </p>
241
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
241
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
242 242
             </td>
243 243
         </tr>
244
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
244
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
245 245
         <tr>
246 246
             <th valign="top" scope="row">
247
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
247
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
248 248
             </th>
249 249
             <td>
250
-                <p><?php echo wpinv_item_dropdown( array(
250
+                <p><?php echo wpinv_item_dropdown(array(
251 251
                         'name'              => 'excluded_items[]',
252 252
                         'id'                => 'excluded_items',
253 253
                         'selected'          => $excluded_items,
254 254
                         'multiple'          => true,
255 255
                         'class'             => 'medium-text wpi_select2',
256
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
256
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
257 257
                         'show_recurring'    => true,
258
-                    ) ); ?>
258
+                    )); ?>
259 259
                 </p>
260
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
260
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
261 261
             </td>
262 262
         </tr>
263
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
263
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
264 264
         <tr>
265 265
             <th valign="top" scope="row">
266
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
266
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
267 267
             </th>
268 268
             <td>
269
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
270
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
271
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
269
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
270
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
271
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
272 272
                     <?php } ?>
273 273
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
274
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
275
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
274
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
275
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
276 276
                     <?php } ?>
277 277
                 </select>
278
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
278
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
279 279
             </td>
280 280
         </tr>
281
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
281
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
282 282
         <tr>
283 283
             <th valign="top" scope="row">
284
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
284
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
285 285
             </th>
286 286
             <td>
287
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
288
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
289
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
287
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
288
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
289
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
290 290
                     <?php } ?>
291 291
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
292
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
293
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
292
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
293
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
294 294
                     <?php } ?>
295 295
                 </select>
296
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
296
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
297 297
             </td>
298 298
         </tr>
299
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
299
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
300 300
         <tr>
301 301
             <th valign="top" scope="row">
302
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
302
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
303 303
             </th>
304 304
             <td>
305 305
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
306
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
306
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
307 307
             </td>
308 308
         </tr>
309
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
309
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
310 310
         <tr>
311 311
             <th valign="top" scope="row">
312
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
312
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
313 313
             </th>
314 314
             <td>
315 315
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
316
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
316
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
317 317
             </td>
318 318
         </tr>
319
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
319
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
320 320
         <tr>
321 321
             <th valign="top" scope="row">
322
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
322
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
323 323
             </th>
324 324
             <td>
325 325
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
326
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
327
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
326
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
327
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
328 328
                 </select>
329
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
329
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
330 330
             </td>
331 331
         </tr>
332
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
332
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
333 333
         <tr>
334 334
             <th valign="top" scope="row">
335
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
335
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
336 336
             </th>
337 337
             <td>
338 338
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
339
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
339
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
340 340
             </td>
341 341
         </tr>
342
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
342
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
343 343
         <tr>
344 344
             <th valign="top" scope="row">
345
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
345
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
346 346
             </th>
347 347
             <td>
348
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
349
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
348
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
349
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
350 350
             </td>
351 351
         </tr>
352
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
352
+        <?php do_action('wpinv_discount_form_last', $post); ?>
353 353
     </tbody>
354 354
 </table>
355
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
355
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
356 356
     <?php
357 357
 }
358 358
 
359
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
360
-    $post_type = !empty( $post ) ? $post->post_type : '';
359
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
360
+    $post_type = !empty($post) ? $post->post_type : '';
361 361
     
362
-    if ( $post_type != 'wpi_discount' ) {
362
+    if ($post_type != 'wpi_discount') {
363 363
         return;
364 364
     }
365 365
     
366
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
366
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
367 367
         return;
368 368
     }
369 369
     
370
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
370
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
371 371
         return;
372 372
     }
373 373
     
374
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
374
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
375 375
         return;
376 376
     }
377 377
     
378
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
378
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
379 379
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
380 380
     }
381 381
 
382
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
382
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
383 383
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
384 384
     }
385 385
     
386
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
386
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
387 387
 }
388
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
389 388
\ No newline at end of file
389
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
390 390
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-user-functions.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC' ) {
6
-    if ( empty( $user ) ) {
5
+function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish', $orderby = 'ID', $order = 'DESC') {
6
+    if (empty($user)) {
7 7
         $user = get_current_user_id();
8 8
     }
9 9
 
10
-    if ( empty( $user ) ) {
10
+    if (empty($user)) {
11 11
         return false;
12 12
     }
13 13
 
14
-    $args = apply_filters( 'wpinv_get_users_invoices_args', array( 'user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order ) );
14
+    $args = apply_filters('wpinv_get_users_invoices_args', array('user' => $user, 'limit' => $number, 'status' => $status, 'paginate' => $pagination, 'orderby' => $orderby, 'order' => $order));
15 15
     
16
-    return wpinv_get_invoices( $args );
16
+    return wpinv_get_invoices($args);
17 17
 }
18 18
 
19
-function wpinv_dropdown_users( $args = '' ) {
19
+function wpinv_dropdown_users($args = '') {
20 20
     $defaults = array(
21 21
         'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '',
22 22
         'orderby' => 'display_name', 'order' => 'ASC',
@@ -27,18 +27,18 @@  discard block
 block discarded – undo
27 27
         'option_none_value' => -1
28 28
     );
29 29
 
30
-    $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
30
+    $defaults['selected'] = is_author() ? get_query_var('author') : 0;
31 31
 
32
-    $r = wp_parse_args( $args, $defaults );
32
+    $r = wp_parse_args($args, $defaults);
33 33
 
34
-    $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
34
+    $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who'));
35 35
 
36
-    $fields = array( 'ID', 'user_login', 'user_email' );
36
+    $fields = array('ID', 'user_login', 'user_email');
37 37
 
38
-    $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name';
39
-    if ( 'display_name_with_login' === $show ) {
38
+    $show = !empty($r['show']) ? $r['show'] : 'display_name';
39
+    if ('display_name_with_login' === $show) {
40 40
         $fields[] = 'display_name';
41
-    } else if ( 'display_name_with_email' === $show ) {
41
+    } else if ('display_name_with_email' === $show) {
42 42
         $fields[] = 'display_name';
43 43
     } else {
44 44
         $fields[] = $show;
@@ -50,99 +50,99 @@  discard block
 block discarded – undo
50 50
     $show_option_none = $r['show_option_none'];
51 51
     $option_none_value = $r['option_none_value'];
52 52
 
53
-    $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r );
53
+    $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r);
54 54
 
55
-    $users = get_users( $query_args );
55
+    $users = get_users($query_args);
56 56
 
57 57
     $output = '';
58
-    if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
59
-        $name = esc_attr( $r['name'] );
60
-        if ( $r['multi'] && ! $r['id'] ) {
58
+    if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) {
59
+        $name = esc_attr($r['name']);
60
+        if ($r['multi'] && !$r['id']) {
61 61
             $id = '';
62 62
         } else {
63
-            $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'";
63
+            $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'";
64 64
         }
65 65
         $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n";
66 66
 
67
-        if ( $show_option_all ) {
67
+        if ($show_option_all) {
68 68
             $output .= "\t<option value='0'>$show_option_all</option>\n";
69 69
         }
70 70
 
71
-        if ( $show_option_none ) {
72
-            $_selected = selected( $option_none_value, $r['selected'], false );
73
-            $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n";
71
+        if ($show_option_none) {
72
+            $_selected = selected($option_none_value, $r['selected'], false);
73
+            $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n";
74 74
         }
75 75
 
76
-        if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) {
76
+        if ($r['include_selected'] && ($r['selected'] > 0)) {
77 77
             $found_selected = false;
78 78
             $r['selected'] = (int) $r['selected'];
79
-            foreach ( (array) $users as $user ) {
79
+            foreach ((array) $users as $user) {
80 80
                 $user->ID = (int) $user->ID;
81
-                if ( $user->ID === $r['selected'] ) {
81
+                if ($user->ID === $r['selected']) {
82 82
                     $found_selected = true;
83 83
                 }
84 84
             }
85 85
 
86
-            if ( ! $found_selected ) {
87
-                $users[] = get_userdata( $r['selected'] );
86
+            if (!$found_selected) {
87
+                $users[] = get_userdata($r['selected']);
88 88
             }
89 89
         }
90 90
 
91
-        foreach ( (array) $users as $user ) {
92
-            if ( 'display_name_with_login' === $show ) {
91
+        foreach ((array) $users as $user) {
92
+            if ('display_name_with_login' === $show) {
93 93
                 /* translators: 1: display name, 2: user_login */
94
-                $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login );
95
-            } elseif ( 'display_name_with_email' === $show ) {
94
+                $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login);
95
+            } elseif ('display_name_with_email' === $show) {
96 96
                 /* translators: 1: display name, 2: user_email */
97
-                if ( $user->display_name == $user->user_email ) {
97
+                if ($user->display_name == $user->user_email) {
98 98
                     $display = $user->display_name;
99 99
                 } else {
100
-                    $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email );
100
+                    $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email);
101 101
                 }
102
-            } elseif ( ! empty( $user->$show ) ) {
102
+            } elseif (!empty($user->$show)) {
103 103
                 $display = $user->$show;
104 104
             } else {
105 105
                 $display = '(' . $user->user_login . ')';
106 106
             }
107 107
 
108
-            $_selected = selected( $user->ID, $r['selected'], false );
109
-            $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
108
+            $_selected = selected($user->ID, $r['selected'], false);
109
+            $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
110 110
         }
111 111
 
112 112
         $output .= "</select>";
113 113
     }
114 114
 
115
-    $html = apply_filters( 'wpinv_dropdown_users', $output );
115
+    $html = apply_filters('wpinv_dropdown_users', $output);
116 116
 
117
-    if ( $r['echo'] ) {
117
+    if ($r['echo']) {
118 118
         echo $html;
119 119
     }
120 120
     return $html;
121 121
 }
122 122
 
123
-function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) {
124
-    if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) {
125
-        wpinv_login_user( $user_id );
123
+function wpinv_guest_redirect($redirect_to, $user_id = 0) {
124
+    if ((int) wpinv_get_option('guest_checkout') && $user_id > 0) {
125
+        wpinv_login_user($user_id);
126 126
     } else {
127
-        $redirect_to = wp_login_url( $redirect_to );
127
+        $redirect_to = wp_login_url($redirect_to);
128 128
     }
129 129
     
130
-    $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id );
130
+    $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id);
131 131
     
132
-    wp_redirect( $redirect_to );
132
+    wp_redirect($redirect_to);
133 133
 }
134 134
 
135
-function wpinv_login_user( $user_id ) {
136
-    if ( is_user_logged_in() ) {
135
+function wpinv_login_user($user_id) {
136
+    if (is_user_logged_in()) {
137 137
         return true;
138 138
     }
139 139
     
140
-    $user = get_user_by( 'id', $user_id );
140
+    $user = get_user_by('id', $user_id);
141 141
     
142
-    if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) {
143
-        wp_set_current_user( $user_id, $user->user_login );
144
-        wp_set_auth_cookie( $user_id );
145
-        do_action( 'wp_login', $user->user_login );
142
+    if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) {
143
+        wp_set_current_user($user_id, $user->user_login);
144
+        wp_set_auth_cookie($user_id);
145
+        do_action('wp_login', $user->user_login);
146 146
         
147 147
         return true;
148 148
     }
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
  * @return string capability to check against
158 158
  * @param string $capalibilty Optional. The alternative capability to check against.
159 159
  */
160
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
160
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
161 161
 
162
-	if ( current_user_can( 'manage_options' ) ) {
162
+	if (current_user_can('manage_options')) {
163 163
 		return 'manage_options';
164 164
 	};
165 165
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  * @return bool
174 174
  */
175 175
 function wpinv_current_user_can_manage_invoicing() {
176
-    return current_user_can( wpinv_get_capability() );
176
+    return current_user_can(wpinv_get_capability());
177 177
 }
178 178
 
179 179
 /**
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
  * @since 1.0.19
183 183
  * @return int|WP_Error
184 184
  */
185
-function wpinv_create_user( $email ) {
185
+function wpinv_create_user($email) {
186 186
 
187 187
     // Prepare user values.
188 188
 	$args = array(
189
-		'user_login' => wpinv_generate_user_name( $email ),
189
+		'user_login' => wpinv_generate_user_name($email),
190 190
 		'user_pass'  => wp_generate_password(),
191 191
 		'user_email' => $email,
192 192
 		'role'       => 'subscriber',
193 193
     );
194 194
         
195
-    return wp_insert_user( $args );
195
+    return wp_insert_user($args);
196 196
 
197 197
 }
198 198
 
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
  * @since 1.0.19
203 203
  * @return bool|WP_User
204 204
  */
205
-function wpinv_generate_user_name( $prefix = '' ) {
205
+function wpinv_generate_user_name($prefix = '') {
206 206
 
207 207
     // If prefix is an email, retrieve the part before the email.
208
-	$prefix = strtok( $prefix, '@' );
208
+	$prefix = strtok($prefix, '@');
209 209
 
210 210
 	// Trim to 4 characters max.
211
-	$prefix = sanitize_user( substr( $prefix, 0, 4 ) );
211
+	$prefix = sanitize_user(substr($prefix, 0, 4));
212 212
 
213
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
214
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
213
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
214
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
215 215
 		$prefix = 'paywp';
216 216
 	}
217 217
 
218
-	$username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 );
219
-	if ( username_exists( $username ) ) {
220
-		return wpinv_generate_user_name( $username );
218
+	$username = $prefix . '_' . zeroise(wp_rand(0, 9999), 4);
219
+	if (username_exists($username)) {
220
+		return wpinv_generate_user_name($username);
221 221
 	}
222 222
 
223 223
     return $username;
Please login to merge, or discard this patch.
includes/class-wpinv-addons.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * All Invoicing extensions screen related functions can be found here.
6 6
  *
7 7
  */
8
-if ( ! defined( 'ABSPATH' ) ) {
8
+if (!defined('ABSPATH')) {
9 9
 	exit;
10 10
 }
11 11
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array of tabs.
22 22
 	 */
23
-	public function get_tabs(){
23
+	public function get_tabs() {
24 24
 		$tabs = array(
25 25
 			'addons' => __("Addons", "invoicing"),
26 26
             'gateways' => __("Payment Gateways", "invoicing"),
@@ -38,28 +38,28 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return array
40 40
 	 */
41
-	public function get_section_data( $section_id ) {
42
-		$section      = self::get_tab( $section_id );
41
+	public function get_section_data($section_id) {
42
+		$section      = self::get_tab($section_id);
43 43
 		$api_url = "https://wpinvoicing.com/edd-api/v2/products/";
44 44
 		$section_data = new stdClass();
45 45
 
46
-		if($section_id=='recommended_plugins'){
46
+		if ($section_id == 'recommended_plugins') {
47 47
 			$section_data->products = self::get_recommend_wp_plugins_edd_formatted();
48 48
 		}
49
-		elseif ( ! empty( $section ) ) {
50
-			if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing
49
+		elseif (!empty($section)) {
50
+			if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing
51 51
 			//if ( 1==1) {
52 52
 
53
-				$query_args = array( 'category' => $section_id, 'number' => 100);
54
-				$query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id);
53
+				$query_args = array('category' => $section_id, 'number' => 100);
54
+				$query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id);
55 55
 
56
-				$raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout'     => 15, ) );
56
+				$raw_section = wp_safe_remote_get(esc_url_raw(add_query_arg($query_args, $api_url)), array('user-agent' => 'Invoicing Addons Page', 'timeout'     => 15,));
57 57
 
58
-				if ( ! is_wp_error( $raw_section ) ) {
59
-					$section_data = json_decode( wp_remote_retrieve_body( $raw_section ) );
58
+				if (!is_wp_error($raw_section)) {
59
+					$section_data = json_decode(wp_remote_retrieve_body($raw_section));
60 60
 
61
-					if ( ! empty( $section_data->products ) ) {
62
-						set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS );
61
+					if (!empty($section_data->products)) {
62
+						set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS);
63 63
 					}
64 64
 				}
65 65
 			}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		$products = isset($section_data->products) ? $section_data->products : '';
69 69
 
70
-		return apply_filters( 'wpi_addons_section_data', $products, $section_id );
70
+		return apply_filters('wpi_addons_section_data', $products, $section_id);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @param string $theme
79 79
 	 * @param string $plugin
80 80
 	 */
81
-	public function output_button( $addon ) {
82
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
81
+	public function output_button($addon) {
82
+		$current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
83 83
 //		$button_text = __('Free','invoicing');
84 84
 //		$licensing = false;
85 85
 //		$installed = false;
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 //		$install_status = 'get';
92 92
 //		$onclick = '';
93 93
 
94
-		$wp_org_themes = array('supreme-directory','directory-starter');
94
+		$wp_org_themes = array('supreme-directory', 'directory-starter');
95 95
 
96 96
 		$button_args = array(
97
-			'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab,
97
+			'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab,
98 98
 			'id' => isset($addon->info->id) ? absint($addon->info->id) : '',
99 99
 			'title' => isset($addon->info->title) ? $addon->info->title : '',
100
-			'button_text' => __('Free','invoicing'),
101
-			'price_text' => __('Free','invoicing'),
100
+			'button_text' => __('Free', 'invoicing'),
101
+			'price_text' => __('Free', 'invoicing'),
102 102
 			'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product
103 103
 			'url' => isset($addon->info->link) ? $addon->info->link : '', // button url
104 104
 			'class' => 'button-primary',
@@ -114,83 +114,83 @@  discard block
 block discarded – undo
114 114
 			'update_url' => '',
115 115
 		);
116 116
 
117
-		if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){
118
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
119
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
117
+		if (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) {
118
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
119
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
120 120
 			$status = self::install_plugin_install_status($addon);
121 121
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
122
-			if(isset($status['status'])){$button_args['install_status'] = $status['status'];}
122
+			if (isset($status['status'])) {$button_args['install_status'] = $status['status']; }
123 123
 			$button_args['update_url'] = "https://wpinvoicing.com";
124
-		}elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
125
-			if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;}
124
+		}elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) {
125
+			if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; }
126 126
 			$button_args['installed'] = self::is_theme_installed($addon);
127
-			if(!in_array($button_args['slug'],$wp_org_themes)){
127
+			if (!in_array($button_args['slug'], $wp_org_themes)) {
128 128
 				$button_args['update_url'] = "https://wpinvoicing.com";
129 129
 			}
130
-		}elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){
131
-			include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
132
-			$status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>""));
130
+		}elseif ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug) {
131
+			include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api..
132
+			$status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>""));
133 133
 			$button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install';
134 134
 			$button_args['file'] = isset($status['file']) ? $status['file'] : '';
135 135
 		}
136 136
 
137 137
 		// set price
138
-		if(isset($addon->pricing) && !empty($addon->pricing)){
139
-			if(is_object($addon->pricing)){
140
-				$prices = (Array)$addon->pricing;
138
+		if (isset($addon->pricing) && !empty($addon->pricing)) {
139
+			if (is_object($addon->pricing)) {
140
+				$prices = (Array) $addon->pricing;
141 141
 				$button_args['price'] = reset($prices);
142
-			}elseif(isset($addon->pricing)){
142
+			}elseif (isset($addon->pricing)) {
143 143
 				$button_args['price'] = $addon->pricing;
144 144
 			}
145 145
 		}
146 146
 
147 147
 		// set price text
148
-		if( $button_args['price'] && $button_args['price'] != '0.00' ){
149
-			$button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']);
148
+		if ($button_args['price'] && $button_args['price'] != '0.00') {
149
+			$button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']);
150 150
 		}
151 151
 
152 152
 
153 153
 		// set if installed
154
-		if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){
154
+		if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) {
155 155
 			$button_args['installed'] = true;
156 156
 		}
157 157
 
158 158
 //		print_r($button_args);
159 159
 		// set if active
160
-		if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){
161
-			if($button_args['type'] != 'themes'){
160
+		if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) {
161
+			if ($button_args['type'] != 'themes') {
162 162
 				$button_args['active'] = is_plugin_active($button_args['file']);
163
-			}else{
163
+			} else {
164 164
 				$button_args['active'] = self::is_theme_active($addon);
165 165
 			}
166 166
 		}
167 167
 
168 168
 		// set button text and class
169
-		if($button_args['active']){
170
-			$button_args['button_text'] = __('Active','invoicing');
169
+		if ($button_args['active']) {
170
+			$button_args['button_text'] = __('Active', 'invoicing');
171 171
 			$button_args['class'] = ' button-secondary disabled ';
172
-		}elseif($button_args['installed']){
173
-			$button_args['button_text'] = __('Activate','invoicing');
172
+		}elseif ($button_args['installed']) {
173
+			$button_args['button_text'] = __('Activate', 'invoicing');
174 174
 
175
-			if($button_args['type'] != 'themes'){
176
-				if ( current_user_can( 'manage_options' ) ) {
177
-					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']);
178
-				}else{
175
+			if ($button_args['type'] != 'themes') {
176
+				if (current_user_can('manage_options')) {
177
+					$button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']);
178
+				} else {
179 179
 					$button_args['url'] = '#';
180 180
 				}
181
-			}else{
182
-				if ( current_user_can( 'switch_themes' ) ) {
181
+			} else {
182
+				if (current_user_can('switch_themes')) {
183 183
 					$button_args['url'] = self::get_theme_activation_url($addon);
184
-				}else{
184
+				} else {
185 185
 					$button_args['url'] = '#';
186 186
 				}
187 187
 			}
188 188
 
189
-		}else{
190
-			if($button_args['type'] == 'recommended_plugins'){
191
-				$button_args['button_text'] = __('Install','invoicing');
192
-			}else{
193
-				$button_args['button_text'] = __('Get it','invoicing');
189
+		} else {
190
+			if ($button_args['type'] == 'recommended_plugins') {
191
+				$button_args['button_text'] = __('Install', 'invoicing');
192
+			} else {
193
+				$button_args['button_text'] = __('Get it', 'invoicing');
194 194
 
195 195
 				/*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){
196 196
 					$button_args['button_text'] = __('Install','invoicing');
@@ -203,45 +203,45 @@  discard block
 block discarded – undo
203 203
 
204 204
 		
205 205
 		// filter the button arguments
206
-		$button_args = apply_filters('edd_api_button_args',$button_args);
206
+		$button_args = apply_filters('edd_api_button_args', $button_args);
207 207
 //		print_r($button_args);
208 208
 		// set price text
209
-		if(isset($button_args['price_text'])){
209
+		if (isset($button_args['price_text'])) {
210 210
 			?>
211 211
 			<a
212 212
 				target="_blank"
213 213
 				class="addons-price-text"
214
-				href="<?php echo esc_url( $button_args['link'] ); ?>">
215
-				<?php echo esc_html( $button_args['price_text'] ); ?>
214
+				href="<?php echo esc_url($button_args['link']); ?>">
215
+				<?php echo esc_html($button_args['price_text']); ?>
216 216
 			</a>
217 217
 			<?php
218 218
 		}
219 219
 
220 220
 
221 221
 		$target = '';
222
-		if ( ! empty( $button_args['url'] ) ) {
222
+		if (!empty($button_args['url'])) {
223 223
 			$target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" ';
224 224
 		}
225 225
 
226 226
 		?>
227 227
 		<a
228
-			data-licence="<?php echo esc_attr($button_args['license']);?>"
229
-			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
230
-			data-title="<?php echo esc_attr($button_args['title']);?>"
231
-			data-type="<?php echo esc_attr($button_args['type']);?>"
232
-			data-text-error-message="<?php _e('Something went wrong!','invoicing');?>"
233
-			data-text-activate="<?php _e('Activate','invoicing');?>"
234
-			data-text-activating="<?php _e('Activating','invoicing');?>"
235
-			data-text-deactivate="<?php _e('Deactivate','invoicing');?>"
236
-			data-text-installed="<?php _e('Installed','invoicing');?>"
237
-			data-text-install="<?php _e('Install','invoicing');?>"
238
-			data-text-installing="<?php _e('Installing','invoicing');?>"
239
-			data-text-error="<?php _e('Error','invoicing');?>"
240
-			<?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?>
241
-			<?php echo $target;?>
242
-			class="addons-button  <?php echo esc_attr( $button_args['class'] ); ?>"
243
-			href="<?php echo esc_url( $button_args['url'] ); ?>">
244
-			<?php echo esc_html( $button_args['button_text'] ); ?>
228
+			data-licence="<?php echo esc_attr($button_args['license']); ?>"
229
+			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>"
230
+			data-title="<?php echo esc_attr($button_args['title']); ?>"
231
+			data-type="<?php echo esc_attr($button_args['type']); ?>"
232
+			data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>"
233
+			data-text-activate="<?php _e('Activate', 'invoicing'); ?>"
234
+			data-text-activating="<?php _e('Activating', 'invoicing'); ?>"
235
+			data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>"
236
+			data-text-installed="<?php _e('Installed', 'invoicing'); ?>"
237
+			data-text-install="<?php _e('Install', 'invoicing'); ?>"
238
+			data-text-installing="<?php _e('Installing', 'invoicing'); ?>"
239
+			data-text-error="<?php _e('Error', 'invoicing'); ?>"
240
+			<?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?>
241
+			<?php echo $target; ?>
242
+			class="addons-button  <?php echo esc_attr($button_args['class']); ?>"
243
+			href="<?php echo esc_url($button_args['url']); ?>">
244
+			<?php echo esc_html($button_args['button_text']); ?>
245 245
 		</a>
246 246
 		<?php
247 247
 
@@ -256,36 +256,36 @@  discard block
 block discarded – undo
256 256
 		$tabs            = self::get_tabs();
257 257
 		$sections        = self::get_sections();
258 258
 		$theme           = wp_get_theme();
259
-		$section_keys    = array_keys( $sections );
260
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
261
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
262
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
259
+		$section_keys    = array_keys($sections);
260
+		$current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys);
261
+		$current_tab     = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
262
+		include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php');
263 263
 	}
264 264
 
265 265
 	/**
266 266
 	 * A list of recommended wp.org plugins.
267 267
 	 * @return array
268 268
 	 */
269
-	public function get_recommend_wp_plugins(){
269
+	public function get_recommend_wp_plugins() {
270 270
 		$plugins = array(
271 271
             'invoicing-quotes' => array(
272 272
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
273 273
                 'slug'   => 'invoicing-quotes',
274 274
 				'name'   => 'Quotes',
275 275
 				'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.jpg',
276
-                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
276
+                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'),
277 277
             ),
278 278
             'geodirectory' => array(
279 279
                 'url'   => 'https://wordpress.org/plugins/geodirectory/',
280 280
                 'slug'   => 'geodirectory',
281 281
                 'name'   => 'GeoDirectory',
282
-                'desc'   => __('Turn any WordPress theme into a global business directory portal.','invoicing'),
282
+                'desc'   => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'),
283 283
             ),
284 284
             'userswp' => array(
285 285
                 'url'   => 'https://wordpress.org/plugins/userswp/',
286 286
                 'slug'   => 'userswp',
287 287
                 'name'   => 'UsersWP',
288
-                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
288
+                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'),
289 289
             ),
290 290
 		);
291 291
 
Please login to merge, or discard this patch.
templates/wpinv-checkout-cart.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -6,144 +6,144 @@
 block discarded – undo
6 6
 global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns;
7 7
 $invoice            = wpinv_get_invoice_cart();
8 8
 $currency           = $invoice->get_currency();
9
-$cart_items         = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details();
9
+$cart_items         = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details();
10 10
 $quantities_enabled = wpinv_item_quantities_enabled();
11 11
 $use_taxes          = wpinv_use_taxes();
12 12
 $tax_label          = $wpinv_euvat->tax_label();
13
-$tax_title          = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
13
+$tax_title          = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
14 14
 ?>
15 15
 <table id="wpinv_checkout_cart" class="table table-bordered table-hover">
16 16
     <thead>
17 17
         <tr class="wpinv_cart_header_row">
18
-            <?php do_action( 'wpinv_checkout_table_header_first' ); ?>
19
-            <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th>
20
-            <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th>
21
-            <?php if ( $quantities_enabled ) { ?>
22
-            <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th>
18
+            <?php do_action('wpinv_checkout_table_header_first'); ?>
19
+            <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th>
20
+            <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th>
21
+            <?php if ($quantities_enabled) { ?>
22
+            <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th>
23 23
             <?php } ?>
24
-            <?php if ( $use_taxes ) { ?>
24
+            <?php if ($use_taxes) { ?>
25 25
             <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th>
26 26
             <?php } ?>
27
-            <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
28
-            <?php do_action( 'wpinv_checkout_table_header_last' ); ?>
27
+            <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
28
+            <?php do_action('wpinv_checkout_table_header_last'); ?>
29 29
         </tr>
30 30
     </thead>
31 31
     <tbody>
32 32
         <?php
33
-            do_action( 'wpinv_cart_items_before' );
33
+            do_action('wpinv_cart_items_before');
34 34
             
35
-            if ( $cart_items ) {
36
-                foreach ( $cart_items as $key => $item ) {
37
-                    $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL;
35
+            if ($cart_items) {
36
+                foreach ($cart_items as $key => $item) {
37
+                    $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL;
38 38
                 ?>
39
-                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>">
40
-                    <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?>
39
+                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>">
40
+                    <?php do_action('wpinv_checkout_table_body_first', $item); ?>
41 41
                     <td class="wpinv_cart_item_name text-left">
42 42
                         <?php
43
-                            if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) {
43
+                            if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) {
44 44
                                 echo '<div class="wpinv_cart_item_image">';
45
-                                    echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) );
45
+                                    echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25)));
46 46
                                 echo '</div>';
47 47
                             }
48
-                            $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item );
48
+                            $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item);
49 49
                             echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>';
50
-                            $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice );
51
-                            if ( !empty( $summary ) ) {
50
+                            $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice);
51
+                            if (!empty($summary)) {
52 52
                                 echo $summary;
53 53
                             }
54 54
                         ?>
55 55
                     </td>
56 56
                     <td class="wpinv_cart_item_price text-right">
57 57
                         <?php 
58
-                        echo wpinv_cart_item_price( $item, $currency );
59
-                        do_action( 'wpinv_checkout_cart_item_price_after', $item, $key );
58
+                        echo wpinv_cart_item_price($item, $currency);
59
+                        do_action('wpinv_checkout_cart_item_price_after', $item, $key);
60 60
                         ?>
61 61
                     </td>
62
-                    <?php if ( $quantities_enabled ) { ?>
62
+                    <?php if ($quantities_enabled) { ?>
63 63
                     <td class="wpinv_cart_item_qty text-right">
64 64
                         <?php
65
-                        echo wpinv_get_cart_item_quantity( $item );
66
-                        do_action( 'wpinv_cart_item_quantitiy', $item, $key );
65
+                        echo wpinv_get_cart_item_quantity($item);
66
+                        do_action('wpinv_cart_item_quantitiy', $item, $key);
67 67
                         ?>
68 68
                     </td>
69 69
                     <?php } ?>
70
-                    <?php if ( $use_taxes ) { ?>
70
+                    <?php if ($use_taxes) { ?>
71 71
                     <td class="wpinv_cart_item_tax text-right">
72 72
                         <?php
73 73
 
74
-                        if ( $invoice->is_taxable() ) {
75
-                            echo wpinv_cart_item_tax( $item, $currency );
74
+                        if ($invoice->is_taxable()) {
75
+                            echo wpinv_cart_item_tax($item, $currency);
76 76
                         } else {
77 77
                             echo 0;
78 78
                         }
79 79
 
80 80
                         //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() );
81
-                        do_action( 'wpinv_cart_item_tax', $item, $key );
81
+                        do_action('wpinv_cart_item_tax', $item, $key);
82 82
                         ?>
83 83
                     </td>
84 84
                     <?php } ?>
85 85
                     <td class="wpinv_cart_item_subtotal text-right">
86 86
                         <?php
87
-                        echo wpinv_cart_item_subtotal( $item, $currency );
88
-                        do_action( 'wpinv_cart_item_subtotal', $item, $key );
87
+                        echo wpinv_cart_item_subtotal($item, $currency);
88
+                        do_action('wpinv_cart_item_subtotal', $item, $key);
89 89
                         ?>
90 90
                     </td>
91
-                    <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?>
91
+                    <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?>
92 92
                 </tr>
93 93
             <?php } ?>
94 94
         <?php } ?>
95
-        <?php do_action( 'wpinv_cart_items_middle' ); ?>
96
-        <?php do_action( 'wpinv_cart_items_after' ); ?>
95
+        <?php do_action('wpinv_cart_items_middle'); ?>
96
+        <?php do_action('wpinv_cart_items_after'); ?>
97 97
     </tbody>
98 98
     <tfoot>
99 99
         <?php $cart_columns = wpinv_checkout_cart_columns(); ?>
100
-        <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?>
100
+        <?php if (has_action('wpinv_cart_footer_buttons')) { ?>
101 101
             <tr class="wpinv_cart_footer_row">
102
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
103
-                <td colspan="<?php echo ( $cart_columns ); ?>">
104
-                    <?php do_action( 'wpinv_cart_footer_buttons' ); ?>
102
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
103
+                <td colspan="<?php echo ($cart_columns); ?>">
104
+                    <?php do_action('wpinv_cart_footer_buttons'); ?>
105 105
                 </td>
106
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
106
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
107 107
             </tr>
108 108
         <?php } ?>
109 109
 
110
-        <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?>
111
-            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
112
-                <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?>
113
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right">
114
-                    <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong>
110
+        <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?>
111
+            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
112
+                <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?>
113
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right">
114
+                    <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong>
115 115
                 </td>
116 116
                 <td class="wpinv_cart_subtotal text-right">
117
-                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items, $currency ); ?></span>
117
+                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items, $currency); ?></span>
118 118
                 </td>
119
-                <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?>
119
+                <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?>
120 120
             </tr>
121 121
         <?php } ?>
122 122
         
123
-        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?>
123
+        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?>
124 124
 
125
-        <?php if ( $use_taxes ) { ?>
126
-            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
127
-                <?php do_action( 'wpinv_checkout_table_tax_first' ); ?>
128
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right">
125
+        <?php if ($use_taxes) { ?>
126
+            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
127
+                <?php do_action('wpinv_checkout_table_tax_first'); ?>
128
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right">
129 129
                     <strong><?php echo $tax_label; ?>:</strong>
130 130
                 </td>
131 131
                 <td class="wpinv_cart_tax text-right">
132
-                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items, false, $currency, $invoice ) ); ?></span>
132
+                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items, false, $currency, $invoice)); ?></span>
133 133
                 </td>
134
-                <?php do_action( 'wpinv_checkout_table_tax_last' ); ?>
134
+                <?php do_action('wpinv_checkout_table_tax_last'); ?>
135 135
             </tr>
136 136
         <?php } ?>
137 137
 
138 138
         <tr class="wpinv_cart_footer_row wpinv_cart_total_row">
139
-            <?php do_action( 'wpinv_checkout_table_footer_first' ); ?>
140
-            <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right">
141
-                <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?>
139
+            <?php do_action('wpinv_checkout_table_footer_first'); ?>
140
+            <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right">
141
+                <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?>
142 142
             </td>
143 143
             <td class="wpinv_cart_total text-right">
144
-                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span>
144
+                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span>
145 145
             </td>
146
-            <?php do_action( 'wpinv_checkout_table_footer_last' ); ?>
146
+            <?php do_action('wpinv_checkout_table_footer_last'); ?>
147 147
         </tr>
148 148
     </tfoot>
149 149
 </table>
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +624 added lines, -624 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 final class WPInv_Invoice {
15
-    public $ID  = 0;
15
+    public $ID = 0;
16 16
     public $title;
17 17
     public $post_type;
18 18
     
@@ -66,17 +66,17 @@  discard block
 block discarded – undo
66 66
     public $full_name = '';
67 67
     public $parent_invoice = 0;
68 68
     
69
-    public function __construct( $invoice_id = false ) {
70
-        if( empty( $invoice_id ) ) {
69
+    public function __construct($invoice_id = false) {
70
+        if (empty($invoice_id)) {
71 71
             return false;
72 72
         }
73 73
 
74
-        $this->setup_invoice( $invoice_id );
74
+        $this->setup_invoice($invoice_id);
75 75
     }
76 76
 
77
-    public function get( $key ) {
78
-        if ( method_exists( $this, 'get_' . $key ) ) {
79
-            $value = call_user_func( array( $this, 'get_' . $key ) );
77
+    public function get($key) {
78
+        if (method_exists($this, 'get_' . $key)) {
79
+            $value = call_user_func(array($this, 'get_' . $key));
80 80
         } else {
81 81
             $value = $this->$key;
82 82
         }
@@ -84,51 +84,51 @@  discard block
 block discarded – undo
84 84
         return $value;
85 85
     }
86 86
 
87
-    public function set( $key, $value ) {
88
-        $ignore = array( 'items', 'cart_details', 'fees', '_ID' );
87
+    public function set($key, $value) {
88
+        $ignore = array('items', 'cart_details', 'fees', '_ID');
89 89
 
90
-        if ( $key === 'status' ) {
90
+        if ($key === 'status') {
91 91
             $this->old_status = $this->status;
92 92
         }
93 93
 
94
-        if ( ! in_array( $key, $ignore ) ) {
95
-            $this->pending[ $key ] = $value;
94
+        if (!in_array($key, $ignore)) {
95
+            $this->pending[$key] = $value;
96 96
         }
97 97
 
98
-        if( '_ID' !== $key ) {
98
+        if ('_ID' !== $key) {
99 99
             $this->$key = $value;
100 100
         }
101 101
     }
102 102
 
103
-    public function _isset( $name ) {
104
-        if ( property_exists( $this, $name) ) {
105
-            return false === empty( $this->$name );
103
+    public function _isset($name) {
104
+        if (property_exists($this, $name)) {
105
+            return false === empty($this->$name);
106 106
         } else {
107 107
             return null;
108 108
         }
109 109
     }
110 110
 
111
-    private function setup_invoice( $invoice_id ) {
111
+    private function setup_invoice($invoice_id) {
112 112
         $this->pending = array();
113 113
 
114
-        if ( empty( $invoice_id ) ) {
114
+        if (empty($invoice_id)) {
115 115
             return false;
116 116
         }
117 117
 
118
-        $invoice = get_post( $invoice_id );
118
+        $invoice = get_post($invoice_id);
119 119
 
120
-        if( !$invoice || is_wp_error( $invoice ) ) {
120
+        if (!$invoice || is_wp_error($invoice)) {
121 121
             return false;
122 122
         }
123 123
 
124
-        if( !('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type) ) {
124
+        if (!('wpi_invoice' == $invoice->post_type OR 'wpi_quote' == $invoice->post_type)) {
125 125
             return false;
126 126
         }
127 127
 
128
-        do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id );
128
+        do_action('wpinv_pre_setup_invoice', $this, $invoice_id);
129 129
         
130 130
         // Primary Identifier
131
-        $this->ID              = absint( $invoice_id );
131
+        $this->ID              = absint($invoice_id);
132 132
         $this->post_type       = $invoice->post_type;
133 133
         
134 134
         // We have a payment, get the generic payment_meta item to reduce calls to it
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
         $this->post_status     = $this->status;
141 141
         $this->mode            = $this->setup_mode();
142 142
         $this->parent_invoice  = $invoice->post_parent;
143
-        $this->post_name       = $this->setup_post_name( $invoice );
143
+        $this->post_name       = $this->setup_post_name($invoice);
144 144
         $this->status_nicename = $this->setup_status_nicename($invoice->post_status);
145 145
 
146 146
         // Items
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
         
164 164
         // User based
165 165
         $this->ip              = $this->setup_ip();
166
-        $this->user_id         = !empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id();
167
-        $this->email           = get_the_author_meta( 'email', $this->user_id );
166
+        $this->user_id         = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id();
167
+        $this->email           = get_the_author_meta('email', $this->user_id);
168 168
         
169 169
         $this->user_info       = $this->setup_user_info();
170 170
                 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $this->company         = $this->user_info['company'];
174 174
         $this->vat_number      = $this->user_info['vat_number'];
175 175
         $this->vat_rate        = $this->user_info['vat_rate'];
176
-        $this->adddress_confirmed  = $this->user_info['adddress_confirmed'];
176
+        $this->adddress_confirmed = $this->user_info['adddress_confirmed'];
177 177
         $this->address         = $this->user_info['address'];
178 178
         $this->city            = $this->user_info['city'];
179 179
         $this->country         = $this->user_info['country'];
@@ -188,39 +188,39 @@  discard block
 block discarded – undo
188 188
         // Other Identifiers
189 189
         $this->key             = $this->setup_invoice_key();
190 190
         $this->number          = $this->setup_invoice_number();
191
-        $this->title           = !empty( $invoice->post_title ) ? $invoice->post_title : $this->number;
191
+        $this->title           = !empty($invoice->post_title) ? $invoice->post_title : $this->number;
192 192
         
193
-        $this->full_name       = trim( $this->first_name . ' '. $this->last_name );
193
+        $this->full_name       = trim($this->first_name . ' ' . $this->last_name);
194 194
         
195 195
         // Allow extensions to add items to this object via hook
196
-        do_action( 'wpinv_setup_invoice', $this, $invoice_id );
196
+        do_action('wpinv_setup_invoice', $this, $invoice_id);
197 197
 
198 198
         return true;
199 199
     }
200 200
 
201
-    private function setup_status_nicename( $status ) {
202
-        $all_invoice_statuses  = wpinv_get_invoice_statuses( true, true, $this );
201
+    private function setup_status_nicename($status) {
202
+        $all_invoice_statuses = wpinv_get_invoice_statuses(true, true, $this);
203 203
 
204
-        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
205
-            $all_invoice_statuses  = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
204
+        if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
205
+            $all_invoice_statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
206 206
         }
207
-        $status   = isset( $all_invoice_statuses[$status] ) ? $all_invoice_statuses[$status] : __( $status, 'invoicing' );
207
+        $status = isset($all_invoice_statuses[$status]) ? $all_invoice_statuses[$status] : __($status, 'invoicing');
208 208
 
209
-        return apply_filters( 'setup_status_nicename', $status );
209
+        return apply_filters('setup_status_nicename', $status);
210 210
     }
211 211
 
212
-    private function setup_post_name( $post = NULL ) {
212
+    private function setup_post_name($post = NULL) {
213 213
         global $wpdb;
214 214
         
215 215
         $post_name = '';
216 216
         
217
-        if ( !empty( $post ) ) {
218
-            if( !empty( $post->post_name ) ) {
217
+        if (!empty($post)) {
218
+            if (!empty($post->post_name)) {
219 219
                 $post_name = $post->post_name;
220
-            } else if ( !empty( $post->ID ) ) {
221
-                $post_name = wpinv_generate_post_name( $post->ID );
220
+            } else if (!empty($post->ID)) {
221
+                $post_name = wpinv_generate_post_name($post->ID);
222 222
 
223
-                $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
223
+                $wpdb->update($wpdb->posts, array('post_name' => $post_name), array('ID' => $post->ID));
224 224
             }
225 225
         }
226 226
 
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
     }
229 229
     
230 230
     private function setup_due_date() {
231
-        $due_date = $this->get_meta( '_wpinv_due_date' );
231
+        $due_date = $this->get_meta('_wpinv_due_date');
232 232
         
233
-        if ( empty( $due_date ) ) {
234
-            $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days' ) ) );
235
-            $due_date = date_i18n( 'Y-m-d', $overdue_time );
236
-        } else if ( $due_date == 'none' ) {
233
+        if (empty($due_date)) {
234
+            $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days')));
235
+            $due_date = date_i18n('Y-m-d', $overdue_time);
236
+        } else if ($due_date == 'none') {
237 237
             $due_date = '';
238 238
         }
239 239
         
@@ -241,67 +241,67 @@  discard block
 block discarded – undo
241 241
     }
242 242
     
243 243
     private function setup_completed_date() {
244
-        $invoice = get_post( $this->ID );
244
+        $invoice = get_post($this->ID);
245 245
 
246
-        if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) {
246
+        if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) {
247 247
             return false; // This invoice was never paid
248 248
         }
249 249
 
250
-        $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date;
250
+        $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date;
251 251
 
252 252
         return $date;
253 253
     }
254 254
     
255 255
     private function setup_cart_details() {
256
-        $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array();
256
+        $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array();
257 257
         return $cart_details;
258 258
     }
259 259
     
260 260
     public function array_convert() {
261
-        return get_object_vars( $this );
261
+        return get_object_vars($this);
262 262
     }
263 263
     
264 264
     private function setup_items() {
265
-        $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array();
265
+        $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array();
266 266
         return $items;
267 267
     }
268 268
     
269 269
     private function setup_fees() {
270
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
270
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
271 271
         return $payment_fees;
272 272
     }
273 273
         
274 274
     private function setup_currency() {
275
-        $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this );
275
+        $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this);
276 276
         return $currency;
277 277
     }
278 278
     
279 279
     private function setup_discount() {
280 280
         //$discount = $this->get_meta( '_wpinv_discount', true );
281
-        $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total );
282
-        if ( $discount < 0 ) {
281
+        $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total);
282
+        if ($discount < 0) {
283 283
             $discount = 0;
284 284
         }
285
-        $discount = wpinv_round_amount( $discount );
285
+        $discount = wpinv_round_amount($discount);
286 286
         
287 287
         return $discount;
288 288
     }
289 289
     
290 290
     private function setup_discount_code() {
291
-        $discount_code = !empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true );
291
+        $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true);
292 292
         return $discount_code;
293 293
     }
294 294
     
295 295
     private function setup_tax() {
296 296
 
297
-        $tax = $this->get_meta( '_wpinv_tax', true );
297
+        $tax = $this->get_meta('_wpinv_tax', true);
298 298
 
299 299
         // We don't have tax as it's own meta and no meta was passed
300
-        if ( '' === $tax ) {            
301
-            $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0;
300
+        if ('' === $tax) {            
301
+            $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0;
302 302
         }
303 303
         
304
-        if ( $tax < 0 || ! $this->is_taxable() ) {
304
+        if ($tax < 0 || !$this->is_taxable()) {
305 305
             $tax = 0;
306 306
         }
307 307
 
@@ -312,16 +312,16 @@  discard block
 block discarded – undo
312 312
      * If taxes are enabled, allow users to enable/disable taxes per invoice.
313 313
      */
314 314
     private function setup_is_taxable() {
315
-        return (int) $this->get_meta( '_wpinv_disable_taxes', true );
315
+        return (int) $this->get_meta('_wpinv_disable_taxes', true);
316 316
     }
317 317
 
318 318
     private function setup_subtotal() {
319 319
         $subtotal     = 0;
320 320
         $cart_details = $this->cart_details;
321 321
 
322
-        if ( is_array( $cart_details ) ) {
323
-            foreach ( $cart_details as $item ) {
324
-                if ( isset( $item['subtotal'] ) ) {
322
+        if (is_array($cart_details)) {
323
+            foreach ($cart_details as $item) {
324
+                if (isset($item['subtotal'])) {
325 325
                     $subtotal += $item['subtotal'];
326 326
                 }
327 327
             }
@@ -335,23 +335,23 @@  discard block
 block discarded – undo
335 335
     }
336 336
 
337 337
     private function setup_discounts() {
338
-        $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array();
338
+        $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array();
339 339
         return $discounts;
340 340
     }
341 341
     
342 342
     private function setup_total() {
343
-        $amount = $this->get_meta( '_wpinv_total', true );
343
+        $amount = $this->get_meta('_wpinv_total', true);
344 344
 
345
-        if ( empty( $amount ) && '0.00' != $amount ) {
346
-            $meta   = $this->get_meta( '_wpinv_payment_meta', true );
347
-            $meta   = maybe_unserialize( $meta );
345
+        if (empty($amount) && '0.00' != $amount) {
346
+            $meta   = $this->get_meta('_wpinv_payment_meta', true);
347
+            $meta   = maybe_unserialize($meta);
348 348
 
349
-            if ( isset( $meta['amount'] ) ) {
349
+            if (isset($meta['amount'])) {
350 350
                 $amount = $meta['amount'];
351 351
             }
352 352
         }
353 353
 
354
-        if($amount < 0){
354
+        if ($amount < 0) {
355 355
             $amount = 0;
356 356
         }
357 357
 
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
     }
360 360
     
361 361
     private function setup_mode() {
362
-        return $this->get_meta( '_wpinv_mode' );
362
+        return $this->get_meta('_wpinv_mode');
363 363
     }
364 364
 
365 365
     private function setup_gateway() {
366
-        $gateway = $this->get_meta( '_wpinv_gateway' );
366
+        $gateway = $this->get_meta('_wpinv_gateway');
367 367
         
368
-        if ( empty( $gateway ) && 'publish' === $this->status ) {
368
+        if (empty($gateway) && 'publish' === $this->status) {
369 369
             $gateway = 'manual';
370 370
         }
371 371
         
@@ -373,23 +373,23 @@  discard block
 block discarded – undo
373 373
     }
374 374
 
375 375
     private function setup_gateway_title() {
376
-        $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway );
376
+        $gateway_title = wpinv_get_gateway_checkout_label($this->gateway);
377 377
         return $gateway_title;
378 378
     }
379 379
 
380 380
     private function setup_transaction_id() {
381
-        $transaction_id = $this->get_meta( '_wpinv_transaction_id' );
381
+        $transaction_id = $this->get_meta('_wpinv_transaction_id');
382 382
 
383
-        if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
383
+        if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
384 384
             $gateway        = $this->gateway;
385
-            $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID );
385
+            $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID);
386 386
         }
387 387
 
388 388
         return $transaction_id;
389 389
     }
390 390
 
391 391
     private function setup_ip() {
392
-        $ip = $this->get_meta( '_wpinv_user_ip' );
392
+        $ip = $this->get_meta('_wpinv_user_ip');
393 393
         return $ip;
394 394
     }
395 395
 
@@ -399,62 +399,62 @@  discard block
 block discarded – undo
399 399
     ///}
400 400
         
401 401
     private function setup_first_name() {
402
-        $first_name = $this->get_meta( '_wpinv_first_name' );
402
+        $first_name = $this->get_meta('_wpinv_first_name');
403 403
         return $first_name;
404 404
     }
405 405
     
406 406
     private function setup_last_name() {
407
-        $last_name = $this->get_meta( '_wpinv_last_name' );
407
+        $last_name = $this->get_meta('_wpinv_last_name');
408 408
         return $last_name;
409 409
     }
410 410
     
411 411
     private function setup_company() {
412
-        $company = $this->get_meta( '_wpinv_company' );
412
+        $company = $this->get_meta('_wpinv_company');
413 413
         return $company;
414 414
     }
415 415
     
416 416
     private function setup_vat_number() {
417
-        $vat_number = $this->get_meta( '_wpinv_vat_number' );
417
+        $vat_number = $this->get_meta('_wpinv_vat_number');
418 418
         return $vat_number;
419 419
     }
420 420
     
421 421
     private function setup_vat_rate() {
422
-        $vat_rate = $this->get_meta( '_wpinv_vat_rate' );
422
+        $vat_rate = $this->get_meta('_wpinv_vat_rate');
423 423
         return $vat_rate;
424 424
     }
425 425
     
426 426
     private function setup_adddress_confirmed() {
427
-        $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' );
427
+        $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed');
428 428
         return $adddress_confirmed;
429 429
     }
430 430
     
431 431
     private function setup_phone() {
432
-        $phone = $this->get_meta( '_wpinv_phone' );
432
+        $phone = $this->get_meta('_wpinv_phone');
433 433
         return $phone;
434 434
     }
435 435
     
436 436
     private function setup_address() {
437
-        $address = $this->get_meta( '_wpinv_address', true );
437
+        $address = $this->get_meta('_wpinv_address', true);
438 438
         return $address;
439 439
     }
440 440
     
441 441
     private function setup_city() {
442
-        $city = $this->get_meta( '_wpinv_city', true );
442
+        $city = $this->get_meta('_wpinv_city', true);
443 443
         return $city;
444 444
     }
445 445
     
446 446
     private function setup_country() {
447
-        $country = $this->get_meta( '_wpinv_country', true );
447
+        $country = $this->get_meta('_wpinv_country', true);
448 448
         return $country;
449 449
     }
450 450
     
451 451
     private function setup_state() {
452
-        $state = $this->get_meta( '_wpinv_state', true );
452
+        $state = $this->get_meta('_wpinv_state', true);
453 453
         return $state;
454 454
     }
455 455
     
456 456
     private function setup_zip() {
457
-        $zip = $this->get_meta( '_wpinv_zip', true );
457
+        $zip = $this->get_meta('_wpinv_zip', true);
458 458
         return $zip;
459 459
     }
460 460
 
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
             'user_id'        => $this->user_id,
464 464
             'first_name'     => $this->first_name,
465 465
             'last_name'      => $this->last_name,
466
-            'email'          => get_the_author_meta( 'email', $this->user_id ),
466
+            'email'          => get_the_author_meta('email', $this->user_id),
467 467
             'phone'          => $this->phone,
468 468
             'address'        => $this->address,
469 469
             'city'           => $this->city,
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
         );
479 479
         
480 480
         $user_info = array();
481
-        if ( isset( $this->payment_meta['user_info'] ) ) {
482
-            $user_info = maybe_unserialize( $this->payment_meta['user_info'] );
481
+        if (isset($this->payment_meta['user_info'])) {
482
+            $user_info = maybe_unserialize($this->payment_meta['user_info']);
483 483
             
484
-            if ( !empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) {
484
+            if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) {
485 485
                 $this->user_id = $post->post_author;
486
-                $this->email = get_the_author_meta( 'email', $this->user_id );
486
+                $this->email = get_the_author_meta('email', $this->user_id);
487 487
                 
488 488
                 $user_info['user_id'] = $this->user_id;
489 489
                 $user_info['email'] = $this->email;
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
             }
493 493
         }
494 494
         
495
-        $user_info    = wp_parse_args( $user_info, $defaults );
495
+        $user_info = wp_parse_args($user_info, $defaults);
496 496
         
497 497
         // Get the user, but only if it's been created
498
-        $user = get_userdata( $this->user_id );
498
+        $user = get_userdata($this->user_id);
499 499
         
500
-        if ( !empty( $user ) && $user->ID > 0 ) {
501
-            if ( empty( $user_info ) ) {
500
+        if (!empty($user) && $user->ID > 0) {
501
+            if (empty($user_info)) {
502 502
                 $user_info = array(
503 503
                     'user_id'    => $user->ID,
504 504
                     'first_name' => $user->first_name,
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
                     'discount'   => '',
508 508
                 );
509 509
             } else {
510
-                foreach ( $user_info as $key => $value ) {
511
-                    if ( ! empty( $value ) ) {
510
+                foreach ($user_info as $key => $value) {
511
+                    if (!empty($value)) {
512 512
                         continue;
513 513
                     }
514 514
 
515
-                    switch( $key ) {
515
+                    switch ($key) {
516 516
                         case 'user_id':
517
-                            $user_info[ $key ] = $user->ID;
517
+                            $user_info[$key] = $user->ID;
518 518
                             break;
519 519
                         case 'first_name':
520
-                            $user_info[ $key ] = $user->first_name;
520
+                            $user_info[$key] = $user->first_name;
521 521
                             break;
522 522
                         case 'last_name':
523
-                            $user_info[ $key ] = $user->last_name;
523
+                            $user_info[$key] = $user->last_name;
524 524
                             break;
525 525
                         case 'email':
526
-                            $user_info[ $key ] = $user->user_email;
526
+                            $user_info[$key] = $user->user_email;
527 527
                             break;
528 528
                     }
529 529
                 }
@@ -534,25 +534,25 @@  discard block
 block discarded – undo
534 534
     }
535 535
 
536 536
     private function setup_invoice_key() {
537
-        $key = $this->get_meta( '_wpinv_key', true );
537
+        $key = $this->get_meta('_wpinv_key', true);
538 538
         
539 539
         return $key;
540 540
     }
541 541
 
542 542
     private function setup_invoice_number() {
543
-        $number = $this->get_meta( '_wpinv_number', true );
543
+        $number = $this->get_meta('_wpinv_number', true);
544 544
 
545
-        if ( !$number ) {
545
+        if (!$number) {
546 546
             $number = $this->ID;
547 547
 
548
-            if ( $this->status == 'auto-draft' ) {
549
-                if ( wpinv_sequential_number_active( $this->post_type ) ) {
550
-                    $next_number = wpinv_get_next_invoice_number( $this->post_type );
548
+            if ($this->status == 'auto-draft') {
549
+                if (wpinv_sequential_number_active($this->post_type)) {
550
+                    $next_number = wpinv_get_next_invoice_number($this->post_type);
551 551
                     $number      = $next_number;
552 552
                 }
553 553
             }
554 554
             
555
-            $number = wpinv_format_invoice_number( $number, $this->post_type );
555
+            $number = wpinv_format_invoice_number($number, $this->post_type);
556 556
         }
557 557
 
558 558
         return $number;
@@ -561,10 +561,10 @@  discard block
 block discarded – undo
561 561
     private function insert_invoice() {
562 562
         global $wpdb;
563 563
 
564
-        if ( empty( $this->post_type ) ) {
565
-            if ( !empty( $this->ID ) && $post_type = get_post_type( $this->ID ) ) {
564
+        if (empty($this->post_type)) {
565
+            if (!empty($this->ID) && $post_type = get_post_type($this->ID)) {
566 566
                 $this->post_type = $post_type;
567
-            } else if ( !empty( $this->parent_invoice ) && $post_type = get_post_type( $this->parent_invoice ) ) {
567
+            } else if (!empty($this->parent_invoice) && $post_type = get_post_type($this->parent_invoice)) {
568 568
                 $this->post_type = $post_type;
569 569
             } else {
570 570
                 $this->post_type = 'wpi_invoice';
@@ -572,16 +572,16 @@  discard block
 block discarded – undo
572 572
         }
573 573
 
574 574
         $invoice_number = $this->ID;
575
-        if ( $number = $this->get_meta( '_wpinv_number', true ) ) {
575
+        if ($number = $this->get_meta('_wpinv_number', true)) {
576 576
             $invoice_number = $number;
577 577
         }
578 578
 
579
-        if ( empty( $this->key ) ) {
579
+        if (empty($this->key)) {
580 580
             $this->key = self::generate_key();
581 581
             $this->pending['key'] = $this->key;
582 582
         }
583 583
 
584
-        if ( empty( $this->ip ) ) {
584
+        if (empty($this->ip)) {
585 585
             $this->ip = wpinv_get_ip();
586 586
             $this->pending['ip'] = $this->ip;
587 587
         }
@@ -618,61 +618,61 @@  discard block
 block discarded – undo
618 618
                         'post_status'   => $this->status,
619 619
                         'post_author'   => $this->user_id,
620 620
                         'post_type'     => $this->post_type,
621
-                        'post_date'     => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time( 'mysql' ),
622
-                        'post_date_gmt' => ! empty( $this->date ) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date( $this->date ) : current_time( 'mysql', 1 ),
621
+                        'post_date'     => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? $this->date : current_time('mysql'),
622
+                        'post_date_gmt' => !empty($this->date) && $this->date != '0000-00-00 00:00:00' ? get_gmt_from_date($this->date) : current_time('mysql', 1),
623 623
                         'post_parent'   => $this->parent_invoice,
624 624
                     );
625
-        $args = apply_filters( 'wpinv_insert_invoice_args', $post_data, $this );
625
+        $args = apply_filters('wpinv_insert_invoice_args', $post_data, $this);
626 626
 
627 627
         // Create a blank invoice
628
-        if ( !empty( $this->ID ) ) {
629
-            $args['ID']         = $this->ID;
628
+        if (!empty($this->ID)) {
629
+            $args['ID'] = $this->ID;
630 630
 
631
-            $invoice_id = wp_update_post( $args, true );
631
+            $invoice_id = wp_update_post($args, true);
632 632
         } else {
633
-            $invoice_id = wp_insert_post( $args, true );
633
+            $invoice_id = wp_insert_post($args, true);
634 634
         }
635 635
 
636
-        if ( is_wp_error( $invoice_id ) ) {
636
+        if (is_wp_error($invoice_id)) {
637 637
             return false;
638 638
         }
639 639
 
640
-        if ( !empty( $invoice_id ) ) {
640
+        if (!empty($invoice_id)) {
641 641
             $this->ID  = $invoice_id;
642 642
             $this->_ID = $invoice_id;
643 643
 
644
-            $this->payment_meta = apply_filters( 'wpinv_payment_meta', $this->payment_meta, $payment_data );
645
-            if ( ! empty( $this->payment_meta['fees'] ) ) {
646
-                $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
647
-                foreach( $this->fees as $fee ) {
648
-                    $this->increase_fees( $fee['amount'] );
644
+            $this->payment_meta = apply_filters('wpinv_payment_meta', $this->payment_meta, $payment_data);
645
+            if (!empty($this->payment_meta['fees'])) {
646
+                $this->fees = array_merge($this->fees, $this->payment_meta['fees']);
647
+                foreach ($this->fees as $fee) {
648
+                    $this->increase_fees($fee['amount']);
649 649
                 }
650 650
             }
651 651
 
652
-            $this->update_meta( '_wpinv_payment_meta', $this->payment_meta );    
652
+            $this->update_meta('_wpinv_payment_meta', $this->payment_meta);    
653 653
             $this->new = true;
654 654
         }
655 655
 
656 656
         return $this->ID;
657 657
     }
658 658
 
659
-    public function save( $setup = false ) {
659
+    public function save($setup = false) {
660 660
         global $wpi_session;
661 661
         
662 662
         $saved = false;
663
-        if ( empty( $this->items ) ) {
663
+        if (empty($this->items)) {
664 664
             return $saved; // Don't save empty invoice.
665 665
         }
666 666
         
667
-        if ( empty( $this->key ) ) {
667
+        if (empty($this->key)) {
668 668
             $this->key = self::generate_key();
669 669
             $this->pending['key'] = $this->key;
670 670
         }
671 671
         
672
-        if ( empty( $this->ID ) ) {
672
+        if (empty($this->ID)) {
673 673
             $invoice_id = $this->insert_invoice();
674 674
 
675
-            if ( false === $invoice_id ) {
675
+            if (false === $invoice_id) {
676 676
                 $saved = false;
677 677
             } else {
678 678
                 $this->ID = $invoice_id;
@@ -680,27 +680,27 @@  discard block
 block discarded – undo
680 680
         }
681 681
 
682 682
         // If we have something pending, let's save it
683
-        if ( !empty( $this->pending ) ) {
683
+        if (!empty($this->pending)) {
684 684
             $total_increase = 0;
685 685
             $total_decrease = 0;
686 686
 
687
-            foreach ( $this->pending as $key => $value ) {
688
-                switch( $key ) {
687
+            foreach ($this->pending as $key => $value) {
688
+                switch ($key) {
689 689
                     case 'items':
690 690
                         // Update totals for pending items
691
-                        foreach ( $this->pending[ $key ] as $item ) {
692
-                            switch( $item['action'] ) {
691
+                        foreach ($this->pending[$key] as $item) {
692
+                            switch ($item['action']) {
693 693
                                 case 'add':
694 694
                                     $price = $item['price'];
695 695
                                     $taxes = $item['tax'];
696 696
 
697
-                                    if ( 'publish' === $this->status ) {
697
+                                    if ('publish' === $this->status) {
698 698
                                         $total_increase += $price;
699 699
                                     }
700 700
                                     break;
701 701
 
702 702
                                 case 'remove':
703
-                                    if ( 'publish' === $this->status ) {
703
+                                    if ('publish' === $this->status) {
704 704
                                         $total_decrease += $item['price'];
705 705
                                     }
706 706
                                     break;
@@ -708,16 +708,16 @@  discard block
 block discarded – undo
708 708
                         }
709 709
                         break;
710 710
                     case 'fees':
711
-                        if ( 'publish' !== $this->status ) {
711
+                        if ('publish' !== $this->status) {
712 712
                             break;
713 713
                         }
714 714
 
715
-                        if ( empty( $this->pending[ $key ] ) ) {
715
+                        if (empty($this->pending[$key])) {
716 716
                             break;
717 717
                         }
718 718
 
719
-                        foreach ( $this->pending[ $key ] as $fee ) {
720
-                            switch( $fee['action'] ) {
719
+                        foreach ($this->pending[$key] as $fee) {
720
+                            switch ($fee['action']) {
721 721
                                 case 'add':
722 722
                                     $total_increase += $fee['amount'];
723 723
                                     break;
@@ -729,86 +729,86 @@  discard block
 block discarded – undo
729 729
                         }
730 730
                         break;
731 731
                     case 'status':
732
-                        $this->update_status( $this->status );
732
+                        $this->update_status($this->status);
733 733
                         break;
734 734
                     case 'gateway':
735
-                        $this->update_meta( '_wpinv_gateway', $this->gateway );
735
+                        $this->update_meta('_wpinv_gateway', $this->gateway);
736 736
                         break;
737 737
                     case 'mode':
738
-                        $this->update_meta( '_wpinv_mode', $this->mode );
738
+                        $this->update_meta('_wpinv_mode', $this->mode);
739 739
                         break;
740 740
                     case 'transaction_id':
741
-                        $this->update_meta( '_wpinv_transaction_id', $this->transaction_id );
741
+                        $this->update_meta('_wpinv_transaction_id', $this->transaction_id);
742 742
                         break;
743 743
                     case 'ip':
744
-                        $this->update_meta( '_wpinv_user_ip', $this->ip );
744
+                        $this->update_meta('_wpinv_user_ip', $this->ip);
745 745
                         break;
746 746
                     ///case 'user_id':
747 747
                         ///$this->update_meta( '_wpinv_user_id', $this->user_id );
748 748
                         ///$this->user_info['user_id'] = $this->user_id;
749 749
                         ///break;
750 750
                     case 'first_name':
751
-                        $this->update_meta( '_wpinv_first_name', $this->first_name );
751
+                        $this->update_meta('_wpinv_first_name', $this->first_name);
752 752
                         $this->user_info['first_name'] = $this->first_name;
753 753
                         break;
754 754
                     case 'last_name':
755
-                        $this->update_meta( '_wpinv_last_name', $this->last_name );
755
+                        $this->update_meta('_wpinv_last_name', $this->last_name);
756 756
                         $this->user_info['last_name'] = $this->last_name;
757 757
                         break;
758 758
                     case 'phone':
759
-                        $this->update_meta( '_wpinv_phone', $this->phone );
759
+                        $this->update_meta('_wpinv_phone', $this->phone);
760 760
                         $this->user_info['phone'] = $this->phone;
761 761
                         break;
762 762
                     case 'address':
763
-                        $this->update_meta( '_wpinv_address', $this->address );
763
+                        $this->update_meta('_wpinv_address', $this->address);
764 764
                         $this->user_info['address'] = $this->address;
765 765
                         break;
766 766
                     case 'city':
767
-                        $this->update_meta( '_wpinv_city', $this->city );
767
+                        $this->update_meta('_wpinv_city', $this->city);
768 768
                         $this->user_info['city'] = $this->city;
769 769
                         break;
770 770
                     case 'country':
771
-                        $this->update_meta( '_wpinv_country', $this->country );
771
+                        $this->update_meta('_wpinv_country', $this->country);
772 772
                         $this->user_info['country'] = $this->country;
773 773
                         break;
774 774
                     case 'state':
775
-                        $this->update_meta( '_wpinv_state', $this->state );
775
+                        $this->update_meta('_wpinv_state', $this->state);
776 776
                         $this->user_info['state'] = $this->state;
777 777
                         break;
778 778
                     case 'zip':
779
-                        $this->update_meta( '_wpinv_zip', $this->zip );
779
+                        $this->update_meta('_wpinv_zip', $this->zip);
780 780
                         $this->user_info['zip'] = $this->zip;
781 781
                         break;
782 782
                     case 'company':
783
-                        $this->update_meta( '_wpinv_company', $this->company );
783
+                        $this->update_meta('_wpinv_company', $this->company);
784 784
                         $this->user_info['company'] = $this->company;
785 785
                         break;
786 786
                     case 'vat_number':
787
-                        $this->update_meta( '_wpinv_vat_number', $this->vat_number );
787
+                        $this->update_meta('_wpinv_vat_number', $this->vat_number);
788 788
                         $this->user_info['vat_number'] = $this->vat_number;
789 789
                         
790
-                        $vat_info = $wpi_session->get( 'user_vat_data' );
791
-                        if ( $this->vat_number && !empty( $vat_info ) && isset( $vat_info['number'] ) && isset( $vat_info['valid'] ) && $vat_info['number'] == $this->vat_number ) {
792
-                            $adddress_confirmed = isset( $vat_info['adddress_confirmed'] ) ? $vat_info['adddress_confirmed'] : false;
793
-                            $this->update_meta( '_wpinv_adddress_confirmed', (bool)$adddress_confirmed );
794
-                            $this->user_info['adddress_confirmed'] = (bool)$adddress_confirmed;
790
+                        $vat_info = $wpi_session->get('user_vat_data');
791
+                        if ($this->vat_number && !empty($vat_info) && isset($vat_info['number']) && isset($vat_info['valid']) && $vat_info['number'] == $this->vat_number) {
792
+                            $adddress_confirmed = isset($vat_info['adddress_confirmed']) ? $vat_info['adddress_confirmed'] : false;
793
+                            $this->update_meta('_wpinv_adddress_confirmed', (bool) $adddress_confirmed);
794
+                            $this->user_info['adddress_confirmed'] = (bool) $adddress_confirmed;
795 795
                         }
796 796
     
797 797
                         break;
798 798
                     case 'vat_rate':
799
-                        $this->update_meta( '_wpinv_vat_rate', $this->vat_rate );
799
+                        $this->update_meta('_wpinv_vat_rate', $this->vat_rate);
800 800
                         $this->user_info['vat_rate'] = $this->vat_rate;
801 801
                         break;
802 802
                     case 'adddress_confirmed':
803
-                        $this->update_meta( '_wpinv_adddress_confirmed', $this->adddress_confirmed );
803
+                        $this->update_meta('_wpinv_adddress_confirmed', $this->adddress_confirmed);
804 804
                         $this->user_info['adddress_confirmed'] = $this->adddress_confirmed;
805 805
                         break;
806 806
                     
807 807
                     case 'key':
808
-                        $this->update_meta( '_wpinv_key', $this->key );
808
+                        $this->update_meta('_wpinv_key', $this->key);
809 809
                         break;
810 810
                     case 'disable_taxes':
811
-                        $this->update_meta( '_wpinv_disable_taxes', $this->disable_taxes );
811
+                        $this->update_meta('_wpinv_disable_taxes', $this->disable_taxes);
812 812
                         break;
813 813
                     case 'date':
814 814
                         $args = array(
@@ -817,49 +817,49 @@  discard block
 block discarded – undo
817 817
                             'edit_date' => true,
818 818
                         );
819 819
 
820
-                        wp_update_post( $args );
820
+                        wp_update_post($args);
821 821
                         break;
822 822
                     case 'due_date':
823
-                        if ( empty( $this->due_date ) ) {
823
+                        if (empty($this->due_date)) {
824 824
                             $this->due_date = 'none';
825 825
                         }
826 826
                         
827
-                        $this->update_meta( '_wpinv_due_date', $this->due_date );
827
+                        $this->update_meta('_wpinv_due_date', $this->due_date);
828 828
                         break;
829 829
                     case 'completed_date':
830
-                        $this->update_meta( '_wpinv_completed_date', $this->completed_date );
830
+                        $this->update_meta('_wpinv_completed_date', $this->completed_date);
831 831
                         break;
832 832
                     case 'discounts':
833
-                        if ( ! is_array( $this->discounts ) ) {
834
-                            $this->discounts = explode( ',', $this->discounts );
833
+                        if (!is_array($this->discounts)) {
834
+                            $this->discounts = explode(',', $this->discounts);
835 835
                         }
836 836
 
837
-                        $this->user_info['discount'] = implode( ',', $this->discounts );
837
+                        $this->user_info['discount'] = implode(',', $this->discounts);
838 838
                         break;
839 839
                     case 'discount':
840
-                        $this->update_meta( '_wpinv_discount', wpinv_round_amount( $this->discount ) );
840
+                        $this->update_meta('_wpinv_discount', wpinv_round_amount($this->discount));
841 841
                         break;
842 842
                     case 'discount_code':
843
-                        $this->update_meta( '_wpinv_discount_code', $this->discount_code );
843
+                        $this->update_meta('_wpinv_discount_code', $this->discount_code);
844 844
                         break;
845 845
                     case 'parent_invoice':
846 846
                         $args = array(
847 847
                             'ID'          => $this->ID,
848 848
                             'post_parent' => $this->parent_invoice,
849 849
                         );
850
-                        wp_update_post( $args );
850
+                        wp_update_post($args);
851 851
                         break;
852 852
                     default:
853
-                        do_action( 'wpinv_save', $this, $key );
853
+                        do_action('wpinv_save', $this, $key);
854 854
                         break;
855 855
                 }
856 856
             }
857 857
 
858
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
859
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
860
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
858
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
859
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
860
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
861 861
             
862
-            $this->items    = array_values( $this->items );
862
+            $this->items = array_values($this->items);
863 863
             
864 864
             $new_meta = array(
865 865
                 'items'         => $this->items,
@@ -870,12 +870,12 @@  discard block
 block discarded – undo
870 870
             );
871 871
             
872 872
             $meta        = $this->get_meta();
873
-            $merged_meta = array_merge( $meta, $new_meta );
873
+            $merged_meta = array_merge($meta, $new_meta);
874 874
 
875 875
             // Only save the payment meta if it's changed
876
-            if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta) ) ) {
877
-                $updated     = $this->update_meta( '_wpinv_payment_meta', $merged_meta );
878
-                if ( false !== $updated ) {
876
+            if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
877
+                $updated = $this->update_meta('_wpinv_payment_meta', $merged_meta);
878
+                if (false !== $updated) {
879 879
                     $saved = true;
880 880
                 }
881 881
             }
@@ -883,15 +883,15 @@  discard block
 block discarded – undo
883 883
             $this->pending = array();
884 884
             $saved         = true;
885 885
         } else {
886
-            $this->update_meta( '_wpinv_subtotal', wpinv_round_amount( $this->subtotal ) );
887
-            $this->update_meta( '_wpinv_total', wpinv_round_amount( $this->total ) );
888
-            $this->update_meta( '_wpinv_tax', wpinv_round_amount( $this->tax ) );
886
+            $this->update_meta('_wpinv_subtotal', wpinv_round_amount($this->subtotal));
887
+            $this->update_meta('_wpinv_total', wpinv_round_amount($this->total));
888
+            $this->update_meta('_wpinv_tax', wpinv_round_amount($this->tax));
889 889
         }
890 890
         
891
-        do_action( 'wpinv_invoice_save', $this, $saved );
891
+        do_action('wpinv_invoice_save', $this, $saved);
892 892
 
893
-        if ( true === $saved || $setup ) {
894
-            $this->setup_invoice( $this->ID );
893
+        if (true === $saved || $setup) {
894
+            $this->setup_invoice($this->ID);
895 895
         }
896 896
         
897 897
         $this->refresh_item_ids();
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
         return $saved;
900 900
     }
901 901
     
902
-    public function add_fee( $args, $global = true ) {
902
+    public function add_fee($args, $global = true) {
903 903
         $default_args = array(
904 904
             'label'       => '',
905 905
             'amount'      => 0,
@@ -909,75 +909,75 @@  discard block
 block discarded – undo
909 909
             'item_id'     => 0,
910 910
         );
911 911
 
912
-        $fee = wp_parse_args( $args, $default_args );
912
+        $fee = wp_parse_args($args, $default_args);
913 913
         
914
-        if ( empty( $fee['label'] ) ) {
914
+        if (empty($fee['label'])) {
915 915
             return false;
916 916
         }
917 917
         
918
-        $fee['id']  = sanitize_title( $fee['label'] );
918
+        $fee['id'] = sanitize_title($fee['label']);
919 919
         
920
-        $this->fees[]               = $fee;
920
+        $this->fees[] = $fee;
921 921
         
922 922
         $added_fee               = $fee;
923 923
         $added_fee['action']     = 'add';
924 924
         $this->pending['fees'][] = $added_fee;
925
-        reset( $this->fees );
925
+        reset($this->fees);
926 926
 
927
-        $this->increase_fees( $fee['amount'] );
927
+        $this->increase_fees($fee['amount']);
928 928
         return true;
929 929
     }
930 930
 
931
-    public function remove_fee( $key ) {
931
+    public function remove_fee($key) {
932 932
         $removed = false;
933 933
 
934
-        if ( is_numeric( $key ) ) {
935
-            $removed = $this->remove_fee_by( 'index', $key );
934
+        if (is_numeric($key)) {
935
+            $removed = $this->remove_fee_by('index', $key);
936 936
         }
937 937
 
938 938
         return $removed;
939 939
     }
940 940
 
941
-    public function remove_fee_by( $key, $value, $global = false ) {
942
-        $allowed_fee_keys = apply_filters( 'wpinv_fee_keys', array(
941
+    public function remove_fee_by($key, $value, $global = false) {
942
+        $allowed_fee_keys = apply_filters('wpinv_fee_keys', array(
943 943
             'index', 'label', 'amount', 'type',
944
-        ) );
944
+        ));
945 945
 
946
-        if ( ! in_array( $key, $allowed_fee_keys ) ) {
946
+        if (!in_array($key, $allowed_fee_keys)) {
947 947
             return false;
948 948
         }
949 949
 
950 950
         $removed = false;
951
-        if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
952
-            $removed_fee             = $this->fees[ $value ];
951
+        if ('index' === $key && array_key_exists($value, $this->fees)) {
952
+            $removed_fee             = $this->fees[$value];
953 953
             $removed_fee['action']   = 'remove';
954 954
             $this->pending['fees'][] = $removed_fee;
955 955
 
956
-            $this->decrease_fees( $removed_fee['amount'] );
956
+            $this->decrease_fees($removed_fee['amount']);
957 957
 
958
-            unset( $this->fees[ $value ] );
958
+            unset($this->fees[$value]);
959 959
             $removed = true;
960
-        } else if ( 'index' !== $key ) {
961
-            foreach ( $this->fees as $index => $fee ) {
962
-                if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
960
+        } else if ('index' !== $key) {
961
+            foreach ($this->fees as $index => $fee) {
962
+                if (isset($fee[$key]) && $fee[$key] == $value) {
963 963
                     $removed_fee             = $fee;
964 964
                     $removed_fee['action']   = 'remove';
965 965
                     $this->pending['fees'][] = $removed_fee;
966 966
 
967
-                    $this->decrease_fees( $removed_fee['amount'] );
967
+                    $this->decrease_fees($removed_fee['amount']);
968 968
 
969
-                    unset( $this->fees[ $index ] );
969
+                    unset($this->fees[$index]);
970 970
                     $removed = true;
971 971
 
972
-                    if ( false === $global ) {
972
+                    if (false === $global) {
973 973
                         break;
974 974
                     }
975 975
                 }
976 976
             }
977 977
         }
978 978
 
979
-        if ( true === $removed ) {
980
-            $this->fees = array_values( $this->fees );
979
+        if (true === $removed) {
980
+            $this->fees = array_values($this->fees);
981 981
         }
982 982
 
983 983
         return $removed;
@@ -985,35 +985,35 @@  discard block
 block discarded – undo
985 985
 
986 986
     
987 987
 
988
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
988
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
989 989
         // Bail if no note specified
990
-        if( !$note ) {
990
+        if (!$note) {
991 991
             return false;
992 992
         }
993 993
 
994
-        if ( empty( $this->ID ) )
994
+        if (empty($this->ID))
995 995
             return false;
996 996
         
997
-        if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && !$system ) {
998
-            $user                 = get_user_by( 'id', get_current_user_id() );
997
+        if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) {
998
+            $user                 = get_user_by('id', get_current_user_id());
999 999
             $comment_author       = $user->display_name;
1000 1000
             $comment_author_email = $user->user_email;
1001 1001
         } else {
1002 1002
             $comment_author       = 'System';
1003 1003
             $comment_author_email = 'system@';
1004
-            $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com';
1005
-            $comment_author_email = sanitize_email( $comment_author_email );
1004
+            $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com';
1005
+            $comment_author_email = sanitize_email($comment_author_email);
1006 1006
         }
1007 1007
 
1008
-        do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type );
1008
+        do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type);
1009 1009
 
1010
-        $note_id = wp_insert_comment( wp_filter_comment( array(
1010
+        $note_id = wp_insert_comment(wp_filter_comment(array(
1011 1011
             'comment_post_ID'      => $this->ID,
1012 1012
             'comment_content'      => $note,
1013 1013
             'comment_agent'        => 'WPInvoicing',
1014 1014
             'user_id'              => is_admin() ? get_current_user_id() : 0,
1015
-            'comment_date'         => current_time( 'mysql' ),
1016
-            'comment_date_gmt'     => current_time( 'mysql', 1 ),
1015
+            'comment_date'         => current_time('mysql'),
1016
+            'comment_date_gmt'     => current_time('mysql', 1),
1017 1017
             'comment_approved'     => 1,
1018 1018
             'comment_parent'       => 0,
1019 1019
             'comment_author'       => $comment_author,
@@ -1021,53 +1021,53 @@  discard block
 block discarded – undo
1021 1021
             'comment_author_url'   => '',
1022 1022
             'comment_author_email' => $comment_author_email,
1023 1023
             'comment_type'         => 'wpinv_note'
1024
-        ) ) );
1024
+        )));
1025 1025
 
1026
-        do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note );
1026
+        do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note);
1027 1027
         
1028
-        if ( $customer_type ) {
1029
-            add_comment_meta( $note_id, '_wpi_customer_note', 1 );
1028
+        if ($customer_type) {
1029
+            add_comment_meta($note_id, '_wpi_customer_note', 1);
1030 1030
 
1031
-            do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $this->ID, 'user_note' => $note ) );
1031
+            do_action('wpinv_new_customer_note', array('invoice_id' => $this->ID, 'user_note' => $note));
1032 1032
         }
1033 1033
 
1034 1034
         return $note_id;
1035 1035
     }
1036 1036
 
1037
-    private function increase_subtotal( $amount = 0.00 ) {
1037
+    private function increase_subtotal($amount = 0.00) {
1038 1038
         $amount          = (float) $amount;
1039 1039
         $this->subtotal += $amount;
1040
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1040
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1041 1041
 
1042 1042
         $this->recalculate_total();
1043 1043
     }
1044 1044
 
1045
-    private function decrease_subtotal( $amount = 0.00 ) {
1045
+    private function decrease_subtotal($amount = 0.00) {
1046 1046
         $amount          = (float) $amount;
1047 1047
         $this->subtotal -= $amount;
1048
-        $this->subtotal  = wpinv_round_amount( $this->subtotal );
1048
+        $this->subtotal  = wpinv_round_amount($this->subtotal);
1049 1049
 
1050
-        if ( $this->subtotal < 0 ) {
1050
+        if ($this->subtotal < 0) {
1051 1051
             $this->subtotal = 0;
1052 1052
         }
1053 1053
 
1054 1054
         $this->recalculate_total();
1055 1055
     }
1056 1056
 
1057
-    private function increase_fees( $amount = 0.00 ) {
1058
-        $amount            = (float)$amount;
1057
+    private function increase_fees($amount = 0.00) {
1058
+        $amount            = (float) $amount;
1059 1059
         $this->fees_total += $amount;
1060
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1060
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1061 1061
 
1062 1062
         $this->recalculate_total();
1063 1063
     }
1064 1064
 
1065
-    private function decrease_fees( $amount = 0.00 ) {
1065
+    private function decrease_fees($amount = 0.00) {
1066 1066
         $amount            = (float) $amount;
1067 1067
         $this->fees_total -= $amount;
1068
-        $this->fees_total  = wpinv_round_amount( $this->fees_total );
1068
+        $this->fees_total  = wpinv_round_amount($this->fees_total);
1069 1069
 
1070
-        if ( $this->fees_total < 0 ) {
1070
+        if ($this->fees_total < 0) {
1071 1071
             $this->fees_total = 0;
1072 1072
         }
1073 1073
 
@@ -1078,54 +1078,54 @@  discard block
 block discarded – undo
1078 1078
         global $wpi_nosave;
1079 1079
         
1080 1080
         $this->total = $this->subtotal + $this->tax + $this->fees_total;
1081
-        $this->total = wpinv_round_amount( $this->total );
1081
+        $this->total = wpinv_round_amount($this->total);
1082 1082
         
1083
-        do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave );
1083
+        do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave);
1084 1084
     }
1085 1085
     
1086
-    public function increase_tax( $amount = 0.00 ) {
1086
+    public function increase_tax($amount = 0.00) {
1087 1087
         $amount       = (float) $amount;
1088 1088
         $this->tax   += $amount;
1089 1089
 
1090 1090
         $this->recalculate_total();
1091 1091
     }
1092 1092
 
1093
-    public function decrease_tax( $amount = 0.00 ) {
1093
+    public function decrease_tax($amount = 0.00) {
1094 1094
         $amount     = (float) $amount;
1095 1095
         $this->tax -= $amount;
1096 1096
 
1097
-        if ( $this->tax < 0 ) {
1097
+        if ($this->tax < 0) {
1098 1098
             $this->tax = 0;
1099 1099
         }
1100 1100
 
1101 1101
         $this->recalculate_total();
1102 1102
     }
1103 1103
 
1104
-    public function update_status( $new_status = false, $note = '', $manual = false ) {
1105
-        $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID );
1104
+    public function update_status($new_status = false, $note = '', $manual = false) {
1105
+        $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID);
1106 1106
 
1107
-        if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) {
1107
+        if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) {
1108 1108
             return false; // Don't permit status changes that aren't changes
1109 1109
         }
1110 1110
 
1111
-        $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status );
1111
+        $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status);
1112 1112
         $updated = false;
1113 1113
 
1114
-        if ( $do_change ) {
1115
-            do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status );
1114
+        if ($do_change) {
1115
+            do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status);
1116 1116
 
1117 1117
             $update_post_data                   = array();
1118 1118
             $update_post_data['ID']             = $this->ID;
1119 1119
             $update_post_data['post_status']    = $new_status;
1120
-            $update_post_data['edit_date']      = current_time( 'mysql', 0 );
1121
-            $update_post_data['edit_date_gmt']  = current_time( 'mysql', 1 );
1120
+            $update_post_data['edit_date']      = current_time('mysql', 0);
1121
+            $update_post_data['edit_date_gmt']  = current_time('mysql', 1);
1122 1122
             
1123
-            $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID );
1123
+            $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID);
1124 1124
 
1125
-            $updated = wp_update_post( $update_post_data );     
1125
+            $updated = wp_update_post($update_post_data);     
1126 1126
            
1127 1127
             // Process any specific status functions
1128
-            switch( $new_status ) {
1128
+            switch ($new_status) {
1129 1129
                 case 'wpi-refunded':
1130 1130
                     $this->process_refund();
1131 1131
                     break;
@@ -1138,9 +1138,9 @@  discard block
 block discarded – undo
1138 1138
             }
1139 1139
             
1140 1140
             // Status was changed.
1141
-            do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status );
1142
-            do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status );
1143
-            do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status );
1141
+            do_action('wpinv_status_' . $new_status, $this->ID, $old_status);
1142
+            do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status);
1143
+            do_action('wpinv_update_status', $this->ID, $new_status, $old_status);
1144 1144
         }
1145 1145
 
1146 1146
         return $updated;
@@ -1154,20 +1154,20 @@  discard block
 block discarded – undo
1154 1154
         $this->save();
1155 1155
     }
1156 1156
 
1157
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1158
-        if ( empty( $meta_key ) ) {
1157
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1158
+        if (empty($meta_key)) {
1159 1159
             return false;
1160 1160
         }
1161 1161
 
1162
-        if ( $meta_key == 'key' || $meta_key == 'date' ) {
1162
+        if ($meta_key == 'key' || $meta_key == 'date') {
1163 1163
             $current_meta = $this->get_meta();
1164
-            $current_meta[ $meta_key ] = $meta_value;
1164
+            $current_meta[$meta_key] = $meta_value;
1165 1165
 
1166 1166
             $meta_key     = '_wpinv_payment_meta';
1167 1167
             $meta_value   = $current_meta;
1168 1168
         }
1169 1169
 
1170
-        $meta_value = apply_filters( 'wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID );
1170
+        $meta_value = apply_filters('wpinv_update_payment_meta_' . $meta_key, $meta_value, $this->ID);
1171 1171
         
1172 1172
         // Do not update created date on invoice marked as paid.
1173 1173
         /*if ( $meta_key == '_wpinv_completed_date' && !empty( $meta_value ) ) {
@@ -1182,45 +1182,45 @@  discard block
 block discarded – undo
1182 1182
             wp_update_post( $args );
1183 1183
         }*/
1184 1184
         
1185
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1185
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1186 1186
     }
1187 1187
 
1188 1188
     private function process_refund() {
1189 1189
         $process_refund = true;
1190 1190
 
1191 1191
         // If the payment was not in publish, don't decrement stats as they were never incremented
1192
-        if ( 'publish' != $this->old_status || 'wpi-refunded' != $this->status ) {
1192
+        if ('publish' != $this->old_status || 'wpi-refunded' != $this->status) {
1193 1193
             $process_refund = false;
1194 1194
         }
1195 1195
 
1196 1196
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1197
-        $process_refund = apply_filters( 'wpinv_should_process_refund', $process_refund, $this );
1197
+        $process_refund = apply_filters('wpinv_should_process_refund', $process_refund, $this);
1198 1198
 
1199
-        if ( false === $process_refund ) {
1199
+        if (false === $process_refund) {
1200 1200
             return;
1201 1201
         }
1202 1202
 
1203
-        do_action( 'wpinv_pre_refund_invoice', $this );
1203
+        do_action('wpinv_pre_refund_invoice', $this);
1204 1204
         
1205
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_refund', true, $this );
1206
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_refund', true, $this );
1207
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_refund', true, $this );
1205
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_refund', true, $this);
1206
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_refund', true, $this);
1207
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_refund', true, $this);
1208 1208
         
1209
-        do_action( 'wpinv_post_refund_invoice', $this );
1209
+        do_action('wpinv_post_refund_invoice', $this);
1210 1210
     }
1211 1211
 
1212 1212
     private function process_failure() {
1213 1213
         $discounts = $this->discounts;
1214
-        if ( empty( $discounts ) ) {
1214
+        if (empty($discounts)) {
1215 1215
             return;
1216 1216
         }
1217 1217
 
1218
-        if ( ! is_array( $discounts ) ) {
1219
-            $discounts = array_map( 'trim', explode( ',', $discounts ) );
1218
+        if (!is_array($discounts)) {
1219
+            $discounts = array_map('trim', explode(',', $discounts));
1220 1220
         }
1221 1221
 
1222
-        foreach ( $discounts as $discount ) {
1223
-            wpinv_decrease_discount_usage( $discount );
1222
+        foreach ($discounts as $discount) {
1223
+            wpinv_decrease_discount_usage($discount);
1224 1224
         }
1225 1225
     }
1226 1226
     
@@ -1228,92 +1228,92 @@  discard block
 block discarded – undo
1228 1228
         $process_pending = true;
1229 1229
 
1230 1230
         // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1231
-        if ( ( 'publish' != $this->old_status && 'revoked' != $this->old_status ) || 'wpi-pending' != $this->status ) {
1231
+        if (('publish' != $this->old_status && 'revoked' != $this->old_status) || 'wpi-pending' != $this->status) {
1232 1232
             $process_pending = false;
1233 1233
         }
1234 1234
 
1235 1235
         // Allow extensions to filter for their own payment types, Example: Recurring Payments
1236
-        $process_pending = apply_filters( 'wpinv_should_process_pending', $process_pending, $this );
1236
+        $process_pending = apply_filters('wpinv_should_process_pending', $process_pending, $this);
1237 1237
 
1238
-        if ( false === $process_pending ) {
1238
+        if (false === $process_pending) {
1239 1239
             return;
1240 1240
         }
1241 1241
 
1242
-        $decrease_store_earnings = apply_filters( 'wpinv_decrease_store_earnings_on_pending', true, $this );
1243
-        $decrease_customer_value = apply_filters( 'wpinv_decrease_customer_value_on_pending', true, $this );
1244
-        $decrease_purchase_count = apply_filters( 'wpinv_decrease_customer_purchase_count_on_pending', true, $this );
1242
+        $decrease_store_earnings = apply_filters('wpinv_decrease_store_earnings_on_pending', true, $this);
1243
+        $decrease_customer_value = apply_filters('wpinv_decrease_customer_value_on_pending', true, $this);
1244
+        $decrease_purchase_count = apply_filters('wpinv_decrease_customer_purchase_count_on_pending', true, $this);
1245 1245
 
1246 1246
         $this->completed_date = '';
1247
-        $this->update_meta( '_wpinv_completed_date', '' );
1247
+        $this->update_meta('_wpinv_completed_date', '');
1248 1248
     }
1249 1249
     
1250 1250
     // get data
1251
-    public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) {
1252
-        $meta = get_post_meta( $this->ID, $meta_key, $single );
1251
+    public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) {
1252
+        $meta = get_post_meta($this->ID, $meta_key, $single);
1253 1253
 
1254
-        if ( $meta_key === '_wpinv_payment_meta' ) {
1254
+        if ($meta_key === '_wpinv_payment_meta') {
1255 1255
 
1256
-            if(!is_array($meta)){$meta = array();} // we need this to be an array so make sure it is.
1256
+            if (!is_array($meta)) {$meta = array(); } // we need this to be an array so make sure it is.
1257 1257
 
1258
-            if ( empty( $meta['key'] ) ) {
1258
+            if (empty($meta['key'])) {
1259 1259
                 $meta['key'] = $this->setup_invoice_key();
1260 1260
             }
1261 1261
 
1262
-            if ( empty( $meta['date'] ) ) {
1263
-                $meta['date'] = get_post_field( 'post_date', $this->ID );
1262
+            if (empty($meta['date'])) {
1263
+                $meta['date'] = get_post_field('post_date', $this->ID);
1264 1264
             }
1265 1265
         }
1266 1266
 
1267
-        $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID );
1267
+        $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID);
1268 1268
 
1269
-        return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key );
1269
+        return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key);
1270 1270
     }
1271 1271
     
1272 1272
     public function get_description() {
1273
-        $post = get_post( $this->ID );
1273
+        $post = get_post($this->ID);
1274 1274
         
1275
-        $description = !empty( $post ) ? $post->post_content : '';
1276
-        return apply_filters( 'wpinv_get_description', $description, $this->ID, $this );
1275
+        $description = !empty($post) ? $post->post_content : '';
1276
+        return apply_filters('wpinv_get_description', $description, $this->ID, $this);
1277 1277
     }
1278 1278
     
1279
-    public function get_status( $nicename = false ) {
1280
-        if ( !$nicename ) {
1279
+    public function get_status($nicename = false) {
1280
+        if (!$nicename) {
1281 1281
             $status = $this->status;
1282 1282
         } else {
1283 1283
             $status = $this->status_nicename;
1284 1284
         }
1285 1285
         
1286
-        return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this );
1286
+        return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this);
1287 1287
     }
1288 1288
     
1289 1289
     public function get_cart_details() {
1290
-        return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this );
1290
+        return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this);
1291 1291
     }
1292 1292
     
1293
-    public function get_subtotal( $currency = false ) {
1294
-        $subtotal = wpinv_round_amount( $this->subtotal );
1293
+    public function get_subtotal($currency = false) {
1294
+        $subtotal = wpinv_round_amount($this->subtotal);
1295 1295
         
1296
-        if ( $currency ) {
1297
-            $subtotal = wpinv_price( wpinv_format_amount( $subtotal, NULL, !$currency ), $this->get_currency() );
1296
+        if ($currency) {
1297
+            $subtotal = wpinv_price(wpinv_format_amount($subtotal, NULL, !$currency), $this->get_currency());
1298 1298
         }
1299 1299
         
1300
-        return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency );
1300
+        return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency);
1301 1301
     }
1302 1302
     
1303
-    public function get_total( $currency = false ) {        
1304
-        if ( $this->is_free_trial() ) {
1305
-            $total = wpinv_round_amount( 0 );
1303
+    public function get_total($currency = false) {        
1304
+        if ($this->is_free_trial()) {
1305
+            $total = wpinv_round_amount(0);
1306 1306
         } else {
1307
-            $total = wpinv_round_amount( $this->total );
1307
+            $total = wpinv_round_amount($this->total);
1308 1308
         }
1309
-        if ( $currency ) {
1310
-            $total = wpinv_price( wpinv_format_amount( $total, NULL, !$currency ), $this->get_currency() );
1309
+        if ($currency) {
1310
+            $total = wpinv_price(wpinv_format_amount($total, NULL, !$currency), $this->get_currency());
1311 1311
         }
1312 1312
         
1313
-        return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency );
1313
+        return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency);
1314 1314
     }
1315 1315
     
1316
-    public function get_recurring_details( $field = '', $currency = false ) {        
1316
+    public function get_recurring_details($field = '', $currency = false) {        
1317 1317
         $data                 = array();
1318 1318
         $data['cart_details'] = $this->cart_details;
1319 1319
         $data['subtotal']     = $this->get_subtotal();
@@ -1321,119 +1321,119 @@  discard block
 block discarded – undo
1321 1321
         $data['tax']          = $this->get_tax();
1322 1322
         $data['total']        = $this->get_total();
1323 1323
     
1324
-        if ( !empty( $this->cart_details ) && ( $this->is_parent() || $this->is_renewal() ) ) {
1324
+        if (!empty($this->cart_details) && ($this->is_parent() || $this->is_renewal())) {
1325 1325
             $is_free_trial = $this->is_free_trial();
1326
-            $discounts = $this->get_discounts( true );
1326
+            $discounts = $this->get_discounts(true);
1327 1327
             
1328
-            if ( $is_free_trial || !empty( $discounts ) ) {
1328
+            if ($is_free_trial || !empty($discounts)) {
1329 1329
                 $first_use_only = false;
1330 1330
                 
1331
-                if ( !empty( $discounts ) ) {
1332
-                    foreach ( $discounts as $key => $code ) {
1333
-                        if ( wpinv_discount_is_recurring( $code, true ) && !$this->is_renewal() ) {
1331
+                if (!empty($discounts)) {
1332
+                    foreach ($discounts as $key => $code) {
1333
+                        if (wpinv_discount_is_recurring($code, true) && !$this->is_renewal()) {
1334 1334
                             $first_use_only = true;
1335 1335
                             break;
1336 1336
                         }
1337 1337
                     }
1338 1338
                 }
1339 1339
                     
1340
-                if ( !$first_use_only ) {
1341
-                    $data['subtotal'] = wpinv_round_amount( $this->subtotal );
1342
-                    $data['discount'] = wpinv_round_amount( $this->discount );
1343
-                    $data['tax']      = wpinv_round_amount( $this->tax );
1344
-                    $data['total']    = wpinv_round_amount( $this->total );
1340
+                if (!$first_use_only) {
1341
+                    $data['subtotal'] = wpinv_round_amount($this->subtotal);
1342
+                    $data['discount'] = wpinv_round_amount($this->discount);
1343
+                    $data['tax']      = wpinv_round_amount($this->tax);
1344
+                    $data['total']    = wpinv_round_amount($this->total);
1345 1345
                 } else {
1346 1346
                     $cart_subtotal   = 0;
1347 1347
                     $cart_discount   = $this->discount;
1348 1348
                     $cart_tax        = 0;
1349 1349
 
1350
-                    foreach ( $this->cart_details as $key => $item ) {
1351
-                        $item_quantity  = $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1352
-                        $item_subtotal  = !empty( $item['subtotal'] ) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1350
+                    foreach ($this->cart_details as $key => $item) {
1351
+                        $item_quantity  = $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1352
+                        $item_subtotal  = !empty($item['subtotal']) ? $item['subtotal'] : $item['item_price'] * $item_quantity;
1353 1353
                         $item_discount  = 0;
1354
-                        $item_tax       = $item_subtotal > 0 && !empty( $item['vat_rate'] ) ? ( $item_subtotal * 0.01 * (float)$item['vat_rate'] ) : 0;
1354
+                        $item_tax       = $item_subtotal > 0 && !empty($item['vat_rate']) ? ($item_subtotal * 0.01 * (float) $item['vat_rate']) : 0;
1355 1355
                         
1356
-                        if ( wpinv_prices_include_tax() ) {
1357
-                            $item_subtotal -= wpinv_round_amount( $item_tax );
1356
+                        if (wpinv_prices_include_tax()) {
1357
+                            $item_subtotal -= wpinv_round_amount($item_tax);
1358 1358
                         }
1359 1359
                         
1360 1360
                         $item_total     = $item_subtotal - $item_discount + $item_tax;
1361 1361
                         // Do not allow totals to go negative
1362
-                        if ( $item_total < 0 ) {
1362
+                        if ($item_total < 0) {
1363 1363
                             $item_total = 0;
1364 1364
                         }
1365 1365
                         
1366
-                        $cart_subtotal  += (float)($item_subtotal);
1367
-                        $cart_discount  += (float)($item_discount);
1368
-                        $cart_tax       += (float)($item_tax);
1366
+                        $cart_subtotal  += (float) ($item_subtotal);
1367
+                        $cart_discount  += (float) ($item_discount);
1368
+                        $cart_tax       += (float) ($item_tax);
1369 1369
                         
1370
-                        $data['cart_details'][$key]['discount']   = wpinv_round_amount( $item_discount );
1371
-                        $data['cart_details'][$key]['tax']        = wpinv_round_amount( $item_tax );
1372
-                        $data['cart_details'][$key]['price']      = wpinv_round_amount( $item_total );
1370
+                        $data['cart_details'][$key]['discount']   = wpinv_round_amount($item_discount);
1371
+                        $data['cart_details'][$key]['tax']        = wpinv_round_amount($item_tax);
1372
+                        $data['cart_details'][$key]['price']      = wpinv_round_amount($item_total);
1373 1373
                     }
1374 1374
 
1375 1375
 	                $total = $data['subtotal'] - $data['discount'] + $data['tax'];
1376
-	                if ( $total < 0 ) {
1376
+	                if ($total < 0) {
1377 1377
 		                $total = 0;
1378 1378
 	                }
1379 1379
 
1380
-                    $data['subtotal'] = wpinv_round_amount( $cart_subtotal );
1381
-                    $data['discount'] = wpinv_round_amount( $cart_discount );
1382
-                    $data['tax']      = wpinv_round_amount( $cart_tax );
1383
-                    $data['total']    = wpinv_round_amount( $total );
1380
+                    $data['subtotal'] = wpinv_round_amount($cart_subtotal);
1381
+                    $data['discount'] = wpinv_round_amount($cart_discount);
1382
+                    $data['tax']      = wpinv_round_amount($cart_tax);
1383
+                    $data['total']    = wpinv_round_amount($total);
1384 1384
                 }
1385 1385
             }
1386 1386
         }
1387 1387
         
1388
-        $data = apply_filters( 'wpinv_get_invoice_recurring_details', $data, $this, $field, $currency );
1388
+        $data = apply_filters('wpinv_get_invoice_recurring_details', $data, $this, $field, $currency);
1389 1389
 
1390
-        if ( isset( $data[$field] ) ) {
1391
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1390
+        if (isset($data[$field])) {
1391
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1392 1392
         }
1393 1393
         
1394 1394
         return $data;
1395 1395
     }
1396 1396
     
1397
-    public function get_final_tax( $currency = false ) {        
1398
-        $final_total = wpinv_round_amount( $this->tax );
1399
-        if ( $currency ) {
1400
-            $final_total = wpinv_price( wpinv_format_amount( $final_total, NULL, !$currency ), $this->get_currency() );
1397
+    public function get_final_tax($currency = false) {        
1398
+        $final_total = wpinv_round_amount($this->tax);
1399
+        if ($currency) {
1400
+            $final_total = wpinv_price(wpinv_format_amount($final_total, NULL, !$currency), $this->get_currency());
1401 1401
         }
1402 1402
         
1403
-        return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency );
1403
+        return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency);
1404 1404
     }
1405 1405
     
1406
-    public function get_discounts( $array = false ) {
1406
+    public function get_discounts($array = false) {
1407 1407
         $discounts = $this->discounts;
1408
-        if ( $array && $discounts ) {
1409
-            $discounts = explode( ',', $discounts );
1408
+        if ($array && $discounts) {
1409
+            $discounts = explode(',', $discounts);
1410 1410
         }
1411
-        return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array );
1411
+        return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array);
1412 1412
     }
1413 1413
     
1414
-    public function get_discount( $currency = false, $dash = false ) {
1415
-        if ( !empty( $this->discounts ) ) {
1414
+    public function get_discount($currency = false, $dash = false) {
1415
+        if (!empty($this->discounts)) {
1416 1416
             global $ajax_cart_details;
1417 1417
             $ajax_cart_details = $this->get_cart_details();
1418 1418
             
1419
-            if ( !empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) {
1419
+            if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) {
1420 1420
                 $cart_items = $ajax_cart_details;
1421 1421
             } else {
1422 1422
                 $cart_items = $this->items;
1423 1423
             }
1424 1424
 
1425
-            $this->discount = wpinv_get_cart_items_discount_amount( $cart_items , $this->discounts );
1425
+            $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts);
1426 1426
         }
1427
-        $discount   = wpinv_round_amount( $this->discount );
1427
+        $discount   = wpinv_round_amount($this->discount);
1428 1428
         $dash       = $dash && $discount > 0 ? '&ndash;' : '';
1429 1429
         
1430
-        if ( $currency ) {
1431
-            $discount = wpinv_price( wpinv_format_amount( $discount, NULL, !$currency ), $this->get_currency() );
1430
+        if ($currency) {
1431
+            $discount = wpinv_price(wpinv_format_amount($discount, NULL, !$currency), $this->get_currency());
1432 1432
         }
1433 1433
         
1434
-        $discount   = $dash . $discount;
1434
+        $discount = $dash . $discount;
1435 1435
         
1436
-        return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash );
1436
+        return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash);
1437 1437
     }
1438 1438
     
1439 1439
     public function get_discount_code() {
@@ -1445,49 +1445,49 @@  discard block
 block discarded – undo
1445 1445
         return (int) $this->disable_taxes === 0;
1446 1446
     }
1447 1447
 
1448
-    public function get_tax( $currency = false ) {
1449
-        $tax = wpinv_round_amount( $this->tax );
1448
+    public function get_tax($currency = false) {
1449
+        $tax = wpinv_round_amount($this->tax);
1450 1450
 
1451
-        if ( $currency ) {
1452
-            $tax = wpinv_price( wpinv_format_amount( $tax, NULL, !$currency ), $this->get_currency() );
1451
+        if ($currency) {
1452
+            $tax = wpinv_price(wpinv_format_amount($tax, NULL, !$currency), $this->get_currency());
1453 1453
         }
1454 1454
 
1455
-        if ( ! $this->is_taxable() ) {
1456
-            $tax = wpinv_round_amount( 0.00 );
1455
+        if (!$this->is_taxable()) {
1456
+            $tax = wpinv_round_amount(0.00);
1457 1457
         }
1458 1458
 
1459
-        return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency );
1459
+        return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency);
1460 1460
     }
1461 1461
     
1462
-    public function get_fees( $type = 'all' ) {
1463
-        $fees    = array();
1462
+    public function get_fees($type = 'all') {
1463
+        $fees = array();
1464 1464
 
1465
-        if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1466
-            foreach ( $this->fees as $fee ) {
1467
-                if( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1465
+        if (!empty($this->fees) && is_array($this->fees)) {
1466
+            foreach ($this->fees as $fee) {
1467
+                if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) {
1468 1468
                     continue;
1469 1469
                 }
1470 1470
 
1471
-                $fee['label'] = stripslashes( $fee['label'] );
1472
-                $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() );
1473
-                $fees[]    = $fee;
1471
+                $fee['label'] = stripslashes($fee['label']);
1472
+                $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency());
1473
+                $fees[] = $fee;
1474 1474
             }
1475 1475
         }
1476 1476
 
1477
-        return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this );
1477
+        return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this);
1478 1478
     }
1479 1479
     
1480
-    public function get_fees_total( $type = 'all' ) {
1480
+    public function get_fees_total($type = 'all') {
1481 1481
         $fees_total = (float) 0.00;
1482 1482
 
1483
-        $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1484
-        if ( ! empty( $payment_fees ) ) {
1485
-            foreach ( $payment_fees as $fee ) {
1483
+        $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1484
+        if (!empty($payment_fees)) {
1485
+            foreach ($payment_fees as $fee) {
1486 1486
                 $fees_total += (float) $fee['amount'];
1487 1487
             }
1488 1488
         }
1489 1489
 
1490
-        return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this );
1490
+        return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this);
1491 1491
         /*
1492 1492
         $fees = $this->get_fees( $type );
1493 1493
 
@@ -1507,116 +1507,116 @@  discard block
 block discarded – undo
1507 1507
     }
1508 1508
 
1509 1509
     public function get_user_id() {
1510
-        return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this );
1510
+        return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this);
1511 1511
     }
1512 1512
     
1513 1513
     public function get_first_name() {
1514
-        return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this );
1514
+        return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this);
1515 1515
     }
1516 1516
     
1517 1517
     public function get_last_name() {
1518
-        return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this );
1518
+        return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this);
1519 1519
     }
1520 1520
     
1521 1521
     public function get_user_full_name() {
1522
-        return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this );
1522
+        return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this);
1523 1523
     }
1524 1524
     
1525 1525
     public function get_user_info() {
1526
-        return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this );
1526
+        return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this);
1527 1527
     }
1528 1528
     
1529 1529
     public function get_email() {
1530
-        return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this );
1530
+        return apply_filters('wpinv_user_email', $this->email, $this->ID, $this);
1531 1531
     }
1532 1532
     
1533 1533
     public function get_address() {
1534
-        return apply_filters( 'wpinv_address', $this->address, $this->ID, $this );
1534
+        return apply_filters('wpinv_address', $this->address, $this->ID, $this);
1535 1535
     }
1536 1536
     
1537 1537
     public function get_phone() {
1538
-        return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this );
1538
+        return apply_filters('wpinv_phone', $this->phone, $this->ID, $this);
1539 1539
     }
1540 1540
     
1541 1541
     public function get_number() {
1542
-        return apply_filters( 'wpinv_number', $this->number, $this->ID, $this );
1542
+        return apply_filters('wpinv_number', $this->number, $this->ID, $this);
1543 1543
     }
1544 1544
     
1545 1545
     public function get_items() {
1546
-        return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this );
1546
+        return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this);
1547 1547
     }
1548 1548
     
1549 1549
     public function get_key() {
1550
-        return apply_filters( 'wpinv_key', $this->key, $this->ID, $this );
1550
+        return apply_filters('wpinv_key', $this->key, $this->ID, $this);
1551 1551
     }
1552 1552
     
1553 1553
     public function get_transaction_id() {
1554
-        return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this );
1554
+        return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this);
1555 1555
     }
1556 1556
     
1557 1557
     public function get_gateway() {
1558
-        return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this );
1558
+        return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this);
1559 1559
     }
1560 1560
     
1561 1561
     public function get_gateway_title() {
1562
-        $this->gateway_title = !empty( $this->gateway_title ) ? $this->gateway_title : wpinv_get_gateway_checkout_label( $this->gateway );
1562
+        $this->gateway_title = !empty($this->gateway_title) ? $this->gateway_title : wpinv_get_gateway_checkout_label($this->gateway);
1563 1563
         
1564
-        return apply_filters( 'wpinv_gateway_title', $this->gateway_title, $this->ID, $this );
1564
+        return apply_filters('wpinv_gateway_title', $this->gateway_title, $this->ID, $this);
1565 1565
     }
1566 1566
     
1567 1567
     public function get_currency() {
1568
-        return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this );
1568
+        return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this);
1569 1569
     }
1570 1570
     
1571 1571
     public function get_created_date() {
1572
-        return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this );
1572
+        return apply_filters('wpinv_created_date', $this->date, $this->ID, $this);
1573 1573
     }
1574 1574
     
1575
-    public function get_due_date( $display = false ) {
1576
-        $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this );
1575
+    public function get_due_date($display = false) {
1576
+        $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this);
1577 1577
         
1578
-        if ( !$display || empty( $due_date ) ) {
1578
+        if (!$display || empty($due_date)) {
1579 1579
             return $due_date;
1580 1580
         }
1581 1581
         
1582
-        return date_i18n( get_option( 'date_format' ), strtotime( $due_date ) );
1582
+        return date_i18n(get_option('date_format'), strtotime($due_date));
1583 1583
     }
1584 1584
     
1585 1585
     public function get_completed_date() {
1586
-        return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this );
1586
+        return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this);
1587 1587
     }
1588 1588
     
1589
-    public function get_invoice_date( $formatted = true ) {
1589
+    public function get_invoice_date($formatted = true) {
1590 1590
         $date_completed = $this->completed_date;
1591 1591
         $invoice_date   = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
1592 1592
         
1593
-        if ( $invoice_date == '' ) {
1593
+        if ($invoice_date == '') {
1594 1594
             $date_created   = $this->date;
1595 1595
             $invoice_date   = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : '';
1596 1596
         }
1597 1597
         
1598
-        if ( $formatted && $invoice_date ) {
1599
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
1598
+        if ($formatted && $invoice_date) {
1599
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
1600 1600
         }
1601 1601
 
1602
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this );
1602
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this);
1603 1603
     }
1604 1604
     
1605 1605
     public function get_ip() {
1606
-        return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this );
1606
+        return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this);
1607 1607
     }
1608 1608
         
1609
-    public function has_status( $status ) {
1610
-        return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status );
1609
+    public function has_status($status) {
1610
+        return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status);
1611 1611
     }
1612 1612
     
1613
-    public function add_item( $item_id = 0, $args = array() ) {
1613
+    public function add_item($item_id = 0, $args = array()) {
1614 1614
         global $wpi_current_id, $wpi_item_id;
1615 1615
         
1616
-        $item = new WPInv_Item( $item_id );
1616
+        $item = new WPInv_Item($item_id);
1617 1617
 
1618 1618
         // Bail if this post isn't a item
1619
-        if( !$item || $item->post_type !== 'wpi_item' ) {
1619
+        if (!$item || $item->post_type !== 'wpi_item') {
1620 1620
             return false;
1621 1621
         }
1622 1622
         
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
             'fees'          => array()
1636 1636
         );
1637 1637
 
1638
-        $args = wp_parse_args( apply_filters( 'wpinv_add_item_args', $args, $item->ID ), $defaults );
1639
-        $args['quantity']   = $has_quantities && $args['quantity'] > 0 ? absint( $args['quantity'] ) : 1;
1638
+        $args = wp_parse_args(apply_filters('wpinv_add_item_args', $args, $item->ID), $defaults);
1639
+        $args['quantity'] = $has_quantities && $args['quantity'] > 0 ? absint($args['quantity']) : 1;
1640 1640
 
1641 1641
         $wpi_current_id         = $this->ID;
1642 1642
         $wpi_item_id            = $item->ID;
@@ -1648,19 +1648,19 @@  discard block
 block discarded – undo
1648 1648
         $found_cart_key         = false;
1649 1649
         
1650 1650
         if ($has_quantities) {
1651
-            $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1651
+            $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1652 1652
             
1653
-            foreach ( $this->items as $key => $cart_item ) {
1654
-                if ( (int)$item_id !== (int)$cart_item['id'] ) {
1653
+            foreach ($this->items as $key => $cart_item) {
1654
+                if ((int) $item_id !== (int) $cart_item['id']) {
1655 1655
                     continue;
1656 1656
                 }
1657 1657
 
1658
-                $this->items[ $key ]['quantity'] += $args['quantity'];
1658
+                $this->items[$key]['quantity'] += $args['quantity'];
1659 1659
                 break;
1660 1660
             }
1661 1661
             
1662
-            foreach ( $this->cart_details as $cart_key => $cart_item ) {
1663
-                if ( $item_id != $cart_item['id'] ) {
1662
+            foreach ($this->cart_details as $cart_key => $cart_item) {
1663
+                if ($item_id != $cart_item['id']) {
1664 1664
                     continue;
1665 1665
                 }
1666 1666
 
@@ -1672,29 +1672,29 @@  discard block
 block discarded – undo
1672 1672
         if ($has_quantities && $found_cart_key !== false) {
1673 1673
             $cart_item          = $this->cart_details[$found_cart_key];
1674 1674
             $item_price         = $cart_item['item_price'];
1675
-            $quantity           = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1676
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1675
+            $quantity           = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1676
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1677 1677
             
1678 1678
             $new_quantity       = $quantity + $args['quantity'];
1679 1679
             $subtotal           = $item_price * $new_quantity;
1680 1680
             
1681 1681
             $args['quantity']   = $new_quantity;
1682
-            $discount           = !empty( $args['discount'] ) ? $args['discount'] : 0;
1683
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1682
+            $discount           = !empty($args['discount']) ? $args['discount'] : 0;
1683
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1684 1684
             
1685
-            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float)$cart_item['discount'] ? $discount - (float)$cart_item['discount'] : 0;
1686
-            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float)$cart_item['tax'] ? $tax - (float)$cart_item['tax'] : 0;
1685
+            $discount_increased = $discount > 0 && $subtotal > 0 && $discount > (float) $cart_item['discount'] ? $discount - (float) $cart_item['discount'] : 0;
1686
+            $tax_increased      = $tax > 0 && $subtotal > 0 && $tax > (float) $cart_item['tax'] ? $tax - (float) $cart_item['tax'] : 0;
1687 1687
             // The total increase equals the number removed * the item_price
1688
-            $total_increased    = wpinv_round_amount( $item_price );
1688
+            $total_increased    = wpinv_round_amount($item_price);
1689 1689
             
1690
-            if ( wpinv_prices_include_tax() ) {
1691
-                $subtotal -= wpinv_round_amount( $tax );
1690
+            if (wpinv_prices_include_tax()) {
1691
+                $subtotal -= wpinv_round_amount($tax);
1692 1692
             }
1693 1693
 
1694
-            $total              = $subtotal - $discount + $tax;
1694
+            $total = $subtotal - $discount + $tax;
1695 1695
 
1696 1696
             // Do not allow totals to go negative
1697
-            if( $total < 0 ) {
1697
+            if ($total < 0) {
1698 1698
                 $total = 0;
1699 1699
             }
1700 1700
             
@@ -1710,25 +1710,25 @@  discard block
 block discarded – undo
1710 1710
             $this->cart_details[$found_cart_key] = $cart_item;
1711 1711
         } else {
1712 1712
             // Set custom price.
1713
-            if ( $args['custom_price'] !== '' ) {
1713
+            if ($args['custom_price'] !== '') {
1714 1714
                 $item_price = $args['custom_price'];
1715 1715
             } else {
1716 1716
                 // Allow overriding the price
1717
-                if ( false !== $args['item_price'] ) {
1717
+                if (false !== $args['item_price']) {
1718 1718
                     $item_price = $args['item_price'];
1719 1719
                 } else {
1720
-                    $item_price = wpinv_get_item_price( $item->ID );
1720
+                    $item_price = wpinv_get_item_price($item->ID);
1721 1721
                 }
1722 1722
             }
1723 1723
 
1724 1724
             // Sanitizing the price here so we don't have a dozen calls later
1725
-            $item_price = wpinv_sanitize_amount( $item_price );
1726
-            $subtotal   = wpinv_round_amount( $item_price * $args['quantity'] );
1725
+            $item_price = wpinv_sanitize_amount($item_price);
1726
+            $subtotal   = wpinv_round_amount($item_price * $args['quantity']);
1727 1727
         
1728
-            $discount   = !empty( $args['discount'] ) ? $args['discount'] : 0;
1729
-            $tax_class  = !empty( $args['vat_class'] ) ? $args['vat_class'] : '';
1730
-            $tax_rate   = !empty( $args['vat_rate'] ) ? $args['vat_rate'] : 0;
1731
-            $tax        = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1728
+            $discount   = !empty($args['discount']) ? $args['discount'] : 0;
1729
+            $tax_class  = !empty($args['vat_class']) ? $args['vat_class'] : '';
1730
+            $tax_rate   = !empty($args['vat_rate']) ? $args['vat_rate'] : 0;
1731
+            $tax        = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1732 1732
 
1733 1733
             // Setup the items meta item
1734 1734
             $new_item = array(
@@ -1736,29 +1736,29 @@  discard block
 block discarded – undo
1736 1736
                 'quantity' => $args['quantity'],
1737 1737
             );
1738 1738
 
1739
-            $this->items[]  = $new_item;
1739
+            $this->items[] = $new_item;
1740 1740
 
1741
-            if ( wpinv_prices_include_tax() ) {
1742
-                $subtotal -= wpinv_round_amount( $tax );
1741
+            if (wpinv_prices_include_tax()) {
1742
+                $subtotal -= wpinv_round_amount($tax);
1743 1743
             }
1744 1744
 
1745
-            $total      = $subtotal - $discount + $tax;
1745
+            $total = $subtotal - $discount + $tax;
1746 1746
 
1747 1747
             // Do not allow totals to go negative
1748
-            if( $total < 0 ) {
1748
+            if ($total < 0) {
1749 1749
                 $total = 0;
1750 1750
             }
1751 1751
         
1752 1752
             $this->cart_details[] = array(
1753 1753
                 'name'          => !empty($args['name']) ? $args['name'] : $item->get_name(),
1754 1754
                 'id'            => $item->ID,
1755
-                'item_price'    => wpinv_round_amount( $item_price ),
1756
-                'custom_price'  => ( $args['custom_price'] !== '' ? wpinv_round_amount( $args['custom_price'] ) : '' ),
1755
+                'item_price'    => wpinv_round_amount($item_price),
1756
+                'custom_price'  => ($args['custom_price'] !== '' ? wpinv_round_amount($args['custom_price']) : ''),
1757 1757
                 'quantity'      => $args['quantity'],
1758 1758
                 'discount'      => $discount,
1759
-                'subtotal'      => wpinv_round_amount( $subtotal ),
1760
-                'tax'           => wpinv_round_amount( $tax ),
1761
-                'price'         => wpinv_round_amount( $total ),
1759
+                'subtotal'      => wpinv_round_amount($subtotal),
1760
+                'tax'           => wpinv_round_amount($tax),
1761
+                'price'         => wpinv_round_amount($total),
1762 1762
                 'vat_rate'      => $tax_rate,
1763 1763
                 'vat_class'     => $tax_class,
1764 1764
                 'meta'          => $args['meta'],
@@ -1768,18 +1768,18 @@  discard block
 block discarded – undo
1768 1768
             $subtotal = $subtotal - $discount;
1769 1769
         }
1770 1770
         
1771
-        $added_item = end( $this->cart_details );
1772
-        $added_item['action']  = 'add';
1771
+        $added_item = end($this->cart_details);
1772
+        $added_item['action'] = 'add';
1773 1773
         
1774 1774
         $this->pending['items'][] = $added_item;
1775 1775
         
1776
-        $this->increase_subtotal( $subtotal );
1777
-        $this->increase_tax( $tax );
1776
+        $this->increase_subtotal($subtotal);
1777
+        $this->increase_tax($tax);
1778 1778
 
1779 1779
         return true;
1780 1780
     }
1781 1781
     
1782
-    public function remove_item( $item_id, $args = array() ) {
1782
+    public function remove_item($item_id, $args = array()) {
1783 1783
         // Set some defaults
1784 1784
         $defaults = array(
1785 1785
             'quantity'      => 1,
@@ -1787,51 +1787,51 @@  discard block
 block discarded – undo
1787 1787
             'custom_price'  => '',
1788 1788
             'cart_index'    => false,
1789 1789
         );
1790
-        $args = wp_parse_args( $args, $defaults );
1790
+        $args = wp_parse_args($args, $defaults);
1791 1791
 
1792 1792
         // Bail if this post isn't a item
1793
-        if ( get_post_type( $item_id ) !== 'wpi_item' ) {
1793
+        if (get_post_type($item_id) !== 'wpi_item') {
1794 1794
             return false;
1795 1795
         }
1796 1796
         
1797
-        $this->cart_details = !empty( $this->cart_details ) ? array_values( $this->cart_details ) : $this->cart_details;
1797
+        $this->cart_details = !empty($this->cart_details) ? array_values($this->cart_details) : $this->cart_details;
1798 1798
 
1799
-        foreach ( $this->items as $key => $item ) {
1800
-            if ( !empty($item['id']) && (int)$item_id !== (int)$item['id'] ) {
1799
+        foreach ($this->items as $key => $item) {
1800
+            if (!empty($item['id']) && (int) $item_id !== (int) $item['id']) {
1801 1801
                 continue;
1802 1802
             }
1803 1803
 
1804
-            if ( false !== $args['cart_index'] ) {
1805
-                $cart_index = absint( $args['cart_index'] );
1806
-                $cart_item  = ! empty( $this->cart_details[ $cart_index ] ) ? $this->cart_details[ $cart_index ] : false;
1804
+            if (false !== $args['cart_index']) {
1805
+                $cart_index = absint($args['cart_index']);
1806
+                $cart_item  = !empty($this->cart_details[$cart_index]) ? $this->cart_details[$cart_index] : false;
1807 1807
 
1808
-                if ( ! empty( $cart_item ) ) {
1808
+                if (!empty($cart_item)) {
1809 1809
                     // If the cart index item isn't the same item ID, don't remove it
1810
-                    if ( !empty($cart_item['id']) && $cart_item['id'] != $item['id'] ) {
1810
+                    if (!empty($cart_item['id']) && $cart_item['id'] != $item['id']) {
1811 1811
                         continue;
1812 1812
                     }
1813 1813
                 }
1814 1814
             }
1815 1815
 
1816
-            $item_quantity = $this->items[ $key ]['quantity'];
1817
-            if ( $item_quantity > $args['quantity'] ) {
1818
-                $this->items[ $key ]['quantity'] -= $args['quantity'];
1816
+            $item_quantity = $this->items[$key]['quantity'];
1817
+            if ($item_quantity > $args['quantity']) {
1818
+                $this->items[$key]['quantity'] -= $args['quantity'];
1819 1819
                 break;
1820 1820
             } else {
1821
-                unset( $this->items[ $key ] );
1821
+                unset($this->items[$key]);
1822 1822
                 break;
1823 1823
             }
1824 1824
         }
1825 1825
 
1826 1826
         $found_cart_key = false;
1827
-        if ( false === $args['cart_index'] ) {
1828
-            foreach ( $this->cart_details as $cart_key => $item ) {
1829
-                if ( $item_id != $item['id'] ) {
1827
+        if (false === $args['cart_index']) {
1828
+            foreach ($this->cart_details as $cart_key => $item) {
1829
+                if ($item_id != $item['id']) {
1830 1830
                     continue;
1831 1831
                 }
1832 1832
 
1833
-                if ( false !== $args['item_price'] ) {
1834
-                    if ( isset( $item['item_price'] ) && (float) $args['item_price'] != (float) $item['item_price'] ) {
1833
+                if (false !== $args['item_price']) {
1834
+                    if (isset($item['item_price']) && (float) $args['item_price'] != (float) $item['item_price']) {
1835 1835
                         continue;
1836 1836
                     }
1837 1837
                 }
@@ -1840,13 +1840,13 @@  discard block
 block discarded – undo
1840 1840
                 break;
1841 1841
             }
1842 1842
         } else {
1843
-            $cart_index = absint( $args['cart_index'] );
1843
+            $cart_index = absint($args['cart_index']);
1844 1844
 
1845
-            if ( ! array_key_exists( $cart_index, $this->cart_details ) ) {
1845
+            if (!array_key_exists($cart_index, $this->cart_details)) {
1846 1846
                 return false; // Invalid cart index passed.
1847 1847
             }
1848 1848
 
1849
-            if ( (int) $this->cart_details[ $cart_index ]['id'] > 0 && (int) $this->cart_details[ $cart_index ]['id'] !== (int) $item_id ) {
1849
+            if ((int) $this->cart_details[$cart_index]['id'] > 0 && (int) $this->cart_details[$cart_index]['id'] !== (int) $item_id) {
1850 1850
                 return false; // We still need the proper Item ID to be sure.
1851 1851
             }
1852 1852
 
@@ -1854,41 +1854,41 @@  discard block
 block discarded – undo
1854 1854
         }
1855 1855
         
1856 1856
         $cart_item  = $this->cart_details[$found_cart_key];
1857
-        $quantity   = !empty( $cart_item['quantity'] ) ? $cart_item['quantity'] : 1;
1857
+        $quantity   = !empty($cart_item['quantity']) ? $cart_item['quantity'] : 1;
1858 1858
         
1859
-        if ( count( $this->cart_details ) == 1 && ( $quantity - $args['quantity'] ) < 1 ) {
1859
+        if (count($this->cart_details) == 1 && ($quantity - $args['quantity']) < 1) {
1860 1860
             //return false; // Invoice must contain at least one item.
1861 1861
         }
1862 1862
         
1863
-        $discounts  = $this->get_discounts();
1863
+        $discounts = $this->get_discounts();
1864 1864
         
1865
-        if ( $quantity > $args['quantity'] ) {
1865
+        if ($quantity > $args['quantity']) {
1866 1866
             $item_price         = $cart_item['item_price'];
1867
-            $tax_rate           = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : 0;
1867
+            $tax_rate           = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : 0;
1868 1868
             
1869
-            $new_quantity       = max( $quantity - $args['quantity'], 1);
1869
+            $new_quantity       = max($quantity - $args['quantity'], 1);
1870 1870
             $subtotal           = $item_price * $new_quantity;
1871 1871
             
1872 1872
             $args['quantity']   = $new_quantity;
1873
-            $discount           = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1874
-            $tax                = $subtotal > 0 && $tax_rate > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1873
+            $discount           = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1874
+            $tax                = $subtotal > 0 && $tax_rate > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1875 1875
             
1876
-            $discount_decrease  = (float)$cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['discount'] / $quantity ) ) : 0;
1877
-            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float)$cart_item['discount'] > $discount ? (float)$cart_item['discount'] - $discount : $discount_decrease; 
1878
-            $tax_decrease       = (float)$cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount( ( (float)$cart_item['tax'] / $quantity ) ) : 0;
1879
-            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float)$cart_item['tax'] > $tax ? (float)$cart_item['tax'] - $tax : $tax_decrease;
1876
+            $discount_decrease  = (float) $cart_item['discount'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['discount'] / $quantity)) : 0;
1877
+            $discount_decrease  = $discount > 0 && $subtotal > 0 && (float) $cart_item['discount'] > $discount ? (float) $cart_item['discount'] - $discount : $discount_decrease; 
1878
+            $tax_decrease       = (float) $cart_item['tax'] > 0 && $quantity > 0 ? wpinv_round_amount(((float) $cart_item['tax'] / $quantity)) : 0;
1879
+            $tax_decrease       = $tax > 0 && $subtotal > 0 && (float) $cart_item['tax'] > $tax ? (float) $cart_item['tax'] - $tax : $tax_decrease;
1880 1880
             
1881 1881
             // The total increase equals the number removed * the item_price
1882
-            $total_decrease     = wpinv_round_amount( $item_price );
1882
+            $total_decrease     = wpinv_round_amount($item_price);
1883 1883
             
1884
-            if ( wpinv_prices_include_tax() ) {
1885
-                $subtotal -= wpinv_round_amount( $tax );
1884
+            if (wpinv_prices_include_tax()) {
1885
+                $subtotal -= wpinv_round_amount($tax);
1886 1886
             }
1887 1887
 
1888
-            $total              = $subtotal - $discount + $tax;
1888
+            $total = $subtotal - $discount + $tax;
1889 1889
 
1890 1890
             // Do not allow totals to go negative
1891
-            if( $total < 0 ) {
1891
+            if ($total < 0) {
1892 1892
                 $total = 0;
1893 1893
             }
1894 1894
             
@@ -1907,16 +1907,16 @@  discard block
 block discarded – undo
1907 1907
             
1908 1908
             $this->cart_details[$found_cart_key] = $cart_item;
1909 1909
             
1910
-            $remove_item = end( $this->cart_details );
1910
+            $remove_item = end($this->cart_details);
1911 1911
         } else {
1912 1912
             $item_price     = $cart_item['item_price'];
1913
-            $discount       = !empty( $cart_item['discount'] ) ? $cart_item['discount'] : 0;
1914
-            $tax            = !empty( $cart_item['tax'] ) ? $cart_item['tax'] : 0;
1913
+            $discount       = !empty($cart_item['discount']) ? $cart_item['discount'] : 0;
1914
+            $tax            = !empty($cart_item['tax']) ? $cart_item['tax'] : 0;
1915 1915
         
1916
-            $subtotal_decrease  = ( $item_price * $quantity ) - $discount;
1916
+            $subtotal_decrease  = ($item_price * $quantity) - $discount;
1917 1917
             $tax_decrease       = $tax;
1918 1918
 
1919
-            unset( $this->cart_details[$found_cart_key] );
1919
+            unset($this->cart_details[$found_cart_key]);
1920 1920
             
1921 1921
             $remove_item             = $args;
1922 1922
             $remove_item['id']       = $item_id;
@@ -1927,8 +1927,8 @@  discard block
 block discarded – undo
1927 1927
         $remove_item['action']      = 'remove';
1928 1928
         $this->pending['items'][]   = $remove_item;
1929 1929
                
1930
-        $this->decrease_subtotal( $subtotal_decrease );
1931
-        $this->decrease_tax( $tax_decrease );
1930
+        $this->decrease_subtotal($subtotal_decrease);
1931
+        $this->decrease_tax($tax_decrease);
1932 1932
         
1933 1933
         return true;
1934 1934
     }
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
     public function update_items($temp = false) {
1937 1937
         global $wpinv_euvat, $wpi_current_id, $wpi_item_id, $wpi_nosave;
1938 1938
         
1939
-        if ( !empty( $this->cart_details ) ) {
1939
+        if (!empty($this->cart_details)) {
1940 1940
             $wpi_nosave             = $temp;
1941 1941
             $cart_subtotal          = 0;
1942 1942
             $cart_discount          = 0;
@@ -1946,65 +1946,65 @@  discard block
 block discarded – undo
1946 1946
             $_POST['wpinv_country'] = $this->country;
1947 1947
             $_POST['wpinv_state']   = $this->state;
1948 1948
 
1949
-            foreach ( $this->cart_details as $key => $item ) {
1949
+            foreach ($this->cart_details as $key => $item) {
1950 1950
                 $item_price = $item['item_price'];
1951
-                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
1952
-                $amount     = wpinv_round_amount( $item_price * $quantity );
1951
+                $quantity   = wpinv_item_quantities_enabled() && $item['quantity'] > 0 ? absint($item['quantity']) : 1;
1952
+                $amount     = wpinv_round_amount($item_price * $quantity);
1953 1953
                 $subtotal   = $item_price * $quantity;
1954 1954
                 
1955 1955
                 $wpi_current_id         = $this->ID;
1956 1956
                 $wpi_item_id            = $item['id'];
1957 1957
                 
1958
-                $discount   = wpinv_get_cart_item_discount_amount( $item, $this->get_discounts() );
1958
+                $discount   = wpinv_get_cart_item_discount_amount($item, $this->get_discounts());
1959 1959
                 
1960
-                $tax_rate   = wpinv_get_tax_rate( $this->country, $this->state, $wpi_item_id );
1961
-                $tax_class  = $wpinv_euvat->get_item_class( $wpi_item_id );
1962
-                $tax        = $item_price > 0 ? ( ( $subtotal - $discount ) * 0.01 * (float)$tax_rate ) : 0;
1960
+                $tax_rate   = wpinv_get_tax_rate($this->country, $this->state, $wpi_item_id);
1961
+                $tax_class  = $wpinv_euvat->get_item_class($wpi_item_id);
1962
+                $tax        = $item_price > 0 ? (($subtotal - $discount) * 0.01 * (float) $tax_rate) : 0;
1963 1963
 
1964
-                if ( ! $this->is_taxable() ) {
1964
+                if (!$this->is_taxable()) {
1965 1965
                     $tax = 0;
1966 1966
                 }
1967 1967
 
1968
-                if ( wpinv_prices_include_tax() ) {
1969
-                    $subtotal -= wpinv_round_amount( $tax );
1968
+                if (wpinv_prices_include_tax()) {
1969
+                    $subtotal -= wpinv_round_amount($tax);
1970 1970
                 }
1971 1971
 
1972
-                $total      = $subtotal - $discount + $tax;
1972
+                $total = $subtotal - $discount + $tax;
1973 1973
 
1974 1974
                 // Do not allow totals to go negative
1975
-                if( $total < 0 ) {
1975
+                if ($total < 0) {
1976 1976
                     $total = 0;
1977 1977
                 }
1978 1978
 
1979 1979
                 $cart_details[] = array(
1980 1980
                     'id'          => $item['id'],
1981 1981
                     'name'        => $item['name'],
1982
-                    'item_price'  => wpinv_round_amount( $item_price ),
1983
-                    'custom_price'=> ( isset( $item['custom_price'] ) ? $item['custom_price'] : '' ),
1982
+                    'item_price'  => wpinv_round_amount($item_price),
1983
+                    'custom_price'=> (isset($item['custom_price']) ? $item['custom_price'] : ''),
1984 1984
                     'quantity'    => $quantity,
1985 1985
                     'discount'    => $discount,
1986
-                    'subtotal'    => wpinv_round_amount( $subtotal ),
1987
-                    'tax'         => wpinv_round_amount( $tax ),
1988
-                    'price'       => wpinv_round_amount( $total ),
1986
+                    'subtotal'    => wpinv_round_amount($subtotal),
1987
+                    'tax'         => wpinv_round_amount($tax),
1988
+                    'price'       => wpinv_round_amount($total),
1989 1989
                     'vat_rate'    => $tax_rate,
1990 1990
                     'vat_class'   => $tax_class,
1991 1991
                     'meta'        => isset($item['meta']) ? $item['meta'] : array(),
1992 1992
                     'fees'        => isset($item['fees']) ? $item['fees'] : array(),
1993 1993
                 );
1994 1994
 
1995
-                $cart_subtotal  += (float)($subtotal - $discount); // TODO
1996
-                $cart_discount  += (float)($discount);
1997
-                $cart_tax       += (float)($tax);
1995
+                $cart_subtotal  += (float) ($subtotal - $discount); // TODO
1996
+                $cart_discount  += (float) ($discount);
1997
+                $cart_tax       += (float) ($tax);
1998 1998
             }
1999
-            if ( $cart_subtotal < 0 ) {
1999
+            if ($cart_subtotal < 0) {
2000 2000
                 $cart_subtotal = 0;
2001 2001
             }
2002
-            if ( $cart_tax < 0 ) {
2002
+            if ($cart_tax < 0) {
2003 2003
                 $cart_tax = 0;
2004 2004
             }
2005
-            $this->subtotal = wpinv_round_amount( $cart_subtotal );
2006
-            $this->tax      = wpinv_round_amount( $cart_tax );
2007
-            $this->discount = wpinv_round_amount( $cart_discount );
2005
+            $this->subtotal = wpinv_round_amount($cart_subtotal);
2006
+            $this->tax      = wpinv_round_amount($cart_tax);
2007
+            $this->discount = wpinv_round_amount($cart_discount);
2008 2008
             
2009 2009
             $this->recalculate_total();
2010 2010
             
@@ -2016,177 +2016,177 @@  discard block
 block discarded – undo
2016 2016
     
2017 2017
     public function recalculate_totals($temp = false) {        
2018 2018
         $this->update_items($temp);
2019
-        $this->save( true );
2019
+        $this->save(true);
2020 2020
         
2021 2021
         return $this;
2022 2022
     }
2023 2023
     
2024 2024
     public function needs_payment() {
2025
-        $valid_invoice_statuses = apply_filters( 'wpinv_valid_invoice_statuses_for_payment', array( 'wpi-pending' ), $this );
2025
+        $valid_invoice_statuses = apply_filters('wpinv_valid_invoice_statuses_for_payment', array('wpi-pending'), $this);
2026 2026
 
2027
-        if ( $this->has_status( $valid_invoice_statuses ) && ( $this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free() ) ) {
2027
+        if ($this->has_status($valid_invoice_statuses) && ($this->get_total() > 0 || $this->is_free_trial() || $this->is_free() || $this->is_initial_free())) {
2028 2028
             $needs_payment = true;
2029 2029
         } else {
2030 2030
             $needs_payment = false;
2031 2031
         }
2032 2032
 
2033
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses );
2033
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this, $valid_invoice_statuses);
2034 2034
     }
2035 2035
     
2036
-    public function get_checkout_payment_url( $with_key = false, $secret = false ) {
2036
+    public function get_checkout_payment_url($with_key = false, $secret = false) {
2037 2037
         $pay_url = wpinv_get_checkout_uri();
2038 2038
 
2039
-        if ( is_ssl() ) {
2040
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
2039
+        if (is_ssl()) {
2040
+            $pay_url = str_replace('http:', 'https:', $pay_url);
2041 2041
         }
2042 2042
         
2043 2043
         $key = $this->get_key();
2044 2044
 
2045
-        if ( $with_key ) {
2046
-            $pay_url = add_query_arg( 'invoice_key', $key, $pay_url );
2045
+        if ($with_key) {
2046
+            $pay_url = add_query_arg('invoice_key', $key, $pay_url);
2047 2047
         } else {
2048
-            $pay_url = add_query_arg( array( 'wpi_action' => 'pay_for_invoice', 'invoice_key' => $key ), $pay_url );
2048
+            $pay_url = add_query_arg(array('wpi_action' => 'pay_for_invoice', 'invoice_key' => $key), $pay_url);
2049 2049
         }
2050 2050
         
2051
-        if ( $secret ) {
2052
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $key ) ), $pay_url );
2051
+        if ($secret) {
2052
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $key)), $pay_url);
2053 2053
         }
2054 2054
 
2055
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret );
2055
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $with_key, $secret);
2056 2056
     }
2057 2057
     
2058
-    public function get_view_url( $with_key = false ) {
2059
-        $invoice_url = get_permalink( $this->ID );
2058
+    public function get_view_url($with_key = false) {
2059
+        $invoice_url = get_permalink($this->ID);
2060 2060
 
2061
-        if ( $with_key ) {
2062
-            $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
2061
+        if ($with_key) {
2062
+            $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
2063 2063
         }
2064 2064
 
2065
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this, $with_key );
2065
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this, $with_key);
2066 2066
     }
2067 2067
     
2068
-    public function generate_key( $string = '' ) {
2069
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
2070
-        return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) );  // Unique key
2068
+    public function generate_key($string = '') {
2069
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
2070
+        return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key
2071 2071
     }
2072 2072
     
2073 2073
     public function is_recurring() {
2074
-        if ( empty( $this->cart_details ) ) {
2074
+        if (empty($this->cart_details)) {
2075 2075
             return false;
2076 2076
         }
2077 2077
         
2078 2078
         $has_subscription = false;
2079
-        foreach( $this->cart_details as $cart_item ) {
2080
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2079
+        foreach ($this->cart_details as $cart_item) {
2080
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2081 2081
                 $has_subscription = true;
2082 2082
                 break;
2083 2083
             }
2084 2084
         }
2085 2085
         
2086
-        if ( count( $this->cart_details ) > 1 ) {
2086
+        if (count($this->cart_details) > 1) {
2087 2087
             $has_subscription = false;
2088 2088
         }
2089 2089
 
2090
-        return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details );
2090
+        return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details);
2091 2091
     }
2092 2092
 
2093 2093
     public function is_free_trial() {
2094 2094
         $is_free_trial = false;
2095 2095
         
2096
-        if ( $this->is_parent() && $item = $this->get_recurring( true ) ) {
2097
-            if ( !empty( $item ) && $item->has_free_trial() ) {
2096
+        if ($this->is_parent() && $item = $this->get_recurring(true)) {
2097
+            if (!empty($item) && $item->has_free_trial()) {
2098 2098
                 $is_free_trial = true;
2099 2099
             }
2100 2100
         }
2101 2101
 
2102
-        return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this );
2102
+        return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this);
2103 2103
     }
2104 2104
 
2105 2105
     public function is_initial_free() {
2106 2106
         $is_initial_free = false;
2107 2107
         
2108
-        if ( ! ( (float)wpinv_round_amount( $this->get_total() ) > 0 ) && $this->is_parent() && $this->is_recurring() && ! $this->is_free_trial() && ! $this->is_free() ) {
2108
+        if (!((float) wpinv_round_amount($this->get_total()) > 0) && $this->is_parent() && $this->is_recurring() && !$this->is_free_trial() && !$this->is_free()) {
2109 2109
             $is_initial_free = true;
2110 2110
         }
2111 2111
 
2112
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details );
2112
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->cart_details);
2113 2113
     }
2114 2114
     
2115
-    public function get_recurring( $object = false ) {
2115
+    public function get_recurring($object = false) {
2116 2116
         $item = NULL;
2117 2117
         
2118
-        if ( empty( $this->cart_details ) ) {
2118
+        if (empty($this->cart_details)) {
2119 2119
             return $item;
2120 2120
         }
2121 2121
         
2122
-        foreach( $this->cart_details as $cart_item ) {
2123
-            if ( !empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] )  ) {
2122
+        foreach ($this->cart_details as $cart_item) {
2123
+            if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) {
2124 2124
                 $item = $cart_item['id'];
2125 2125
                 break;
2126 2126
             }
2127 2127
         }
2128 2128
         
2129
-        if ( $object ) {
2130
-            $item = $item ? new WPInv_Item( $item ) : NULL;
2129
+        if ($object) {
2130
+            $item = $item ? new WPInv_Item($item) : NULL;
2131 2131
             
2132
-            apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this );
2132
+            apply_filters('wpinv_invoice_get_recurring_item', $item, $this);
2133 2133
         }
2134 2134
 
2135
-        return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this );
2135
+        return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this);
2136 2136
     }
2137 2137
     
2138 2138
     public function get_subscription_name() {
2139
-        $item = $this->get_recurring( true );
2139
+        $item = $this->get_recurring(true);
2140 2140
         
2141
-        if ( empty( $item ) ) {
2141
+        if (empty($item)) {
2142 2142
             return NULL;
2143 2143
         }
2144 2144
         
2145
-        if ( !($name = $item->get_name()) ) {
2145
+        if (!($name = $item->get_name())) {
2146 2146
             $name = $item->post_name;
2147 2147
         }
2148 2148
 
2149
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $name, $this );
2149
+        return apply_filters('wpinv_invoice_get_subscription_name', $name, $this);
2150 2150
     }
2151 2151
     
2152 2152
     public function get_subscription_id() {
2153
-        $subscription_id = $this->get_meta( '_wpinv_subscr_profile_id', true );
2153
+        $subscription_id = $this->get_meta('_wpinv_subscr_profile_id', true);
2154 2154
         
2155
-        if ( empty( $subscription_id ) && !empty( $this->parent_invoice ) ) {
2156
-            $parent_invoice = wpinv_get_invoice( $this->parent_invoice );
2155
+        if (empty($subscription_id) && !empty($this->parent_invoice)) {
2156
+            $parent_invoice = wpinv_get_invoice($this->parent_invoice);
2157 2157
             
2158
-            $subscription_id = $parent_invoice->get_meta( '_wpinv_subscr_profile_id', true );
2158
+            $subscription_id = $parent_invoice->get_meta('_wpinv_subscr_profile_id', true);
2159 2159
         }
2160 2160
         
2161 2161
         return $subscription_id;
2162 2162
     }
2163 2163
     
2164 2164
     public function is_parent() {
2165
-        $is_parent = empty( $this->parent_invoice ) ? true : false;
2165
+        $is_parent = empty($this->parent_invoice) ? true : false;
2166 2166
 
2167
-        return apply_filters( 'wpinv_invoice_is_parent', $is_parent, $this );
2167
+        return apply_filters('wpinv_invoice_is_parent', $is_parent, $this);
2168 2168
     }
2169 2169
     
2170 2170
     public function is_renewal() {
2171 2171
         $is_renewal = $this->parent_invoice && $this->parent_invoice != $this->ID ? true : false;
2172 2172
 
2173
-        return apply_filters( 'wpinv_invoice_is_renewal', $is_renewal, $this );
2173
+        return apply_filters('wpinv_invoice_is_renewal', $is_renewal, $this);
2174 2174
     }
2175 2175
     
2176 2176
     public function get_parent_payment() {
2177 2177
         $parent_payment = NULL;
2178 2178
         
2179
-        if ( $this->is_renewal() ) {
2180
-            $parent_payment = wpinv_get_invoice( $this->parent_invoice );
2179
+        if ($this->is_renewal()) {
2180
+            $parent_payment = wpinv_get_invoice($this->parent_invoice);
2181 2181
         }
2182 2182
         
2183 2183
         return $parent_payment;
2184 2184
     }
2185 2185
     
2186 2186
     public function is_paid() {
2187
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2187
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2188 2188
 
2189
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2189
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2190 2190
     }
2191 2191
 
2192 2192
     /**
@@ -2199,23 +2199,23 @@  discard block
 block discarded – undo
2199 2199
     }
2200 2200
     
2201 2201
     public function is_refunded() {
2202
-        $is_refunded = $this->has_status( array( 'wpi-refunded' ) );
2202
+        $is_refunded = $this->has_status(array('wpi-refunded'));
2203 2203
 
2204
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2204
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2205 2205
     }
2206 2206
     
2207 2207
     public function is_free() {
2208 2208
         $is_free = false;
2209 2209
         
2210
-        if ( !( (float)wpinv_round_amount( $this->get_total() ) > 0 ) ) {
2211
-            if ( $this->is_parent() && $this->is_recurring() ) {
2212
-                $is_free = (float)wpinv_round_amount( $this->get_recurring_details( 'total' ) ) > 0 ? false : true;
2210
+        if (!((float) wpinv_round_amount($this->get_total()) > 0)) {
2211
+            if ($this->is_parent() && $this->is_recurring()) {
2212
+                $is_free = (float) wpinv_round_amount($this->get_recurring_details('total')) > 0 ? false : true;
2213 2213
             } else {
2214 2214
                 $is_free = true;
2215 2215
             }
2216 2216
         }
2217 2217
         
2218
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2218
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2219 2219
     }
2220 2220
     
2221 2221
     public function has_vat() {
@@ -2223,41 +2223,41 @@  discard block
 block discarded – undo
2223 2223
         
2224 2224
         $requires_vat = false;
2225 2225
         
2226
-        if ( $this->country ) {
2226
+        if ($this->country) {
2227 2227
             $wpi_country        = $this->country;
2228 2228
             
2229
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2229
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2230 2230
         }
2231 2231
         
2232
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2232
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2233 2233
     }
2234 2234
     
2235 2235
     public function refresh_item_ids() {
2236 2236
         $item_ids = array();
2237 2237
         
2238
-        if ( !empty( $this->cart_details ) ) {
2239
-            foreach ( $this->cart_details as $key => $item ) {
2240
-                if ( !empty( $item['id'] ) ) {
2238
+        if (!empty($this->cart_details)) {
2239
+            foreach ($this->cart_details as $key => $item) {
2240
+                if (!empty($item['id'])) {
2241 2241
                     $item_ids[] = $item['id'];
2242 2242
                 }
2243 2243
             }
2244 2244
         }
2245 2245
         
2246
-        $item_ids = !empty( $item_ids ) ? implode( ',', array_unique( $item_ids ) ) : '';
2246
+        $item_ids = !empty($item_ids) ? implode(',', array_unique($item_ids)) : '';
2247 2247
         
2248
-        update_post_meta( $this->ID, '_wpinv_item_ids', $item_ids );
2248
+        update_post_meta($this->ID, '_wpinv_item_ids', $item_ids);
2249 2249
     }
2250 2250
     
2251
-    public function get_invoice_quote_type( $post_id ) {
2252
-        if ( empty( $post_id ) ) {
2251
+    public function get_invoice_quote_type($post_id) {
2252
+        if (empty($post_id)) {
2253 2253
             return '';
2254 2254
         }
2255 2255
 
2256
-        $type = get_post_type( $post_id );
2256
+        $type = get_post_type($post_id);
2257 2257
 
2258
-        if ( 'wpi_invoice' === $type ) {
2258
+        if ('wpi_invoice' === $type) {
2259 2259
             $post_type = __('Invoice', 'invoicing');
2260
-        } else{
2260
+        } else {
2261 2261
             $post_type = __('Quote', 'invoicing');
2262 2262
         }
2263 2263
 
Please login to merge, or discard this patch.
includes/data/sample-payment-form-items.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 
Please login to merge, or discard this patch.