Passed
Pull Request — master (#42)
by Farhan
05:05
created
includes/wpinv-payment-functions.php 1 patch
Spacing   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-function wpinv_get_subscriptions( $args = array() ) {
3
-    if ( empty( $args['parent_invoice_id'] ) ) {
2
+function wpinv_get_subscriptions($args = array()) {
3
+    if (empty($args['parent_invoice_id'])) {
4 4
         return false;
5 5
     }
6 6
     
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
     );
15 15
 
16 16
     $args['post_parent']    = $args['parent_invoice_id'];
17
-    $args                   = wp_parse_args( $args, $defaults );
17
+    $args                   = wp_parse_args($args, $defaults);
18 18
 
19
-    if( $args['numberposts'] < 1 ) {
19
+    if ($args['numberposts'] < 1) {
20 20
         $args['numberposts'] = 999999999999;
21 21
     }
22 22
 
23
-    $posts          = get_posts( $args );
23
+    $posts          = get_posts($args);
24 24
     $subscriptions  = array();
25
-    if ( !empty( $posts ) ) {
26
-        foreach ( $posts as $post ) {
27
-            if ( !empty( $post->ID ) ) {
28
-                $subscriptions[] = wpinv_get_invoice( $post->ID );
25
+    if (!empty($posts)) {
26
+        foreach ($posts as $post) {
27
+            if (!empty($post->ID)) {
28
+                $subscriptions[] = wpinv_get_invoice($post->ID);
29 29
             }
30 30
         }
31 31
     }
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
     
34 34
     return $subscriptions;
35 35
 }
36
-function wpinv_get_subscription( $id = 0, $by_profile_id = false ) {
36
+function wpinv_get_subscription($id = 0, $by_profile_id = false) {
37 37
     global $wpdb;
38 38
 
39
-    if ( empty( $id ) ) {
39
+    if (empty($id)) {
40 40
         return false;
41 41
     }
42 42
 
43
-    $id = esc_sql( $id );
43
+    $id = esc_sql($id);
44 44
 
45
-    $invoice_id = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1" );
45
+    $invoice_id = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_profile_id' AND meta_value = '{$id}' LIMIT 1");
46 46
 
47
-    if ( $invoice_id != null ) {
48
-        return wpinv_get_invoice( $invoice_id );
47
+    if ($invoice_id != null) {
48
+        return wpinv_get_invoice($invoice_id);
49 49
     }
50 50
 
51 51
     return false;
@@ -55,49 +55,49 @@  discard block
 block discarded – undo
55 55
  * Records a new payment on the subscription
56 56
  * 
57 57
  */
58
-function wpinv_recurring_add_subscription_payment( $parent_invoice_id, $subscription_args = array() ) {    
59
-    $args = wp_parse_args( $subscription_args, array(
58
+function wpinv_recurring_add_subscription_payment($parent_invoice_id, $subscription_args = array()) {    
59
+    $args = wp_parse_args($subscription_args, array(
60 60
         'amount'         => '',
61 61
         'transaction_id' => '',
62 62
         'gateway'        => ''
63
-    ) );
63
+    ));
64 64
 
65
-    if ( wpinv_payment_exists( $args['transaction_id'] ) ) {
65
+    if (wpinv_payment_exists($args['transaction_id'])) {
66 66
         return false;
67 67
     }
68 68
     
69
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
70
-    if ( empty( $parent_invoice ) ) {
69
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
70
+    if (empty($parent_invoice)) {
71 71
         return;
72 72
     }
73 73
 
74 74
     $invoice = new WPInv_Invoice();
75
-    $invoice->set( 'parent_invoice', $parent_invoice_id );
76
-    $invoice->set( 'currency', $parent_invoice->get_currency() );
75
+    $invoice->set('parent_invoice', $parent_invoice_id);
76
+    $invoice->set('currency', $parent_invoice->get_currency());
77 77
     //$invoice->set( 'status', 'publish' );
78
-    $invoice->set( 'transaction_id', $args['transaction_id'] );
79
-    $invoice->set( 'key', $parent_invoice->get_key() );
78
+    $invoice->set('transaction_id', $args['transaction_id']);
79
+    $invoice->set('key', $parent_invoice->get_key());
80 80
     
81
-    $invoice->set( 'ip', $parent_invoice->ip );
82
-    $invoice->set( 'user_id', $parent_invoice->get_user_id() );
83
-    $invoice->set( 'first_name', $parent_invoice->get_first_name() );
84
-    $invoice->set( 'last_name', $parent_invoice->get_last_name() );
81
+    $invoice->set('ip', $parent_invoice->ip);
82
+    $invoice->set('user_id', $parent_invoice->get_user_id());
83
+    $invoice->set('first_name', $parent_invoice->get_first_name());
84
+    $invoice->set('last_name', $parent_invoice->get_last_name());
85 85
     ///$invoice->set( 'email', $parent_invoice->get_email() );
86
-    $invoice->set( 'phone', $parent_invoice->phone );
87
-    $invoice->set( 'address', $parent_invoice->address );
88
-    $invoice->set( 'city', $parent_invoice->city );
89
-    $invoice->set( 'country', $parent_invoice->country );
90
-    $invoice->set( 'state', $parent_invoice->state );
91
-    $invoice->set( 'zip', $parent_invoice->zip );
92
-    $invoice->set( 'company', $parent_invoice->company );
93
-    $invoice->set( 'vat_number', $parent_invoice->vat_number );
94
-    $invoice->set( 'vat_rate', $parent_invoice->vat_rate );
95
-    $invoice->set( 'adddress_confirmed', $parent_invoice->adddress_confirmed );
96
-
97
-    if ( empty( $args['gateway'] ) ) {
98
-        $invoice->set( 'gateway', $parent_invoice->get_gateway() );
86
+    $invoice->set('phone', $parent_invoice->phone);
87
+    $invoice->set('address', $parent_invoice->address);
88
+    $invoice->set('city', $parent_invoice->city);
89
+    $invoice->set('country', $parent_invoice->country);
90
+    $invoice->set('state', $parent_invoice->state);
91
+    $invoice->set('zip', $parent_invoice->zip);
92
+    $invoice->set('company', $parent_invoice->company);
93
+    $invoice->set('vat_number', $parent_invoice->vat_number);
94
+    $invoice->set('vat_rate', $parent_invoice->vat_rate);
95
+    $invoice->set('adddress_confirmed', $parent_invoice->adddress_confirmed);
96
+
97
+    if (empty($args['gateway'])) {
98
+        $invoice->set('gateway', $parent_invoice->get_gateway());
99 99
     } else {
100
-        $invoice->set( 'gateway', $args['gateway'] );
100
+        $invoice->set('gateway', $args['gateway']);
101 101
     }
102 102
     
103 103
     $recurring_details = $parent_invoice->get_recurring_details();
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
     // increase the earnings for each item in the subscription
106 106
     $items = $recurring_details['cart_details'];
107 107
     
108
-    if ( $items ) {        
108
+    if ($items) {        
109 109
         $add_items      = array();
110 110
         $cart_details   = array();
111 111
         
112
-        foreach ( $items as $item ) {
112
+        foreach ($items as $item) {
113 113
             $add_item             = array();
114 114
             $add_item['id']       = $item['id'];
115 115
             $add_item['quantity'] = $item['quantity'];
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
             break;
120 120
         }
121 121
         
122
-        $invoice->set( 'items', $add_items );
122
+        $invoice->set('items', $add_items);
123 123
         $invoice->cart_details = $cart_details;
124 124
     }
125 125
     
@@ -129,277 +129,277 @@  discard block
 block discarded – undo
129 129
     $tax                = $recurring_details['tax'];
130 130
     $discount           = $recurring_details['discount'];
131 131
     
132
-    if ( $discount > 0 ) {
133
-        $invoice->set( 'discount_code', $parent_invoice->discount_code );
132
+    if ($discount > 0) {
133
+        $invoice->set('discount_code', $parent_invoice->discount_code);
134 134
     }
135 135
     
136
-    $invoice->subtotal = wpinv_format_amount( $subtotal, NULL, true );
137
-    $invoice->tax      = wpinv_format_amount( $tax, NULL, true );
138
-    $invoice->discount = wpinv_format_amount( $discount, NULL, true );
139
-    $invoice->total    = wpinv_format_amount( $total, NULL, true );
136
+    $invoice->subtotal = wpinv_format_amount($subtotal, NULL, true);
137
+    $invoice->tax      = wpinv_format_amount($tax, NULL, true);
138
+    $invoice->discount = wpinv_format_amount($discount, NULL, true);
139
+    $invoice->total    = wpinv_format_amount($total, NULL, true);
140 140
     $invoice->save();
141 141
     
142
-    wpinv_update_payment_status( $invoice->ID, 'publish' );
142
+    wpinv_update_payment_status($invoice->ID, 'publish');
143 143
     sleep(1);
144
-    wpinv_update_payment_status( $invoice->ID, 'wpi-renewal' );
144
+    wpinv_update_payment_status($invoice->ID, 'wpi-renewal');
145 145
     
146
-    $invoice = wpinv_get_invoice( $invoice->ID );
146
+    $invoice = wpinv_get_invoice($invoice->ID);
147 147
     
148
-    $subscription_data                      = wpinv_payment_subscription_data( $parent_invoice );
148
+    $subscription_data                      = wpinv_payment_subscription_data($parent_invoice);
149 149
     $subscription_data['recurring_amount']  = $invoice->get_total();
150
-    $subscription_data['created']           = current_time( 'mysql', 0 );
151
-    $subscription_data['expiration']        = $invoice->get_new_expiration( $subscription_data['item_id'] );
150
+    $subscription_data['created']           = current_time('mysql', 0);
151
+    $subscription_data['expiration']        = $invoice->get_new_expiration($subscription_data['item_id']);
152 152
     
153 153
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
154
-    $invoice->update_subscription( $subscription_data );
154
+    $invoice->update_subscription($subscription_data);
155 155
 
156
-    do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args );
157
-    do_action( 'wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args );
156
+    do_action('wpinv_recurring_add_subscription_payment', $invoice, $parent_invoice, $subscription_args);
157
+    do_action('wpinv_recurring_record_payment', $invoice->ID, $parent_invoice_id, $subscription_args);
158 158
 
159 159
     return $invoice;
160 160
 }
161 161
 
162
-function wpinv_payment_exists( $txn_id = '' ) {
162
+function wpinv_payment_exists($txn_id = '') {
163 163
     global $wpdb;
164 164
 
165
-    if ( empty( $txn_id ) ) {
165
+    if (empty($txn_id)) {
166 166
         return false;
167 167
     }
168 168
 
169
-    $txn_id = esc_sql( $txn_id );
169
+    $txn_id = esc_sql($txn_id);
170 170
 
171
-    $invoice = $wpdb->get_var( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1" );
171
+    $invoice = $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_transaction_id' AND meta_value = '{$txn_id}' LIMIT 1");
172 172
 
173
-    if ( $invoice != null ) {
173
+    if ($invoice != null) {
174 174
         return true;
175 175
     }
176 176
 
177 177
     return false;
178 178
 }
179 179
 
180
-function wpinv_is_subscription_payment( $invoice = '' ) {
181
-    if ( empty( $invoice ) ) {
180
+function wpinv_is_subscription_payment($invoice = '') {
181
+    if (empty($invoice)) {
182 182
         return false;
183 183
     }
184 184
     
185
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
186
-        $invoice = wpinv_get_invoice( $invoice );
185
+    if (!is_object($invoice) && is_scalar($invoice)) {
186
+        $invoice = wpinv_get_invoice($invoice);
187 187
     }
188 188
     
189
-    if ( empty( $invoice ) ) {
189
+    if (empty($invoice)) {
190 190
         return false;
191 191
     }
192 192
         
193
-    if ( $invoice->is_renewal() ) {
193
+    if ($invoice->is_renewal()) {
194 194
         return true;
195 195
     }
196 196
 
197 197
     return false;
198 198
 }
199 199
 
200
-function wpinv_payment_subscription_data( $invoice = '' ) {
201
-    if ( empty( $invoice ) ) {
200
+function wpinv_payment_subscription_data($invoice = '') {
201
+    if (empty($invoice)) {
202 202
         return false;
203 203
     }
204 204
     
205
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
206
-        $invoice = wpinv_get_invoice( $invoice );
205
+    if (!is_object($invoice) && is_scalar($invoice)) {
206
+        $invoice = wpinv_get_invoice($invoice);
207 207
     }
208 208
     
209
-    if ( empty( $invoice ) ) {
209
+    if (empty($invoice)) {
210 210
         return false;
211 211
     }    
212 212
 
213 213
     return $invoice->get_subscription_data();
214 214
 }
215 215
 
216
-function wpinv_payment_link_transaction_id( $invoice = '' ) {
217
-    if ( empty( $invoice ) ) {
216
+function wpinv_payment_link_transaction_id($invoice = '') {
217
+    if (empty($invoice)) {
218 218
         return false;
219 219
     }
220 220
     
221
-    if ( !is_object( $invoice ) && is_scalar( $invoice ) ) {
222
-        $invoice = wpinv_get_invoice( $invoice );
221
+    if (!is_object($invoice) && is_scalar($invoice)) {
222
+        $invoice = wpinv_get_invoice($invoice);
223 223
     }
224 224
     
225
-    if ( empty( $invoice ) ) {
225
+    if (empty($invoice)) {
226 226
         return false;
227 227
     }
228 228
 
229
-    return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice );
229
+    return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice);
230 230
 }
231 231
 
232
-function wpinv_get_pretty_subscription_period( $period ) {
232
+function wpinv_get_pretty_subscription_period($period) {
233 233
     $frequency = '';
234 234
     //Format period details
235
-    switch ( $period ) {
235
+    switch ($period) {
236 236
         case 'D' :
237 237
         case 'day' :
238
-            $frequency = __( 'Daily', 'invoicing' );
238
+            $frequency = __('Daily', 'invoicing');
239 239
             break;
240 240
         case 'W' :
241 241
         case 'week' :
242
-            $frequency = __( 'Weekly', 'invoicing' );
242
+            $frequency = __('Weekly', 'invoicing');
243 243
             break;
244 244
         case 'M' :
245 245
         case 'month' :
246
-            $frequency = __( 'Monthly', 'invoicing' );
246
+            $frequency = __('Monthly', 'invoicing');
247 247
             break;
248 248
         case 'Y' :
249 249
         case 'year' :
250
-            $frequency = __( 'Yearly', 'invoicing' );
250
+            $frequency = __('Yearly', 'invoicing');
251 251
             break;
252 252
         default :
253
-            $frequency = apply_filters( 'wpinv_pretty_subscription_period', $frequency, $period );
253
+            $frequency = apply_filters('wpinv_pretty_subscription_period', $frequency, $period);
254 254
             break;
255 255
     }
256 256
 
257 257
     return $frequency;
258 258
 }
259 259
 
260
-function wpinv_get_pretty_subscription_period_name( $period ) {
260
+function wpinv_get_pretty_subscription_period_name($period) {
261 261
     $frequency = '';
262 262
     //Format period details
263
-    switch ( $period ) {
263
+    switch ($period) {
264 264
         case 'D' :
265 265
         case 'day' :
266
-            $frequency = __( 'Day', 'invoicing' );
266
+            $frequency = __('Day', 'invoicing');
267 267
             break;
268 268
         case 'W' :
269 269
         case 'week' :
270
-            $frequency = __( 'Week', 'invoicing' );
270
+            $frequency = __('Week', 'invoicing');
271 271
             break;
272 272
         case 'M' :
273 273
         case 'month' :
274
-            $frequency = __( 'Month', 'invoicing' );
274
+            $frequency = __('Month', 'invoicing');
275 275
             break;
276 276
         case 'Y' :
277 277
         case 'year' :
278
-            $frequency = __( 'Year', 'invoicing' );
278
+            $frequency = __('Year', 'invoicing');
279 279
             break;
280 280
         default :
281
-            $frequency = apply_filters( 'wpinv_pretty_subscription_period_name', $frequency, $period );
281
+            $frequency = apply_filters('wpinv_pretty_subscription_period_name', $frequency, $period);
282 282
             break;
283 283
     }
284 284
 
285 285
     return $frequency;
286 286
 }
287 287
 
288
-function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) {
288
+function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) {
289 289
     $interval   = (int)$interval > 0 ? (int)$interval : 1;
290 290
     
291
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
292
-        $amount = __( 'Free', 'invoicing' );
291
+    if ($trial_interval > 0 && !empty($trial_period)) {
292
+        $amount = __('Free', 'invoicing');
293 293
         $interval = $trial_interval;
294 294
         $period = $trial_period;
295 295
     }
296 296
     
297 297
     $description = '';
298
-    switch ( $period ) {
298
+    switch ($period) {
299 299
         case 'D' :
300 300
         case 'day' :
301
-            $description = wp_sprintf( _n( '%s for the first day.', '%s for the first %d days.', $interval, 'invoicing' ), $amount, $interval );
301
+            $description = wp_sprintf(_n('%s for the first day.', '%s for the first %d days.', $interval, 'invoicing'), $amount, $interval);
302 302
             break;
303 303
         case 'W' :
304 304
         case 'week' :
305
-            $description = wp_sprintf( _n( '%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing' ), $amount, $interval );
305
+            $description = wp_sprintf(_n('%s for the first week.', '%s for the first %d weeks.', $interval, 'invoicing'), $amount, $interval);
306 306
             break;
307 307
         case 'M' :
308 308
         case 'month' :
309
-            $description = wp_sprintf( _n( '%s for the first month.', '%s for the first %d months.', $interval, 'invoicing' ), $amount, $interval );
309
+            $description = wp_sprintf(_n('%s for the first month.', '%s for the first %d months.', $interval, 'invoicing'), $amount, $interval);
310 310
             break;
311 311
         case 'Y' :
312 312
         case 'year' :
313
-            $description = wp_sprintf( _n( '%s for the first year.', '%s for the first %d years.', $interval, 'invoicing' ), $amount, $interval );
313
+            $description = wp_sprintf(_n('%s for the first year.', '%s for the first %d years.', $interval, 'invoicing'), $amount, $interval);
314 314
             break;
315 315
     }
316 316
 
317
-    return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval  );
317
+    return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval);
318 318
 }
319 319
 
320
-function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) {
320
+function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) {
321 321
     $interval   = (int)$interval > 0 ? (int)$interval : 1;
322 322
     $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0;
323 323
     
324 324
     $description = '';
325
-    switch ( $period ) {
325
+    switch ($period) {
326 326
         case 'D' :
327 327
         case 'day' :            
328
-            if ( (int)$bill_times > 0 ) {
329
-                if ( $interval > 1 ) {
330
-                    if ( $bill_times > 1 ) {
331
-                        $description = wp_sprintf( __( '%s for each %d days, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
328
+            if ((int)$bill_times > 0) {
329
+                if ($interval > 1) {
330
+                    if ($bill_times > 1) {
331
+                        $description = wp_sprintf(__('%s for each %d days, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
332 332
                     } else {
333
-                        $description = wp_sprintf( __( '%s for %d days.', 'invoicing' ), $amount, $interval );
333
+                        $description = wp_sprintf(__('%s for %d days.', 'invoicing'), $amount, $interval);
334 334
                     }
335 335
                 } else {
336
-                    $description = wp_sprintf( _n( '%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
336
+                    $description = wp_sprintf(_n('%s for one day.', '%s for each day, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
337 337
                 }
338 338
             } else {
339
-                $description = wp_sprintf( _n( '%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval );
339
+                $description = wp_sprintf(_n('%s for each day.', '%s for each %d days.', $interval, 'invoicing'), $amount, $interval);
340 340
             }
341 341
             break;
342 342
         case 'W' :
343 343
         case 'week' :            
344
-            if ( (int)$bill_times > 0 ) {
345
-                if ( $interval > 1 ) {
346
-                    if ( $bill_times > 1 ) {
347
-                        $description = wp_sprintf( __( '%s for each %d weeks, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
344
+            if ((int)$bill_times > 0) {
345
+                if ($interval > 1) {
346
+                    if ($bill_times > 1) {
347
+                        $description = wp_sprintf(__('%s for each %d weeks, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
348 348
                     } else {
349
-                        $description = wp_sprintf( __( '%s for %d weeks.', 'invoicing' ), $amount, $interval );
349
+                        $description = wp_sprintf(__('%s for %d weeks.', 'invoicing'), $amount, $interval);
350 350
                     }
351 351
                 } else {
352
-                    $description = wp_sprintf( _n( '%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
352
+                    $description = wp_sprintf(_n('%s for one week.', '%s for each week, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
353 353
                 }
354 354
             } else {
355
-                $description = wp_sprintf( _n( '%s for each week.', '%s for each %d weeks.', $interval, 'invoicing' ), $amount, $interval );
355
+                $description = wp_sprintf(_n('%s for each week.', '%s for each %d weeks.', $interval, 'invoicing'), $amount, $interval);
356 356
             }
357 357
             break;
358 358
         case 'M' :
359 359
         case 'month' :            
360
-            if ( (int)$bill_times > 0 ) {
361
-                if ( $interval > 1 ) {
362
-                    if ( $bill_times > 1 ) {
363
-                        $description = wp_sprintf( __( '%s for each %d months, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
360
+            if ((int)$bill_times > 0) {
361
+                if ($interval > 1) {
362
+                    if ($bill_times > 1) {
363
+                        $description = wp_sprintf(__('%s for each %d months, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
364 364
                     } else {
365
-                        $description = wp_sprintf( __( '%s for %d months.', 'invoicing' ), $amount, $interval );
365
+                        $description = wp_sprintf(__('%s for %d months.', 'invoicing'), $amount, $interval);
366 366
                     }
367 367
                 } else {
368
-                    $description = wp_sprintf( _n( '%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
368
+                    $description = wp_sprintf(_n('%s for one month.', '%s for each month, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
369 369
                 }
370 370
             } else {
371
-                $description = wp_sprintf( _n( '%s for each month.', '%s for each %d months.', $interval, 'invoicing' ), $amount, $interval );
371
+                $description = wp_sprintf(_n('%s for each month.', '%s for each %d months.', $interval, 'invoicing'), $amount, $interval);
372 372
             }
373 373
             break;
374 374
         case 'Y' :
375 375
         case 'year' :            
376
-            if ( (int)$bill_times > 0 ) {
377
-                if ( $interval > 1 ) {
378
-                    if ( $bill_times > 1 ) {
379
-                        $description = wp_sprintf( __( '%s for each %d years, for %d installments.', 'invoicing' ), $amount, $interval, $bill_times );
376
+            if ((int)$bill_times > 0) {
377
+                if ($interval > 1) {
378
+                    if ($bill_times > 1) {
379
+                        $description = wp_sprintf(__('%s for each %d years, for %d installments.', 'invoicing'), $amount, $interval, $bill_times);
380 380
                     } else {
381
-                        $description = wp_sprintf( __( '%s for %d years.', 'invoicing'), $amount, $interval );
381
+                        $description = wp_sprintf(__('%s for %d years.', 'invoicing'), $amount, $interval);
382 382
                     }
383 383
                 } else {
384
-                    $description = wp_sprintf( _n( '%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing' ), $amount, $bill_times );
384
+                    $description = wp_sprintf(_n('%s for one year.', '%s for each year, for %d installments.', $bill_times, 'invoicing'), $amount, $bill_times);
385 385
                 }
386 386
             } else {
387
-                $description = wp_sprintf( _n( '%s for each year.', '%s for each %d years.', $interval, 'invoicing' ), $amount, $interval );
387
+                $description = wp_sprintf(_n('%s for each year.', '%s for each %d years.', $interval, 'invoicing'), $amount, $interval);
388 388
             }
389 389
             break;
390 390
     }
391 391
 
392
-    return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
392
+    return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
393 393
 }
394 394
 
395
-function wpinv_subscription_payment_desc( $invoice ) {
396
-    if ( empty( $invoice ) ) {
395
+function wpinv_subscription_payment_desc($invoice) {
396
+    if (empty($invoice)) {
397 397
         return NULL;
398 398
     }
399 399
     
400 400
     $description = '';
401
-    if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) {
402
-        if ( $item->has_free_trial() ) {
401
+    if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) {
402
+        if ($item->has_free_trial()) {
403 403
             $trial_period = $item->get_trial_period();
404 404
             $trial_interval = $item->get_trial_interval();
405 405
         } else {
@@ -407,45 +407,45 @@  discard block
 block discarded – undo
407 407
             $trial_interval = 0;
408 408
         }
409 409
         
410
-        $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() );
410
+        $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency());
411 411
     }
412 412
     
413
-    return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice );
413
+    return apply_filters('wpinv_subscription_payment_desc', $description, $invoice);
414 414
 }
415 415
 
416
-function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) {
417
-    $initial_total      = wpinv_format_amount( $initial );
418
-    $recurring_total    = wpinv_format_amount( $recurring );
416
+function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') {
417
+    $initial_total      = wpinv_format_amount($initial);
418
+    $recurring_total    = wpinv_format_amount($recurring);
419 419
     
420
-    if ( $trial_interval > 0 && !empty( $trial_period ) ) {
420
+    if ($trial_interval > 0 && !empty($trial_period)) {
421 421
         // Free trial
422 422
     } else {
423
-        if ( $bill_times == 1 ) {
423
+        if ($bill_times == 1) {
424 424
             $recurring_total = $initial_total;
425
-        } else if ( $bill_times > 1 && $initial_total != $recurring_total ) {
425
+        } else if ($bill_times > 1 && $initial_total != $recurring_total) {
426 426
             $bill_times--;
427 427
         }
428 428
     }
429 429
     
430
-    $initial_amount     = wpinv_price( $initial_total, $currency );
431
-    $recurring_amount   = wpinv_price( $recurring_total, $currency );
430
+    $initial_amount     = wpinv_price($initial_total, $currency);
431
+    $recurring_amount   = wpinv_price($recurring_total, $currency);
432 432
     
433
-    $recurring          = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval );
433
+    $recurring          = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval);
434 434
         
435
-    if ( $initial_total != $recurring_total ) {
436
-        $initial        = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval );
435
+    if ($initial_total != $recurring_total) {
436
+        $initial        = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval);
437 437
         
438
-        $description    = wp_sprintf( __( '%s Then %s', 'invoicing' ), $initial, $recurring );
438
+        $description    = wp_sprintf(__('%s Then %s', 'invoicing'), $initial, $recurring);
439 439
     } else {
440 440
         $description    = $recurring;
441 441
     }
442 442
     
443
-    return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency );
443
+    return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency);
444 444
 }
445 445
 
446
-function wpinv_recurring_send_payment_failed( $invoice ) {
447
-    if ( !empty( $invoice->ID ) ) {
448
-        wpinv_failed_invoice_notification( $invoice->ID );
446
+function wpinv_recurring_send_payment_failed($invoice) {
447
+    if (!empty($invoice->ID)) {
448
+        wpinv_failed_invoice_notification($invoice->ID);
449 449
     }
450 450
 }
451
-add_action( 'wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1 );
452 451
\ No newline at end of file
452
+add_action('wpinv_recurring_payment_failed', 'wpinv_recurring_send_payment_failed', 10, 1);
453 453
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,22 +11,22 @@
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
     
16
-    if ( $wpi_version == WPINV_VERSION ) {
16
+    if ($wpi_version == WPINV_VERSION) {
17 17
         return;
18 18
     }
19 19
     
20
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
20
+    if (version_compare($wpi_version, '0.0.5', '<')) {
21 21
         wpinv_v005_upgrades();
22 22
     }
23 23
     
24
-    update_option( 'wpinv_version', WPINV_VERSION );
24
+    update_option('wpinv_version', WPINV_VERSION);
25 25
 }
26
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
26
+add_action('admin_init', 'wpinv_automatic_upgrade');
27 27
 
28 28
 function wpinv_v005_upgrades() {
29 29
     global $wpdb;
30 30
     
31
-    $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
31
+    $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  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
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,31 +33,31 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
48
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
55 55
         
56
-        if ( is_admin() ) {
57
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
58
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
56
+        if (is_admin()) {
57
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
58
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
59 59
         } else {
60
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
60
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
61 61
         }
62 62
         
63 63
         /**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
          *
68 68
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
69 69
          */
70
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
70
+        do_action_ref_array('wpinv_actions', array(&$this));
71 71
 
72
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
72
+        add_action('admin_init', array(&$this, 'activation_redirect'));
73 73
     }
74 74
     
75 75
     public function plugins_loaded() {
@@ -83,189 +83,189 @@  discard block
 block discarded – undo
83 83
      * @since 1.0
84 84
      */
85 85
     public function load_textdomain() {
86
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
86
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
87 87
         
88
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
89
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
88
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
89
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
90 90
         
91 91
         /**
92 92
          * Define language constants.
93 93
          */
94
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
94
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
95 95
     }
96 96
         
97 97
     public function includes() {
98 98
         global $wpinv_options;
99 99
         
100
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
100
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
101 101
         $wpinv_options = wpinv_get_settings();
102 102
         
103
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
104
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
126
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
127
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
103
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
104
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
126
+        if (!class_exists('Geodir_EUVat')) {
127
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
128 128
         }
129 129
         
130
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
131
-        if ( !empty( $gateways ) ) {
132
-            foreach ( $gateways as $gateway ) {
133
-                if ( $gateway == 'manual' ) {
130
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
131
+        if (!empty($gateways)) {
132
+            foreach ($gateways as $gateway) {
133
+                if ($gateway == 'manual') {
134 134
                     continue;
135 135
                 }
136 136
                 
137 137
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
138 138
                 
139
-                if ( file_exists( $gateway_file ) ) {
140
-                    require_once( $gateway_file );
139
+                if (file_exists($gateway_file)) {
140
+                    require_once($gateway_file);
141 141
                 }
142 142
             }
143 143
         }
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
145
-        
146
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
147
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
148
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
149
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
153
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
145
+        
146
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
147
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
148
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
149
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
155 155
             
156 156
         }
157 157
         
158 158
         // include css inliner
159
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
160
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
159
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
160
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
161 161
         }
162 162
         
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
164 164
     }
165 165
     
166 166
     public function init() {
167 167
     }
168 168
     
169 169
     public function admin_init() {
170
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
170
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
171 171
         }
172 172
         
173
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
173
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
174 174
     }
175 175
 
176 176
     public function activation_redirect() {
177 177
         // Bail if no activation redirect
178
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
178
+        if (!get_transient('_wpinv_activation_redirect')) {
179 179
             return;
180 180
         }
181 181
 
182 182
         // Delete the redirect transient
183
-        delete_transient( '_wpinv_activation_redirect' );
183
+        delete_transient('_wpinv_activation_redirect');
184 184
 
185 185
         // Bail if activating from network, or bulk
186
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
186
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
187 187
             return;
188 188
         }
189 189
 
190
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
190
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
191 191
         exit;
192 192
     }
193 193
     
194 194
     public function enqueue_scripts() {
195
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
195
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
196 196
         
197
-        wp_deregister_style( 'font-awesome' );
198
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
199
-        wp_enqueue_style( 'font-awesome' );
197
+        wp_deregister_style('font-awesome');
198
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
199
+        wp_enqueue_style('font-awesome');
200 200
         
201
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
202
-        wp_enqueue_style( 'wpinv_front_style' );
201
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
202
+        wp_enqueue_style('wpinv_front_style');
203 203
                
204 204
         // Register scripts
205
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
206
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
205
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
206
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
207 207
         
208 208
         $localize                         = array();
209
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
210
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
209
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
210
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
211 211
         $localize['currency_symbol']      = wpinv_currency_symbol();
212 212
         $localize['currency_pos']         = wpinv_currency_position();
213 213
         $localize['thousand_sep']         = wpinv_thousands_seperator();
214 214
         $localize['decimal_sep']          = wpinv_decimal_seperator();
215 215
         $localize['decimals']             = wpinv_decimals();
216 216
         
217
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
217
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
218 218
         
219
-        wp_enqueue_script( 'jquery-blockui' );
220
-        wp_enqueue_script( 'wpinv-front-script' );
221
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
219
+        wp_enqueue_script('jquery-blockui');
220
+        wp_enqueue_script('wpinv-front-script');
221
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
222 222
     }
223 223
     
224 224
     public function admin_enqueue_scripts() {
225 225
         global $post, $pagenow;
226 226
         
227 227
         $post_type  = wpinv_admin_post_type();
228
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
228
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
229 229
         
230
-        wp_deregister_style( 'font-awesome' );
231
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
232
-        wp_enqueue_style( 'font-awesome' );
230
+        wp_deregister_style('font-awesome');
231
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
232
+        wp_enqueue_style('font-awesome');
233 233
         
234
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
235
-        wp_enqueue_style( 'jquery-ui-css' );
234
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
235
+        wp_enqueue_style('jquery-ui-css');
236 236
         
237
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
238
-        wp_enqueue_style( 'jquery-chosen' );
237
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
238
+        wp_enqueue_style('jquery-chosen');
239 239
 
240
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
241
-        wp_enqueue_script( 'jquery-chosen' );
240
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
241
+        wp_enqueue_script('jquery-chosen');
242 242
         
243
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
244
-        wp_enqueue_style( 'wpinv_meta_box_style' );
243
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
244
+        wp_enqueue_style('wpinv_meta_box_style');
245 245
         
246
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
247
-        wp_enqueue_style( 'wpinv_admin_style' );
246
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
247
+        wp_enqueue_style('wpinv_admin_style');
248 248
         
249
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
250
-            wp_enqueue_script( 'jquery-ui-datepicker' );
249
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
250
+            wp_enqueue_script('jquery-ui-datepicker');
251 251
         }
252 252
 
253
-        wp_enqueue_style( 'wp-color-picker' );
254
-        wp_enqueue_script( 'wp-color-picker' );
253
+        wp_enqueue_style('wp-color-picker');
254
+        wp_enqueue_script('wp-color-picker');
255 255
         
256
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
256
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
257 257
         
258
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
259
-        wp_enqueue_script( 'wpinv-admin-script' );
258
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
259
+        wp_enqueue_script('wpinv-admin-script');
260 260
         
261 261
         $localize                               = array();
262
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
263
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
264
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
265
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
266
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
267
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
268
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
262
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
263
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
264
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
265
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
266
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
267
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
268
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
269 269
         $localize['tax']                        = wpinv_tax_amount();
270 270
         $localize['discount']                   = wpinv_discount_amount();
271 271
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -273,55 +273,55 @@  discard block
 block discarded – undo
273 273
         $localize['thousand_sep']               = wpinv_thousands_seperator();
274 274
         $localize['decimal_sep']                = wpinv_decimal_seperator();
275 275
         $localize['decimals']                   = wpinv_decimals();
276
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
277
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
278
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
279
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
280
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
281
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
282
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
283
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
284
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
285
-        $localize['hasGD']                      = wpinv_gd_active();;
276
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
277
+        $localize['status_publish']             = wpinv_status_nicename('publish');
278
+        $localize['status_pending']             = wpinv_status_nicename('pending');
279
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
280
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
281
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
282
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
283
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
284
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
285
+        $localize['hasGD']                      = wpinv_gd_active(); ;
286 286
         $localize['hasPM']                      = wpinv_pm_active();
287
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
288
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
289
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
290
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
287
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
288
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
289
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
290
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
291 291
         
292
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
292
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
293 293
     }
294 294
     
295
-    public function admin_body_class( $classes ) {
295
+    public function admin_body_class($classes) {
296 296
         global $pagenow;
297 297
         
298
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
298
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
299 299
 
300 300
         $add_class = false;
301
-        if ( $pagenow == 'admin.php' && $page ) {
302
-            $add_class = strpos( $page, 'wpinv-' );
301
+        if ($pagenow == 'admin.php' && $page) {
302
+            $add_class = strpos($page, 'wpinv-');
303 303
         }
304 304
         
305 305
         $settings_class = array();
306
-        if ( $page == 'wpinv-settings' ) {
307
-            if ( !empty( $_REQUEST['tab'] ) ) {
308
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
306
+        if ($page == 'wpinv-settings') {
307
+            if (!empty($_REQUEST['tab'])) {
308
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
309 309
             }
310 310
             
311
-            if ( !empty( $_REQUEST['section'] ) ) {
312
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
311
+            if (!empty($_REQUEST['section'])) {
312
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
313 313
             }
314 314
             
315
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
315
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
316 316
         }
317 317
         
318
-        if ( !empty( $settings_class ) ) {
319
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
318
+        if (!empty($settings_class)) {
319
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
320 320
         }
321 321
         
322 322
         $post_type = wpinv_admin_post_type();
323 323
         
324
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
324
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
325 325
             return $classes .= ' wpinv';
326 326
         } else {
327 327
             return $classes;
@@ -333,26 +333,26 @@  discard block
 block discarded – undo
333 333
     public function admin_print_scripts_edit_php() {
334 334
         $post_type = wpinv_admin_post_type();
335 335
         
336
-        if ( $post_type == 'wpi_item' ) {
337
-            wp_enqueue_script( 'wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
336
+        if ($post_type == 'wpi_item') {
337
+            wp_enqueue_script('wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array('jquery', 'inline-edit-post'), '', true);
338 338
         }
339 339
     }
340 340
     
341 341
     public function wpinv_actions() {
342
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
343
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
342
+        if (isset($_REQUEST['wpi_action'])) {
343
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
344 344
         }
345 345
     }
346 346
     
347
-    public function pre_get_posts( $wp_query ) {
348
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
349
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
347
+    public function pre_get_posts($wp_query) {
348
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
349
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
350 350
         }
351 351
         
352 352
         return $wp_query;
353 353
     }
354 354
     
355 355
     public function bp_invoicing_init() {
356
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
356
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
357 357
     }
358 358
 }
359 359
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -14,73 +14,73 @@  discard block
 block discarded – undo
14 14
     }
15 15
     
16 16
     public function init() {
17
-        do_action( 'wpinv_class_notes_init', $this );
17
+        do_action('wpinv_class_notes_init', $this);
18 18
     }
19 19
     
20 20
     public function includes() {
21
-        do_action( 'wpinv_class_notes_includes', $this );
21
+        do_action('wpinv_class_notes_includes', $this);
22 22
     }
23 23
     
24 24
     public function actions() {
25 25
         // Secure inovice notes
26
-        add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
26
+        add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
27 27
         
28 28
         // Count comments
29
-        add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 11, 2 );
29
+        add_filter('wp_count_comments', array($this, 'wp_count_comments'), 11, 2);
30 30
         
31 31
         // Delete comments count cache whenever there is a new comment or a comment status changes
32
-        add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) );
33
-        add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) );
32
+        add_action('wp_insert_comment', array($this, 'delete_comments_count_cache'));
33
+        add_action('wp_set_comment_status', array($this, 'delete_comments_count_cache'));
34 34
         
35
-        do_action( 'wpinv_class_notes_actions', $this );
35
+        do_action('wpinv_class_notes_actions', $this);
36 36
     }
37 37
         
38
-    public function set_invoice_note_type( $query ) {
39
-        $post_ID        = !empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
38
+    public function set_invoice_note_type($query) {
39
+        $post_ID = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
40 40
         
41
-        if ( $post_ID && get_post_type( $post_ID ) == $this->invoice_post_type ) {
41
+        if ($post_ID && get_post_type($post_ID) == $this->invoice_post_type) {
42 42
             $query->query_vars['type__in']      = $this->comment_type;
43 43
             $query->query_vars['type__not_in']  = '';
44 44
         } else {        
45
-            if ( isset( $query->query_vars['type__in'] ) && $type_in = $query->query_vars['type__in'] ) {
46
-                if ( is_array( $type_in ) && in_array( $this->comment_type, $type_in ) ) {
47
-                    $key = array_search( $this->comment_type, $type_in );
48
-                    unset( $query->query_vars['type__in'][$key] );
49
-                } else if ( !is_array( $type_in ) && $type_in == $this->comment_type ) {
45
+            if (isset($query->query_vars['type__in']) && $type_in = $query->query_vars['type__in']) {
46
+                if (is_array($type_in) && in_array($this->comment_type, $type_in)) {
47
+                    $key = array_search($this->comment_type, $type_in);
48
+                    unset($query->query_vars['type__in'][$key]);
49
+                } else if (!is_array($type_in) && $type_in == $this->comment_type) {
50 50
                     $query->query_vars['type__in'] = '';
51 51
                 }
52 52
             }
53 53
             
54
-            if ( isset( $query->query_vars['type__not_in'] ) && $type_not_in = $query->query_vars['type__not_in'] ) {
55
-                if ( is_array( $type_not_in ) && !in_array( $this->comment_type, $type_not_in ) ) {
54
+            if (isset($query->query_vars['type__not_in']) && $type_not_in = $query->query_vars['type__not_in']) {
55
+                if (is_array($type_not_in) && !in_array($this->comment_type, $type_not_in)) {
56 56
                     $query->query_vars['type__not_in'][] = $this->comment_type;
57
-                } else if ( !is_array( $type_not_in ) && $type_not_in != $this->comment_type ) {
57
+                } else if (!is_array($type_not_in) && $type_not_in != $this->comment_type) {
58 58
                     $query->query_vars['type__not_in'] = (array)$query->query_vars['type__not_in'];
59 59
                     $query->query_vars['type__not_in'][] = $this->comment_type;
60 60
                 }
61 61
             } else {
62
-                $query->query_vars['type__not_in']  = $this->comment_type;
62
+                $query->query_vars['type__not_in'] = $this->comment_type;
63 63
             }
64 64
         }
65 65
         
66 66
         return $query;
67 67
     }
68 68
     
69
-    public function get_invoice_notes( $invoice_id = 0, $type = '' ) {
69
+    public function get_invoice_notes($invoice_id = 0, $type = '') {
70 70
         $args = array( 
71 71
             'post_id'   => $invoice_id,
72 72
             'order'     => 'comment_date_gmt',
73 73
             'order'     => 'DESC',
74 74
         );
75 75
         
76
-        if ( $type == 'customer' ) {
76
+        if ($type == 'customer') {
77 77
             $args['meta_key']   = '_wpi_customer_note';
78 78
             $args['meta_value'] = 1;
79 79
         }
80 80
         
81
-        $args   = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
81
+        $args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
82 82
         
83
-        return get_comments( $args );
83
+        return get_comments($args);
84 84
     }
85 85
     
86 86
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      * @return void
92 92
      */
93 93
     public function delete_comments_count_cache() {
94
-        delete_transient( 'wpinv_count_comments' );
94
+        delete_transient('wpinv_count_comments');
95 95
     }
96 96
     
97 97
     /**
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
      * @param  int    $post_id Post ID.
103 103
      * @return object
104 104
      */
105
-    public function wp_count_comments( $stats, $post_id ) {
105
+    public function wp_count_comments($stats, $post_id) {
106 106
         global $wpdb;
107 107
 
108
-        if ( 0 === $post_id ) {
109
-            $stats = get_transient( 'wpinv_count_comments' );
108
+        if (0 === $post_id) {
109
+            $stats = get_transient('wpinv_count_comments');
110 110
 
111
-            if ( ! $stats ) {
111
+            if (!$stats) {
112 112
                 $stats = array();
113 113
 
114
-                $count = $wpdb->get_results( "SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A );
114
+                $count = $wpdb->get_results("SELECT comment_approved, COUNT(*) AS num_comments FROM {$wpdb->comments} WHERE comment_type NOT IN ('" . $this->comment_type . "') GROUP BY comment_approved", ARRAY_A);
115 115
 
116 116
                 $total = 0;
117 117
                 $approved = array(
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
                     'post-trashed' => 'post-trashed',
123 123
                 );
124 124
 
125
-                foreach ( (array) $count as $row ) {
125
+                foreach ((array)$count as $row) {
126 126
                     // Do not count post-trashed toward totals.
127
-                    if ( 'post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved'] ) {
127
+                    if ('post-trashed' !== $row['comment_approved'] && 'trash' !== $row['comment_approved']) {
128 128
                         $total += $row['num_comments'];
129 129
                     }
130
-                    if ( isset( $approved[ $row['comment_approved'] ] ) ) {
131
-                        $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
130
+                    if (isset($approved[$row['comment_approved']])) {
131
+                        $stats[$approved[$row['comment_approved']]] = $row['num_comments'];
132 132
                     }
133 133
                 }
134 134
 
135 135
                 $stats['total_comments'] = $total;
136 136
                 $stats['all'] = $total;
137
-                foreach ( $approved as $key ) {
138
-                    if ( empty( $stats[ $key ] ) ) {
139
-                        $stats[ $key ] = 0;
137
+                foreach ($approved as $key) {
138
+                    if (empty($stats[$key])) {
139
+                        $stats[$key] = 0;
140 140
                     }
141 141
                 }
142 142
 
143
-                $stats = (object) $stats;
144
-                set_transient( 'wpinv_count_comments', $stats );
143
+                $stats = (object)$stats;
144
+                set_transient('wpinv_count_comments', $stats);
145 145
             }
146 146
         }
147 147
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  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 7
 class WPInv_Meta_Box_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10 10
         $statuses           = wpinv_get_invoice_statuses();
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
27
-        $mail_notice = esc_attr__( 'After save invoice this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27
+        $mail_notice = esc_attr__('After save invoice this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
28 28
         
29 29
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
30 30
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 <div class="gdmbx2-wrap form-table">
35 35
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
36 36
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
37
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
38
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
37
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
38
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
39 39
         </div>
40
-        <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?>
40
+        <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?>
41 41
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
42
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
42
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
43 43
             <div class="gdmbx-td">
44
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
44
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
45 45
             </div>
46 46
         </div>
47 47
         <?php } ?>
48
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
48
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
49 49
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
50
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
51
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
50
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
51
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
52 52
         </div>
53 53
         <?php } ?>
54 54
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
55 55
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
56 56
             <div class="gdmbx-td">
57 57
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select">
58
-                    <?php foreach ( $statuses as $value => $label ) { ?>
59
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
58
+                    <?php foreach ($statuses as $value => $label) { ?>
59
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
60 60
                     <?php } ?>
61 61
                 </select>
62 62
             </div>
@@ -64,107 +64,107 @@  discard block
 block discarded – undo
64 64
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
65 65
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
66 66
             <div class="gdmbx-td">
67
-                <input type="text" placeholder="<?php echo esc_attr( wpinv_format_invoice_number( 1 ) ); ?>" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text">
67
+                <input type="text" placeholder="<?php echo esc_attr(wpinv_format_invoice_number(1)); ?>" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text">
68 68
             </div>
69 69
         </div>
70
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?>
71
-        <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?>
70
+        <?php do_action('wpinv_meta_box_details_inner', $post_id); ?>
71
+        <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?>
72 72
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
73
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
73
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
74 74
             <div class="gdmbx-td">
75
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
75
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
76 76
             </div>
77 77
         </div>
78 78
         <?php } ?>
79 79
     </div>
80 80
 </div>
81 81
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
82
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
82
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
83 83
         <select id="wpi_save_send" name="wpi_save_send">
84
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
85
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
84
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
85
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
86 86
         </select>
87 87
     </p>
88 88
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
89 89
 </div>
90
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
90
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
91 91
         <?php
92 92
     }
93 93
     
94
-    public static function resend_invoice( $post ) {
94
+    public static function resend_invoice($post) {
95 95
         global $wpi_mb_invoice;
96 96
         
97
-        if ( empty( $wpi_mb_invoice ) ) {
97
+        if (empty($wpi_mb_invoice)) {
98 98
             return;
99 99
         }
100 100
         
101 101
         $text = array(
102
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
103
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
102
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
103
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
104 104
         );
105 105
             
106 106
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
107
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
107
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
108 108
         
109
-        if ( $email = $wpi_mb_invoice->get_email() ) {
109
+        if ($email = $wpi_mb_invoice->get_email()) {
110 110
             $email_actions = array();
111
-            $email_actions['email_url']      = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) );
112
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
111
+            $email_actions['email_url']      = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID));
112
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
113 113
             
114
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
114
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
115 115
         ?>
116 116
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
117
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
119
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
117
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
+        <?php if (wpinv_get_option('overdue_active') && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
119
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
120 120
         <?php } ?>
121 121
         <?php
122 122
         }
123 123
         
124
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
124
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
125 125
     }
126 126
     
127
-    public static function subscriptions( $post ) {
127
+    public static function subscriptions($post) {
128 128
         global $wpi_mb_invoice;
129 129
         
130 130
         $invoice = $wpi_mb_invoice;
131 131
         
132
-        if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
132
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
133 133
             $payments       = $invoice->get_child_payments();
134 134
             
135 135
             $total_payments = (int)$invoice->get_total_payments();
136 136
             $subscription   = $invoice->get_subscription_data();
137 137
 
138
-            $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
139
-            $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
138
+            $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
139
+            $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
140 140
             $subscription_status = $invoice->get_subscription_status();
141 141
             ?>
142
-            <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p>
143
-            <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?>
144
-            <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p>
142
+            <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p>
143
+            <?php if ($subscription_id = $invoice->get_subscription_id()) { ?>
144
+            <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p>
145 145
             <?php } ?>
146
-            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p>
147
-            <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p>
148
-            <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?>
149
-                <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
-                <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
-                <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?>
152
-                <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p>
146
+            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p>
147
+            <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p>
148
+            <?php if (!empty($payments) || $invoice->is_paid()) { ?>
149
+                <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
+                <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
+                <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?>
152
+                <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p>
153 153
                 <?php } ?>
154
-                <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?>
155
-                <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p>
154
+                <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?>
155
+                <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p>
156 156
                 <?php } ?>
157
-                <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?>
158
-                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p>
157
+                <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?>
158
+                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p>
159 159
                 <?php } ?>
160
-                <?php if ( !empty( $payments ) ) { ?>
161
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
160
+                <?php if (!empty($payments)) { ?>
161
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
162 162
                 <ul id="wpi-sub-payments">
163
-                <?php foreach ( $payments as $invoice_id ) { ?>
163
+                <?php foreach ($payments as $invoice_id) { ?>
164 164
                     <li>
165
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
166
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
167
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
165
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
166
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
167
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
168 168
                     </li>
169 169
                 <?php } ?>
170 170
                 </ul>
@@ -172,47 +172,47 @@  discard block
 block discarded – undo
172 172
         }
173 173
     }
174 174
     
175
-    public static function renewals( $post ) {
175
+    public static function renewals($post) {
176 176
         global $wpi_mb_invoice;
177 177
         
178
-        if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
179
-            $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice );
180
-            $parent_id  = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice );
178
+        if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
179
+            $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice);
180
+            $parent_id  = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice);
181 181
         ?>
182
-        <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
182
+        <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
184 184
         <?php
185 185
         }
186 186
     }
187 187
     
188
-    public static function payment_meta( $post ) {
188
+    public static function payment_meta($post) {
189 189
         global $wpi_mb_invoice;
190 190
 
191
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
192
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) {
191
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
192
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) {
193 193
             $set_dateway = true;
194 194
         }
195 195
         
196 196
         ?>
197 197
         <p class="wpi-meta-row">
198
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
199
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
198
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
199
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
200 200
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
201
-                <?php foreach ( $gateways as $name => $gateway ) {
202
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
201
+                <?php foreach ($gateways as $name => $gateway) {
202
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
203 203
                         continue;
204 204
                     }
205 205
                     ?>
206
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
206
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
207 207
                 <?php } ?>
208 208
             </select>
209 209
         <?php } else { 
210
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) );
210
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway));
211 211
         } ?>
212 212
         </p>
213
-        <?php if ( $wpi_mb_invoice->is_paid() ) { ?>
214
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p>
215
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
213
+        <?php if ($wpi_mb_invoice->is_paid()) { ?>
214
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p>
215
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
216 216
         <?php } ?>
217 217
         <?php
218 218
     }
Please login to merge, or discard this patch.