Passed
Pull Request — master (#37)
by Kiran
03:38
created
includes/wpinv-email-functions.php 1 patch
Spacing   +492 added lines, -492 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_pending_to_processing',
17 17
         'wpinv_status_pending_to_publish',
18 18
         'wpinv_status_pending_to_cancelled',
@@ -28,74 +28,74 @@  discard block
 block discarded – undo
28 28
         'wpinv_fully_refunded',
29 29
         'wpinv_partially_refunded',
30 30
         'wpinv_new_invoice_note'
31
-    ) );
31
+    ));
32 32
 
33
-    foreach ( $email_actions as $action ) {
34
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
33
+    foreach ($email_actions as $action) {
34
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
35 35
     }
36 36
 }
37
-add_action( 'init', 'wpinv_init_transactional_emails' );
37
+add_action('init', 'wpinv_init_transactional_emails');
38 38
 
39 39
 // New invoice email
40
-add_action( 'wpinv_status_pending_to_processing_notification', 'wpinv_new_invoice_notification' );
41
-add_action( 'wpinv_status_pending_to_publish_notification', 'wpinv_new_invoice_notification' );
42
-add_action( 'wpinv_status_pending_to_onhold_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_failed_to_processing_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_failed_to_publish_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_failed_to_onhold_notification', 'wpinv_new_invoice_notification' );
40
+add_action('wpinv_status_pending_to_processing_notification', 'wpinv_new_invoice_notification');
41
+add_action('wpinv_status_pending_to_publish_notification', 'wpinv_new_invoice_notification');
42
+add_action('wpinv_status_pending_to_onhold_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_failed_to_processing_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_failed_to_publish_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_failed_to_onhold_notification', 'wpinv_new_invoice_notification');
46 46
 
47 47
 // Cancelled invoice email
48
-add_action( 'wpinv_status_pending_to_cancelled_notification', 'wpinv_cancelled_invoice_notification' );
49
-add_action( 'wpinv_status_onhold_to_cancelled_notification', 'wpinv_cancelled_invoice_notification' );
48
+add_action('wpinv_status_pending_to_cancelled_notification', 'wpinv_cancelled_invoice_notification');
49
+add_action('wpinv_status_onhold_to_cancelled_notification', 'wpinv_cancelled_invoice_notification');
50 50
 
51 51
 // Failed invoice email
52
-add_action( 'wpinv_status_pending_to_failed_notification', 'wpinv_failed_invoice_notification' );
53
-add_action( 'wpinv_status_onhold_to_failed_notification', 'wpinv_failed_invoice_notification' );
52
+add_action('wpinv_status_pending_to_failed_notification', 'wpinv_failed_invoice_notification');
53
+add_action('wpinv_status_onhold_to_failed_notification', 'wpinv_failed_invoice_notification');
54 54
 
55 55
 // On hold invoice email
56
-add_action( 'wpinv_status_pending_to_onhold_notification', 'wpinv_onhold_invoice_notification' );
57
-add_action( 'wpinv_status_failed_to_onhold_notification', 'wpinv_onhold_invoice_notification' );
56
+add_action('wpinv_status_pending_to_onhold_notification', 'wpinv_onhold_invoice_notification');
57
+add_action('wpinv_status_failed_to_onhold_notification', 'wpinv_onhold_invoice_notification');
58 58
 
59 59
 // Processing invoice email
60
-add_action( 'wpinv_status_pending_to_processing_notification', 'wpinv_processing_invoice_notification' );
60
+add_action('wpinv_status_pending_to_processing_notification', 'wpinv_processing_invoice_notification');
61 61
 
62 62
 // Paid invoice email
63
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
63
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
64 64
 
65 65
 // Refunded invoice email
66
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
67
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
66
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
67
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
68 68
 
69 69
 // Invoice note
70
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
70
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
71 71
 
72
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
73
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
74
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
75
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
76
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
72
+add_action('wpinv_email_header', 'wpinv_email_header');
73
+add_action('wpinv_email_footer', 'wpinv_email_footer');
74
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
75
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
76
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
77 77
 
78 78
 function wpinv_send_transactional_email() {
79 79
     $args       = func_get_args();
80 80
     $function   = current_filter() . '_notification';
81
-    do_action_ref_array( $function, $args );
81
+    do_action_ref_array($function, $args);
82 82
 }
83 83
     
84
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
84
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
85 85
     global $wpinv_email_search, $wpinv_email_replace;
86 86
     
87 87
     $email_type = 'new_invoice';
88
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
88
+    if (!wpinv_email_is_enabled($email_type)) {
89 89
         return false;
90 90
     }
91 91
     
92
-    $invoice = wpinv_get_invoice( $invoice_id );
93
-    if ( empty( $invoice ) ) {
92
+    $invoice = wpinv_get_invoice($invoice_id);
93
+    if (empty($invoice)) {
94 94
         return false;
95 95
     }
96 96
     
97
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
98
-    if ( !is_email( $recipient ) ) {
97
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
98
+    if (!is_email($recipient)) {
99 99
         return false;
100 100
     }
101 101
         
@@ -112,37 +112,37 @@  discard block
 block discarded – undo
112 112
     $wpinv_email_search     = $search;
113 113
     $wpinv_email_replace    = $replace;
114 114
     
115
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
116
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
117
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
118
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
115
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
116
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
117
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
118
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
119 119
     
120
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
120
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
121 121
             'invoice'       => $invoice,
122 122
             'email_type'    => $email_type,
123 123
             'email_heading' => $email_heading,
124 124
             'sent_to_admin' => true,
125 125
             'plain_text'    => false,
126
-        ) );
126
+        ));
127 127
     
128
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
128
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
129 129
 }
130 130
 
131
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
131
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
132 132
     global $wpinv_email_search, $wpinv_email_replace;
133 133
     
134 134
     $email_type = 'cancelled_invoice';
135
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
135
+    if (!wpinv_email_is_enabled($email_type)) {
136 136
         return false;
137 137
     }
138 138
     
139
-    $invoice = wpinv_get_invoice( $invoice_id );
140
-    if ( empty( $invoice ) ) {
139
+    $invoice = wpinv_get_invoice($invoice_id);
140
+    if (empty($invoice)) {
141 141
         return false;
142 142
     }
143 143
     
144
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
145
-    if ( !is_email( $recipient ) ) {
144
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
145
+    if (!is_email($recipient)) {
146 146
         return false;
147 147
     }
148 148
         
@@ -159,37 +159,37 @@  discard block
 block discarded – undo
159 159
     $wpinv_email_search     = $search;
160 160
     $wpinv_email_replace    = $replace;
161 161
     
162
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
163
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
164
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
165
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
162
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
163
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
164
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
165
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
166 166
     
167
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
167
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
168 168
             'invoice'       => $invoice,
169 169
             'email_type'    => $email_type,
170 170
             'email_heading' => $email_heading,
171 171
             'sent_to_admin' => true,
172 172
             'plain_text'    => false,
173
-        ) );
173
+        ));
174 174
     
175
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
175
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
176 176
 }
177 177
 
178
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
178
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
179 179
     global $wpinv_email_search, $wpinv_email_replace;
180 180
     
181 181
     $email_type = 'failed_invoice';
182
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
182
+    if (!wpinv_email_is_enabled($email_type)) {
183 183
         return false;
184 184
     }
185 185
     
186
-    $invoice = wpinv_get_invoice( $invoice_id );
187
-    if ( empty( $invoice ) ) {
186
+    $invoice = wpinv_get_invoice($invoice_id);
187
+    if (empty($invoice)) {
188 188
         return false;
189 189
     }
190 190
     
191
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
192
-    if ( !is_email( $recipient ) ) {
191
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
192
+    if (!is_email($recipient)) {
193 193
         return false;
194 194
     }
195 195
         
@@ -206,37 +206,37 @@  discard block
 block discarded – undo
206 206
     $wpinv_email_search     = $search;
207 207
     $wpinv_email_replace    = $replace;
208 208
     
209
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
210
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
211
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
212
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
209
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
210
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
211
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
212
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
213 213
     
214
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
214
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
215 215
             'invoice'       => $invoice,
216 216
             'email_type'    => $email_type,
217 217
             'email_heading' => $email_heading,
218 218
             'sent_to_admin' => true,
219 219
             'plain_text'    => false,
220
-        ) );
220
+        ));
221 221
     
222
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
222
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
223 223
 }
224 224
 
225
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
225
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
226 226
     global $wpinv_email_search, $wpinv_email_replace;
227 227
     
228 228
     $email_type = 'onhold_invoice';
229
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
229
+    if (!wpinv_email_is_enabled($email_type)) {
230 230
         return false;
231 231
     }
232 232
     
233
-    $invoice = wpinv_get_invoice( $invoice_id );
234
-    if ( empty( $invoice ) ) {
233
+    $invoice = wpinv_get_invoice($invoice_id);
234
+    if (empty($invoice)) {
235 235
         return false;
236 236
     }
237 237
     
238
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
239
-    if ( !is_email( $recipient ) ) {
238
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
239
+    if (!is_email($recipient)) {
240 240
         return false;
241 241
     }
242 242
         
@@ -253,45 +253,45 @@  discard block
 block discarded – undo
253 253
     $wpinv_email_search     = $search;
254 254
     $wpinv_email_replace    = $replace;
255 255
     
256
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
257
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
258
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
259
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
256
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
257
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
258
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
259
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
260 260
     
261
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
261
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
262 262
             'invoice'       => $invoice,
263 263
             'email_type'    => $email_type,
264 264
             'email_heading' => $email_heading,
265 265
             'sent_to_admin' => false,
266 266
             'plain_text'    => false,
267
-        ) );
267
+        ));
268 268
     
269
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
269
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
270 270
     
271
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
272
-        $recipient  = wpinv_get_admin_email();
273
-        $subject    .= ' - ADMIN BCC COPY';
274
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
271
+    if (wpinv_mail_admin_bcc_active($email_type)) {
272
+        $recipient = wpinv_get_admin_email();
273
+        $subject .= ' - ADMIN BCC COPY';
274
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
275 275
     }
276 276
     
277 277
     return $sent;
278 278
 }
279 279
 
280
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
280
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
281 281
     global $wpinv_email_search, $wpinv_email_replace;
282 282
     
283 283
     $email_type = 'processing_invoice';
284
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
284
+    if (!wpinv_email_is_enabled($email_type)) {
285 285
         return false;
286 286
     }
287 287
     
288
-    $invoice = wpinv_get_invoice( $invoice_id );
289
-    if ( empty( $invoice ) ) {
288
+    $invoice = wpinv_get_invoice($invoice_id);
289
+    if (empty($invoice)) {
290 290
         return false;
291 291
     }
292 292
     
293
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
294
-    if ( !is_email( $recipient ) ) {
293
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
294
+    if (!is_email($recipient)) {
295 295
         return false;
296 296
     }
297 297
         
@@ -308,45 +308,45 @@  discard block
 block discarded – undo
308 308
     $wpinv_email_search     = $search;
309 309
     $wpinv_email_replace    = $replace;
310 310
     
311
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
312
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
313
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
314
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
311
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
312
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
313
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
314
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
315 315
     
316
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
316
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
317 317
             'invoice'       => $invoice,
318 318
             'email_type'    => $email_type,
319 319
             'email_heading' => $email_heading,
320 320
             'sent_to_admin' => false,
321 321
             'plain_text'    => false,
322
-        ) );
322
+        ));
323 323
     
324
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
324
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
325 325
     
326
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
327
-        $recipient  = wpinv_get_admin_email();
328
-        $subject    .= ' - ADMIN BCC COPY';
329
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
326
+    if (wpinv_mail_admin_bcc_active($email_type)) {
327
+        $recipient = wpinv_get_admin_email();
328
+        $subject .= ' - ADMIN BCC COPY';
329
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
330 330
     }
331 331
     
332 332
     return $sent;
333 333
 }
334 334
 
335
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
335
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
336 336
     global $wpinv_email_search, $wpinv_email_replace;
337 337
     
338 338
     $email_type = 'completed_invoice';
339
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
339
+    if (!wpinv_email_is_enabled($email_type)) {
340 340
         return false;
341 341
     }
342 342
     
343
-    $invoice = wpinv_get_invoice( $invoice_id );
344
-    if ( empty( $invoice ) ) {
343
+    $invoice = wpinv_get_invoice($invoice_id);
344
+    if (empty($invoice)) {
345 345
         return false;
346 346
     }
347 347
     
348
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
349
-    if ( !is_email( $recipient ) ) {
348
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
349
+    if (!is_email($recipient)) {
350 350
         return false;
351 351
     }
352 352
         
@@ -363,45 +363,45 @@  discard block
 block discarded – undo
363 363
     $wpinv_email_search     = $search;
364 364
     $wpinv_email_replace    = $replace;
365 365
     
366
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
367
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
368
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
369
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
366
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
367
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
368
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
369
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
370 370
     
371
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
371
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
372 372
             'invoice'       => $invoice,
373 373
             'email_type'    => $email_type,
374 374
             'email_heading' => $email_heading,
375 375
             'sent_to_admin' => false,
376 376
             'plain_text'    => false,
377
-        ) );
377
+        ));
378 378
     
379
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
379
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
380 380
     
381
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
382
-        $recipient  = wpinv_get_admin_email();
383
-        $subject    .= ' - ADMIN BCC COPY';
384
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
381
+    if (wpinv_mail_admin_bcc_active($email_type)) {
382
+        $recipient = wpinv_get_admin_email();
383
+        $subject .= ' - ADMIN BCC COPY';
384
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
385 385
     }
386 386
     
387 387
     return $sent;
388 388
 }
389 389
 
390
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
390
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
391 391
     global $wpinv_email_search, $wpinv_email_replace;
392 392
     
393 393
     $email_type = 'refunded_invoice';
394
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
394
+    if (!wpinv_email_is_enabled($email_type)) {
395 395
         return false;
396 396
     }
397 397
     
398
-    $invoice = wpinv_get_invoice( $invoice_id );
399
-    if ( empty( $invoice ) ) {
398
+    $invoice = wpinv_get_invoice($invoice_id);
399
+    if (empty($invoice)) {
400 400
         return false;
401 401
     }
402 402
     
403
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
404
-    if ( !is_email( $recipient ) ) {
403
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
404
+    if (!is_email($recipient)) {
405 405
         return false;
406 406
     }
407 407
         
@@ -418,46 +418,46 @@  discard block
 block discarded – undo
418 418
     $wpinv_email_search     = $search;
419 419
     $wpinv_email_replace    = $replace;
420 420
     
421
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
422
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
423
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
424
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
421
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
422
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
423
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
424
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
425 425
     
426
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
426
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
427 427
             'invoice'           => $invoice,
428 428
             'email_type'        => $email_type,
429 429
             'email_heading'     => $email_heading,
430 430
             'sent_to_admin'     => false,
431 431
             'plain_text'        => false,
432 432
             'partial_refund'    => false
433
-        ) );
433
+        ));
434 434
     
435
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
435
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
436 436
     
437
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
438
-        $recipient  = wpinv_get_admin_email();
439
-        $subject    .= ' - ADMIN BCC COPY';
440
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
437
+    if (wpinv_mail_admin_bcc_active($email_type)) {
438
+        $recipient = wpinv_get_admin_email();
439
+        $subject .= ' - ADMIN BCC COPY';
440
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
441 441
     }
442 442
     
443 443
     return $sent;
444 444
 }
445 445
 
446
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
446
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
447 447
     global $wpinv_email_search, $wpinv_email_replace;
448 448
     
449 449
     $email_type = 'refunded_invoice';
450
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
450
+    if (!wpinv_email_is_enabled($email_type)) {
451 451
         return false;
452 452
     }
453 453
     
454
-    $invoice = wpinv_get_invoice( $invoice_id );
455
-    if ( empty( $invoice ) ) {
454
+    $invoice = wpinv_get_invoice($invoice_id);
455
+    if (empty($invoice)) {
456 456
         return false;
457 457
     }
458 458
     
459
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
460
-    if ( !is_email( $recipient ) ) {
459
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
460
+    if (!is_email($recipient)) {
461 461
         return false;
462 462
     }
463 463
         
@@ -474,49 +474,49 @@  discard block
 block discarded – undo
474 474
     $wpinv_email_search     = $search;
475 475
     $wpinv_email_replace    = $replace;
476 476
     
477
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
478
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
479
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
480
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
477
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
478
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
479
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
480
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
481 481
     
482
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
482
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
483 483
             'invoice'           => $invoice,
484 484
             'email_type'        => $email_type,
485 485
             'email_heading'     => $email_heading,
486 486
             'sent_to_admin'     => false,
487 487
             'plain_text'        => false,
488 488
             'partial_refund'    => true
489
-        ) );
489
+        ));
490 490
     
491
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
491
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
492 492
     
493
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
494
-        $recipient  = wpinv_get_admin_email();
495
-        $subject    .= ' - ADMIN BCC COPY';
496
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
493
+    if (wpinv_mail_admin_bcc_active($email_type)) {
494
+        $recipient = wpinv_get_admin_email();
495
+        $subject .= ' - ADMIN BCC COPY';
496
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
497 497
     }
498 498
     
499 499
     return $sent;
500 500
 }
501 501
 
502
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
502
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
503 503
 }
504 504
 
505
-function wpinv_user_invoice_notification( $invoice_id ) {
505
+function wpinv_user_invoice_notification($invoice_id) {
506 506
     global $wpinv_email_search, $wpinv_email_replace;
507 507
     
508 508
     $email_type = 'user_invoice';
509
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
509
+    if (!wpinv_email_is_enabled($email_type)) {
510 510
         return false;
511 511
     }
512 512
     
513
-    $invoice = wpinv_get_invoice( $invoice_id );
514
-    if ( empty( $invoice ) ) {
513
+    $invoice = wpinv_get_invoice($invoice_id);
514
+    if (empty($invoice)) {
515 515
         return false;
516 516
     }
517 517
     
518
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
519
-    if ( !is_email( $recipient ) ) {
518
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
519
+    if (!is_email($recipient)) {
520 520
         return false;
521 521
     }
522 522
         
@@ -533,52 +533,52 @@  discard block
 block discarded – undo
533 533
     $wpinv_email_search     = $search;
534 534
     $wpinv_email_replace    = $replace;
535 535
     
536
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
537
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
538
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
539
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
536
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
537
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
538
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
539
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
540 540
     
541
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
541
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
542 542
             'invoice'       => $invoice,
543 543
             'email_type'    => $email_type,
544 544
             'email_heading' => $email_heading,
545 545
             'sent_to_admin' => false,
546 546
             'plain_text'    => false,
547
-        ) );
547
+        ));
548 548
     
549
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
549
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
550 550
     
551
-    if ( $sent ) {
552
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
551
+    if ($sent) {
552
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
553 553
     } else {
554
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
554
+        $note = __('Fail to send invoice to the user!', 'invoicing');
555 555
     }
556
-    $invoice->add_note( $note ); // Add private note.
556
+    $invoice->add_note($note); // Add private note.
557 557
     
558
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
559
-        $recipient  = wpinv_get_admin_email();
560
-        $subject    .= ' - ADMIN BCC COPY';
561
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
558
+    if (wpinv_mail_admin_bcc_active($email_type)) {
559
+        $recipient = wpinv_get_admin_email();
560
+        $subject .= ' - ADMIN BCC COPY';
561
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
562 562
     }
563 563
     
564 564
     return $sent;
565 565
 }
566 566
 
567
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
567
+function wpinv_user_note_notification($invoice_id, $args = array()) {
568 568
     global $wpinv_email_search, $wpinv_email_replace;
569 569
     
570 570
     $email_type = 'user_note';
571
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
571
+    if (!wpinv_email_is_enabled($email_type)) {
572 572
         return false;
573 573
     }
574 574
     
575
-    $invoice = wpinv_get_invoice( $invoice_id );
576
-    if ( empty( $invoice ) ) {
575
+    $invoice = wpinv_get_invoice($invoice_id);
576
+    if (empty($invoice)) {
577 577
         return false;
578 578
     }
579 579
     
580
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
581
-    if ( !is_email( $recipient ) ) {
580
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
581
+    if (!is_email($recipient)) {
582 582
         return false;
583 583
     }
584 584
     
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
         'user_note' => ''
587 587
     );
588 588
 
589
-    $args = wp_parse_args( $args, $defaults );
589
+    $args = wp_parse_args($args, $defaults);
590 590
         
591 591
     $search                     = array();
592 592
     $search['invoice_number']   = '{invoice_number}';
@@ -603,46 +603,46 @@  discard block
 block discarded – undo
603 603
     $wpinv_email_search     = $search;
604 604
     $wpinv_email_replace    = $replace;
605 605
     
606
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
607
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
608
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
609
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
606
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
607
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
608
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
609
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
610 610
     
611
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
611
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
612 612
             'invoice'       => $invoice,
613 613
             'email_type'    => $email_type,
614 614
             'email_heading' => $email_heading,
615 615
             'sent_to_admin' => false,
616 616
             'plain_text'    => false,
617 617
             'customer_note' => $args['user_note']
618
-        ) );
618
+        ));
619 619
         
620
-    $content        = wpinv_email_format_text( $content );
620
+    $content = wpinv_email_format_text($content);
621 621
     
622
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
622
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
623 623
         
624 624
     return $sent;
625 625
 }
626 626
 
627 627
 function wpinv_mail_get_from_address() {
628
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
629
-    return sanitize_email( $from_address );
628
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
629
+    return sanitize_email($from_address);
630 630
 }
631 631
 
632 632
 function wpinv_mail_get_from_name() {
633
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
634
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
633
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
634
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
635 635
 }
636 636
 
637
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
638
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
639
-    return ( $active ? true : false );
637
+function wpinv_mail_admin_bcc_active($mail_type = '') {
638
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
639
+    return ($active ? true : false);
640 640
 }
641 641
     
642
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
643
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
642
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
643
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
644 644
     
645
-    switch ( $email_type ) {
645
+    switch ($email_type) {
646 646
         case 'html' :
647 647
             $content_type = 'text/html';
648 648
             break;
@@ -657,35 +657,35 @@  discard block
 block discarded – undo
657 657
     return $content_type;
658 658
 }
659 659
     
660
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
661
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
662
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
663
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
660
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
661
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
662
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
663
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
664 664
 
665
-    $message = wpinv_email_style_body( $message );
666
-    $message = apply_filters( 'wpinv_mail_content', $message );
665
+    $message = wpinv_email_style_body($message);
666
+    $message = apply_filters('wpinv_mail_content', $message);
667 667
     
668
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
668
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
669 669
     
670
-    if ( !$sent ) {
671
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
672
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
670
+    if (!$sent) {
671
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
672
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
673 673
     }
674 674
 
675
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
676
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
677
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
675
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
676
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
677
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
678 678
 
679 679
     return $sent;
680 680
 }
681 681
     
682 682
 function wpinv_get_emails() {
683 683
     $overdue_days_options       = array();
684
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
685
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
684
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
685
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
686 686
     
687
-    for ( $i = 2; $i <= 10; $i++ ) {
688
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
687
+    for ($i = 2; $i <= 10; $i++) {
688
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
689 689
     }
690 690
 
691 691
 	// Default, built-in gateways
@@ -693,130 +693,130 @@  discard block
 block discarded – undo
693 693
 		'new_invoice' => array(
694 694
             'email_new_invoice_header' => array(
695 695
                 'id'   => 'email_new_invoice_header',
696
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
697
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
696
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
697
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
698 698
                 'type' => 'header',
699 699
             ),
700 700
             'email_new_invoice_active' => array(
701 701
                 'id'   => 'email_new_invoice_active',
702
-                'name' => __( 'Enable/Disable', 'invoicing' ),
703
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
702
+                'name' => __('Enable/Disable', 'invoicing'),
703
+                'desc' => __('Enable this email notification', 'invoicing'),
704 704
                 'type' => 'checkbox',
705 705
                 'std'  => 1
706 706
             ),
707 707
             'email_new_invoice_subject' => array(
708 708
                 'id'   => 'email_new_invoice_subject',
709
-                'name' => __( 'Subject', 'invoicing' ),
710
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
709
+                'name' => __('Subject', 'invoicing'),
710
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
711 711
                 'type' => 'text',
712
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
712
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
713 713
                 'size' => 'large'
714 714
             ),
715 715
             'email_new_invoice_heading' => array(
716 716
                 'id'   => 'email_new_invoice_heading',
717
-                'name' => __( 'Email Heading', 'invoicing' ),
718
-                'desc' => __( 'Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
717
+                'name' => __('Email Heading', 'invoicing'),
718
+                'desc' => __('Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
719 719
                 'type' => 'text',
720
-                'std'  => __( 'New payment invoice', 'invoicing' ),
720
+                'std'  => __('New payment invoice', 'invoicing'),
721 721
                 'size' => 'large'
722 722
             ),
723 723
         ),
724 724
         'cancelled_invoice' => array(
725 725
             'email_cancelled_invoice_header' => array(
726 726
                 'id'   => 'email_cancelled_invoice_header',
727
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
728
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
727
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
728
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
729 729
                 'type' => 'header',
730 730
             ),
731 731
             'email_cancelled_invoice_active' => array(
732 732
                 'id'   => 'email_cancelled_invoice_active',
733
-                'name' => __( 'Enable/Disable', 'invoicing' ),
734
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
733
+                'name' => __('Enable/Disable', 'invoicing'),
734
+                'desc' => __('Enable this email notification', 'invoicing'),
735 735
                 'type' => 'checkbox',
736 736
                 'std'  => 1
737 737
             ),
738 738
             'email_cancelled_invoice_subject' => array(
739 739
                 'id'   => 'email_cancelled_invoice_subject',
740
-                'name' => __( 'Subject', 'invoicing' ),
741
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
740
+                'name' => __('Subject', 'invoicing'),
741
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
742 742
                 'type' => 'text',
743
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
743
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
744 744
                 'size' => 'large'
745 745
             ),
746 746
             'email_cancelled_invoice_heading' => array(
747 747
                 'id'   => 'email_cancelled_invoice_heading',
748
-                'name' => __( 'Email Heading', 'invoicing' ),
749
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
748
+                'name' => __('Email Heading', 'invoicing'),
749
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
750 750
                 'type' => 'text',
751
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
751
+                'std'  => __('Cancelled invoice', 'invoicing'),
752 752
                 'size' => 'large'
753 753
             ),
754 754
         ),
755 755
         'failed_invoice' => array(
756 756
             'email_failed_invoice_header' => array(
757 757
                 'id'   => 'email_failed_invoice_header',
758
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
759
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
758
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
759
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
760 760
                 'type' => 'header',
761 761
             ),
762 762
             'email_failed_invoice_active' => array(
763 763
                 'id'   => 'email_failed_invoice_active',
764
-                'name' => __( 'Enable/Disable', 'invoicing' ),
765
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
764
+                'name' => __('Enable/Disable', 'invoicing'),
765
+                'desc' => __('Enable this email notification', 'invoicing'),
766 766
                 'type' => 'checkbox',
767 767
                 'std'  => 1
768 768
             ),
769 769
             'email_failed_invoice_subject' => array(
770 770
                 'id'   => 'email_failed_invoice_subject',
771
-                'name' => __( 'Subject', 'invoicing' ),
772
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
771
+                'name' => __('Subject', 'invoicing'),
772
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
773 773
                 'type' => 'text',
774
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
774
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
775 775
                 'size' => 'large'
776 776
             ),
777 777
             'email_failed_invoice_heading' => array(
778 778
                 'id'   => 'email_failed_invoice_heading',
779
-                'name' => __( 'Email Heading', 'invoicing' ),
780
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
779
+                'name' => __('Email Heading', 'invoicing'),
780
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
781 781
                 'type' => 'text',
782
-                'std'  => __( 'Failed invoice', 'invoicing' ),
782
+                'std'  => __('Failed invoice', 'invoicing'),
783 783
                 'size' => 'large'
784 784
             )
785 785
         ),
786 786
         'onhold_invoice' => array(
787 787
             'email_onhold_invoice_header' => array(
788 788
                 'id'   => 'email_onhold_invoice_header',
789
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
790
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
789
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
790
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
791 791
                 'type' => 'header',
792 792
             ),
793 793
             'email_onhold_invoice_active' => array(
794 794
                 'id'   => 'email_onhold_invoice_active',
795
-                'name' => __( 'Enable/Disable', 'invoicing' ),
796
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
795
+                'name' => __('Enable/Disable', 'invoicing'),
796
+                'desc' => __('Enable this email notification', 'invoicing'),
797 797
                 'type' => 'checkbox',
798 798
                 'std'  => 1
799 799
             ),
800 800
             'email_onhold_invoice_subject' => array(
801 801
                 'id'   => 'email_onhold_invoice_subject',
802
-                'name' => __( 'Subject', 'invoicing' ),
803
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
802
+                'name' => __('Subject', 'invoicing'),
803
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
804 804
                 'type' => 'text',
805
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
805
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
806 806
                 'size' => 'large'
807 807
             ),
808 808
             'email_onhold_invoice_heading' => array(
809 809
                 'id'   => 'email_onhold_invoice_heading',
810
-                'name' => __( 'Email Heading', 'invoicing' ),
811
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
810
+                'name' => __('Email Heading', 'invoicing'),
811
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
812 812
                 'type' => 'text',
813
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
813
+                'std'  => __('Thank you for your invoice', 'invoicing'),
814 814
                 'size' => 'large'
815 815
             ),
816 816
             'email_onhold_invoice_admin_bcc' => array(
817 817
                 'id'   => 'email_onhold_invoice_admin_bcc',
818
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
819
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
818
+                'name' => __('Enable Admin BCC', 'invoicing'),
819
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
820 820
                 'type' => 'checkbox',
821 821
                 'std'  => 1
822 822
             ),
@@ -824,37 +824,37 @@  discard block
 block discarded – undo
824 824
         'processing_invoice' => array(
825 825
             'email_processing_invoice_header' => array(
826 826
                 'id'   => 'email_processing_invoice_header',
827
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
828
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
827
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
828
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
829 829
                 'type' => 'header',
830 830
             ),
831 831
             'email_processing_invoice_active' => array(
832 832
                 'id'   => 'email_processing_invoice_active',
833
-                'name' => __( 'Enable/Disable', 'invoicing' ),
834
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
833
+                'name' => __('Enable/Disable', 'invoicing'),
834
+                'desc' => __('Enable this email notification', 'invoicing'),
835 835
                 'type' => 'checkbox',
836 836
                 'std'  => 1
837 837
             ),
838 838
             'email_processing_invoice_subject' => array(
839 839
                 'id'   => 'email_processing_invoice_subject',
840
-                'name' => __( 'Subject', 'invoicing' ),
841
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
840
+                'name' => __('Subject', 'invoicing'),
841
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
842 842
                 'type' => 'text',
843
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
843
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
844 844
                 'size' => 'large'
845 845
             ),
846 846
             'email_processing_invoice_heading' => array(
847 847
                 'id'   => 'email_processing_invoice_heading',
848
-                'name' => __( 'Email Heading', 'invoicing' ),
849
-                'desc' => __( 'Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
848
+                'name' => __('Email Heading', 'invoicing'),
849
+                'desc' => __('Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
850 850
                 'type' => 'text',
851
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
851
+                'std'  => __('Thank you for your invoice', 'invoicing'),
852 852
                 'size' => 'large'
853 853
             ),
854 854
             'email_processing_invoice_admin_bcc' => array(
855 855
                 'id'   => 'email_processing_invoice_admin_bcc',
856
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
857
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
856
+                'name' => __('Enable Admin BCC', 'invoicing'),
857
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
858 858
                 'type' => 'checkbox',
859 859
                 'std'  => 1
860 860
             ),
@@ -862,37 +862,37 @@  discard block
 block discarded – undo
862 862
         'completed_invoice' => array(
863 863
             'email_completed_invoice_header' => array(
864 864
                 'id'   => 'email_completed_invoice_header',
865
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
866
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
865
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
866
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
867 867
                 'type' => 'header',
868 868
             ),
869 869
             'email_completed_invoice_active' => array(
870 870
                 'id'   => 'email_completed_invoice_active',
871
-                'name' => __( 'Enable/Disable', 'invoicing' ),
872
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
871
+                'name' => __('Enable/Disable', 'invoicing'),
872
+                'desc' => __('Enable this email notification', 'invoicing'),
873 873
                 'type' => 'checkbox',
874 874
                 'std'  => 1
875 875
             ),
876 876
             'email_completed_invoice_subject' => array(
877 877
                 'id'   => 'email_completed_invoice_subject',
878
-                'name' => __( 'Subject', 'invoicing' ),
879
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
878
+                'name' => __('Subject', 'invoicing'),
879
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
880 880
                 'type' => 'text',
881
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
881
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
882 882
                 'size' => 'large'
883 883
             ),
884 884
             'email_completed_invoice_heading' => array(
885 885
                 'id'   => 'email_completed_invoice_heading',
886
-                'name' => __( 'Email Heading', 'invoicing' ),
887
-                'desc' => __( 'Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
886
+                'name' => __('Email Heading', 'invoicing'),
887
+                'desc' => __('Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
888 888
                 'type' => 'text',
889
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
889
+                'std'  => __('Your invoice has been paid', 'invoicing'),
890 890
                 'size' => 'large'
891 891
             ),
892 892
             'email_completed_invoice_admin_bcc' => array(
893 893
                 'id'   => 'email_completed_invoice_admin_bcc',
894
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
895
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
894
+                'name' => __('Enable Admin BCC', 'invoicing'),
895
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
896 896
                 'type' => 'checkbox',
897 897
             ),
898 898
             'std'  => 1
@@ -900,37 +900,37 @@  discard block
 block discarded – undo
900 900
         'refunded_invoice' => array(
901 901
             'email_refunded_invoice_header' => array(
902 902
                 'id'   => 'email_refunded_invoice_header',
903
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
904
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
903
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
904
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
905 905
                 'type' => 'header',
906 906
             ),
907 907
             'email_refunded_invoice_active' => array(
908 908
                 'id'   => 'email_refunded_invoice_active',
909
-                'name' => __( 'Enable/Disable', 'invoicing' ),
910
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
909
+                'name' => __('Enable/Disable', 'invoicing'),
910
+                'desc' => __('Enable this email notification', 'invoicing'),
911 911
                 'type' => 'checkbox',
912 912
                 'std'  => 1
913 913
             ),
914 914
             'email_refunded_invoice_subject' => array(
915 915
                 'id'   => 'email_refunded_invoice_subject',
916
-                'name' => __( 'Subject', 'invoicing' ),
917
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
916
+                'name' => __('Subject', 'invoicing'),
917
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
918 918
                 'type' => 'text',
919
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
919
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
920 920
                 'size' => 'large'
921 921
             ),
922 922
             'email_refunded_invoice_heading' => array(
923 923
                 'id'   => 'email_refunded_invoice_heading',
924
-                'name' => __( 'Email Heading', 'invoicing' ),
925
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
924
+                'name' => __('Email Heading', 'invoicing'),
925
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
926 926
                 'type' => 'text',
927
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
927
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
928 928
                 'size' => 'large'
929 929
             ),
930 930
             'email_refunded_invoice_admin_bcc' => array(
931 931
                 'id'   => 'email_refunded_invoice_admin_bcc',
932
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
933
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
932
+                'name' => __('Enable Admin BCC', 'invoicing'),
933
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
934 934
                 'type' => 'checkbox',
935 935
                 'std'  => 1
936 936
             ),
@@ -938,37 +938,37 @@  discard block
 block discarded – undo
938 938
         'user_invoice' => array(
939 939
             'email_user_invoice_header' => array(
940 940
                 'id'   => 'email_user_invoice_header',
941
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
942
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
941
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
942
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
943 943
                 'type' => 'header',
944 944
             ),
945 945
             'email_user_invoice_active' => array(
946 946
                 'id'   => 'email_user_invoice_active',
947
-                'name' => __( 'Enable/Disable', 'invoicing' ),
948
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
947
+                'name' => __('Enable/Disable', 'invoicing'),
948
+                'desc' => __('Enable this email notification', 'invoicing'),
949 949
                 'type' => 'checkbox',
950 950
                 'std'  => 1
951 951
             ),
952 952
             'email_user_invoice_subject' => array(
953 953
                 'id'   => 'email_user_invoice_subject',
954
-                'name' => __( 'Subject', 'invoicing' ),
955
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
954
+                'name' => __('Subject', 'invoicing'),
955
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
956 956
                 'type' => 'text',
957
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
957
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
958 958
                 'size' => 'large'
959 959
             ),
960 960
             'email_user_invoice_heading' => array(
961 961
                 'id'   => 'email_user_invoice_heading',
962
-                'name' => __( 'Email Heading', 'invoicing' ),
963
-                'desc' => __( 'Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
962
+                'name' => __('Email Heading', 'invoicing'),
963
+                'desc' => __('Enter the the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
964 964
                 'type' => 'text',
965
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
965
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
966 966
                 'size' => 'large'
967 967
             ),
968 968
             'email_user_invoice_admin_bcc' => array(
969 969
                 'id'   => 'email_user_invoice_admin_bcc',
970
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
971
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
970
+                'name' => __('Enable Admin BCC', 'invoicing'),
971
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
972 972
                 'type' => 'checkbox',
973 973
                 'std'  => 1
974 974
             ),
@@ -976,177 +976,177 @@  discard block
 block discarded – undo
976 976
         'user_note' => array(
977 977
             'email_user_note_header' => array(
978 978
                 'id'   => 'email_user_note_header',
979
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
980
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice.', 'invoicing' ),
979
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
980
+                'desc' => __('Customer note emails are sent when you add a note to an invoice.', 'invoicing'),
981 981
                 'type' => 'header',
982 982
             ),
983 983
             'email_user_note_active' => array(
984 984
                 'id'   => 'email_user_note_active',
985
-                'name' => __( 'Enable/Disable', 'invoicing' ),
986
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
985
+                'name' => __('Enable/Disable', 'invoicing'),
986
+                'desc' => __('Enable this email notification', 'invoicing'),
987 987
                 'type' => 'checkbox',
988 988
                 'std'  => 1
989 989
             ),
990 990
             'email_user_note_subject' => array(
991 991
                 'id'   => 'email_user_note_subject',
992
-                'name' => __( 'Subject', 'invoicing' ),
993
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
992
+                'name' => __('Subject', 'invoicing'),
993
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
994 994
                 'type' => 'text',
995
-                'std'  => __( '[{site_title}] Note added to your invoice #{invoice_number} from {invoice_date}', 'invoicing' ),
995
+                'std'  => __('[{site_title}] Note added to your invoice #{invoice_number} from {invoice_date}', 'invoicing'),
996 996
                 'size' => 'large'
997 997
             ),
998 998
             'email_user_note_heading' => array(
999 999
                 'id'   => 'email_user_note_heading',
1000
-                'name' => __( 'Email Heading', 'invoicing' ),
1001
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
1000
+                'name' => __('Email Heading', 'invoicing'),
1001
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
1002 1002
                 'type' => 'text',
1003
-                'std'  => __( 'A note has been added to your invoice', 'invoicing' ),
1003
+                'std'  => __('A note has been added to your invoice', 'invoicing'),
1004 1004
                 'size' => 'large'
1005 1005
             ),
1006 1006
         ),
1007 1007
         'overdue' => array(
1008 1008
             'email_overdue_header' => array(
1009 1009
                 'id'   => 'email_overdue_header',
1010
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1011
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1010
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1011
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1012 1012
                 'type' => 'header',
1013 1013
             ),
1014 1014
             'email_overdue_active' => array(
1015 1015
                 'id'   => 'email_overdue_active',
1016
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1017
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1016
+                'name' => __('Enable/Disable', 'invoicing'),
1017
+                'desc' => __('Enable this email notification', 'invoicing'),
1018 1018
                 'type' => 'checkbox',
1019 1019
                 'std'  => 1
1020 1020
             ),
1021 1021
             'email_due_reminder_days' => array(
1022 1022
                 'id'        => 'email_due_reminder_days',
1023
-                'name'      => __( 'When to Send', 'sliced-invoices' ),
1024
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1023
+                'name'      => __('When to Send', 'sliced-invoices'),
1024
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1025 1025
                 'default'   => '',
1026 1026
                 'type'      => 'multicheck',
1027 1027
                 'options'   => $overdue_days_options,
1028 1028
             ),
1029 1029
             'email_overdue_subject' => array(
1030 1030
                 'id'   => 'email_overdue_subject',
1031
-                'name' => __( 'Subject', 'invoicing' ),
1032
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1031
+                'name' => __('Subject', 'invoicing'),
1032
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1033 1033
                 'type' => 'text',
1034
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1034
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1035 1035
                 'size' => 'large'
1036 1036
             ),
1037 1037
             'email_overdue_heading' => array(
1038 1038
                 'id'   => 'email_overdue_heading',
1039
-                'name' => __( 'Email Heading', 'invoicing' ),
1040
-                'desc' => __( 'Enter the the main heading contained within the email notification.', 'invoicing' ),
1039
+                'name' => __('Email Heading', 'invoicing'),
1040
+                'desc' => __('Enter the the main heading contained within the email notification.', 'invoicing'),
1041 1041
                 'type' => 'text',
1042
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1042
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1043 1043
                 'size' => 'large'
1044 1044
             ),
1045 1045
             'email_overdue_body' => array(
1046 1046
                 'id'   => 'email_overdue_body',
1047
-                'name' => __( 'Email Content', 'invoicing' ),
1048
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1047
+                'name' => __('Email Content', 'invoicing'),
1048
+                'desc' => __('The content of the email.', 'invoicing'),
1049 1049
                 'type' => 'rich_editor',
1050
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing' ),
1050
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing'),
1051 1051
                 'class' => 'large',
1052 1052
                 'size'  => 10,
1053 1053
             ),
1054 1054
         ),
1055 1055
     );
1056 1056
 
1057
-    return apply_filters( 'wpinv_get_emails', $emails );
1057
+    return apply_filters('wpinv_get_emails', $emails);
1058 1058
 }
1059 1059
 
1060
-function wpinv_settings_emails( $settings = array() ) {
1060
+function wpinv_settings_emails($settings = array()) {
1061 1061
     $emails = wpinv_get_emails();
1062 1062
     
1063
-    if ( !empty( $emails ) ) {
1064
-        foreach ( $emails as $key => $email ) {
1063
+    if (!empty($emails)) {
1064
+        foreach ($emails as $key => $email) {
1065 1065
             $settings[$key] = $email;
1066 1066
         }
1067 1067
     }
1068 1068
     
1069
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1069
+    return apply_filters('wpinv_settings_get_emails', $settings);
1070 1070
 }
1071
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1071
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1072 1072
 
1073
-function wpinv_settings_sections_emails( $settings ) {
1073
+function wpinv_settings_sections_emails($settings) {
1074 1074
     $emails = wpinv_get_emails();
1075 1075
     
1076 1076
     if (!empty($emails)) {
1077
-        foreach  ($emails as $key => $email) {
1078
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1077
+        foreach ($emails as $key => $email) {
1078
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1079 1079
         }
1080 1080
     }
1081 1081
     
1082 1082
     return $settings;    
1083 1083
 }
1084
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1084
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1085 1085
 
1086
-function wpinv_email_is_enabled( $email_type ) {
1086
+function wpinv_email_is_enabled($email_type) {
1087 1087
     $emails = wpinv_get_emails();
1088
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( $email_type . '_active', 1 ) ? true : false;
1088
+    $enabled = isset($emails[$email_type]) && wpinv_get_option($email_type . '_active', 1) ? true : false;
1089 1089
 
1090
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1090
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1091 1091
 }
1092 1092
 
1093
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1094
-    switch ( $email_type ) {
1093
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1094
+    switch ($email_type) {
1095 1095
         case 'new_invoice':
1096 1096
         case 'cancelled_invoice':
1097 1097
         case 'failed_invoice':
1098 1098
             $recipient  = wpinv_get_admin_email();
1099 1099
         break;
1100 1100
         default:
1101
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1102
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1101
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1102
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1103 1103
         break;
1104 1104
     }
1105 1105
     
1106
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1106
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1107 1107
 }
1108 1108
 
1109
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1110
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1109
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1110
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1111 1111
     
1112
-    $subject    = wpinv_email_format_text( $subject );
1112
+    $subject    = wpinv_email_format_text($subject);
1113 1113
     
1114
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1114
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1115 1115
 }
1116 1116
 
1117
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1118
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1117
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1118
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1119 1119
     
1120
-    $email_heading = wpinv_email_format_text( $email_heading );
1120
+    $email_heading = wpinv_email_format_text($email_heading);
1121 1121
     
1122
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1122
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1123 1123
 }
1124 1124
 
1125
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1126
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1125
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1126
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1127 1127
     
1128
-    $content    = wpinv_email_format_text( $content );
1128
+    $content    = wpinv_email_format_text($content);
1129 1129
     
1130
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1130
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1131 1131
 }
1132 1132
 
1133
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1133
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1134 1134
     $from_name = wpinv_mail_get_from_address();
1135 1135
     $from_email = wpinv_mail_get_from_address();
1136 1136
     
1137
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1137
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1138 1138
     
1139
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1140
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1139
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1140
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1141 1141
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1142 1142
     
1143
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1143
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1144 1144
 }
1145 1145
 
1146
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1146
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1147 1147
     $attachments = array();
1148 1148
     
1149
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1149
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1150 1150
 }
1151 1151
 
1152 1152
 function wpinv_email_global_vars() {
@@ -1163,73 +1163,73 @@  discard block
 block discarded – undo
1163 1163
     $replace['sitename']    = $blogname;
1164 1164
     $replace['site-title']  = $blogname;
1165 1165
     
1166
-    return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) );
1166
+    return apply_filters('wpinv_email_global_vars', array($search, $replace));
1167 1167
 }
1168 1168
 
1169
-function wpinv_email_format_text( $content ) {
1169
+function wpinv_email_format_text($content) {
1170 1170
     global $wpinv_email_search, $wpinv_email_replace;
1171 1171
     
1172
-    if ( empty( $wpinv_email_search ) ) {
1172
+    if (empty($wpinv_email_search)) {
1173 1173
         $wpinv_email_search = array();
1174 1174
     }
1175 1175
     
1176
-    if ( empty( $wpinv_email_replace ) ) {
1176
+    if (empty($wpinv_email_replace)) {
1177 1177
         $wpinv_email_replace = array();
1178 1178
     }
1179 1179
     
1180
-    $wpinv_email_search     = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search );
1181
-    $wpinv_email_replace    = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace );
1180
+    $wpinv_email_search     = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search);
1181
+    $wpinv_email_replace    = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace);
1182 1182
     
1183 1183
     $global_vars    = wpinv_email_global_vars();
1184 1184
     
1185
-    $search         = array_merge( $global_vars[0], $wpinv_email_search );
1186
-    $replace        = array_merge( $global_vars[1], $wpinv_email_replace );
1185
+    $search         = array_merge($global_vars[0], $wpinv_email_search);
1186
+    $replace        = array_merge($global_vars[1], $wpinv_email_replace);
1187 1187
     
1188
-    if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) {
1188
+    if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) {
1189 1189
         return  $content;
1190 1190
     }
1191 1191
         
1192
-    return str_replace( $search, $replace, $content );
1192
+    return str_replace($search, $replace, $content);
1193 1193
 }
1194 1194
 
1195
-function wpinv_email_style_body( $content ) {
1195
+function wpinv_email_style_body($content) {
1196 1196
     // make sure we only inline CSS for html emails
1197
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1197
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1198 1198
         ob_start();
1199
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1200
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1199
+        wpinv_get_template('emails/wpinv-email-styles.php');
1200
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1201 1201
         
1202 1202
         // apply CSS styles inline for picky email clients
1203 1203
         try {
1204
-            $emogrifier = new Emogrifier( $content, $css );
1204
+            $emogrifier = new Emogrifier($content, $css);
1205 1205
             $content    = $emogrifier->emogrify();
1206
-        } catch ( Exception $e ) {
1207
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1206
+        } catch (Exception $e) {
1207
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1208 1208
         }
1209 1209
     }
1210 1210
     return $content;
1211 1211
 }
1212 1212
 
1213
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1214
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1213
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1214
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1215 1215
 }
1216 1216
 
1217 1217
 /**
1218 1218
  * Get the email footer.
1219 1219
  */
1220
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1221
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1220
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1221
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1222 1222
 }
1223 1223
 
1224
-function wpinv_email_wrap_message( $message ) {
1224
+function wpinv_email_wrap_message($message) {
1225 1225
     // Buffer
1226 1226
     ob_start();
1227 1227
 
1228
-    do_action( 'wpinv_email_header' );
1228
+    do_action('wpinv_email_header');
1229 1229
 
1230
-    echo wpautop( wptexturize( $message ) );
1230
+    echo wpautop(wptexturize($message));
1231 1231
 
1232
-    do_action( 'wpinv_email_footer' );
1232
+    do_action('wpinv_email_footer');
1233 1233
 
1234 1234
     // Get contents
1235 1235
     $message = ob_get_clean();
@@ -1237,86 +1237,86 @@  discard block
 block discarded – undo
1237 1237
     return $message;
1238 1238
 }
1239 1239
 
1240
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1241
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1240
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1241
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1242 1242
 }
1243 1243
 
1244
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1245
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1244
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1245
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1246 1246
 }
1247 1247
 
1248
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1249
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1248
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1249
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1250 1250
 }
1251 1251
 
1252
-function wpinv_send_customer_invoice( $data = array() ) {
1253
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1252
+function wpinv_send_customer_invoice($data = array()) {
1253
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1254 1254
     
1255
-    if ( empty( $invoice_id ) ) {
1255
+    if (empty($invoice_id)) {
1256 1256
         return;
1257 1257
     }
1258 1258
 
1259
-    if ( !current_user_can( 'manage_options' ) ) {
1260
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1259
+    if (!current_user_can('manage_options')) {
1260
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1261 1261
     }
1262 1262
     
1263
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1263
+    $sent = wpinv_user_invoice_notification($invoice_id);
1264 1264
     
1265 1265
     $status = $sent ? 'email_sent' : 'email_fail';
1266 1266
     
1267
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1268
-    wp_redirect( $redirect );
1267
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1268
+    wp_redirect($redirect);
1269 1269
     exit;
1270 1270
 }
1271
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1271
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1272 1272
 
1273
-function wpinv_send_overdue_reminder( $data = array() ) {
1274
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1273
+function wpinv_send_overdue_reminder($data = array()) {
1274
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1275 1275
     
1276
-    if ( empty( $invoice_id ) ) {
1276
+    if (empty($invoice_id)) {
1277 1277
         return;
1278 1278
     }
1279 1279
 
1280
-    if ( !current_user_can( 'manage_options' ) ) {
1281
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1280
+    if (!current_user_can('manage_options')) {
1281
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1282 1282
     }
1283 1283
     
1284
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1284
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1285 1285
     
1286 1286
     $status = $sent ? 'email_sent' : 'email_fail';
1287 1287
     
1288
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1289
-    wp_redirect( $redirect );
1288
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1289
+    wp_redirect($redirect);
1290 1290
     exit;
1291 1291
 }
1292
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1292
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1293 1293
 
1294
-function wpinv_send_customer_note_email( $data ) {
1295
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1294
+function wpinv_send_customer_note_email($data) {
1295
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1296 1296
     
1297
-    if ( empty( $invoice_id ) ) {
1297
+    if (empty($invoice_id)) {
1298 1298
         return;
1299 1299
     }
1300 1300
     
1301
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1301
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1302 1302
 }
1303
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1303
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1304 1304
 
1305
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1306
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1307
-        $date_format = get_option( 'date_format' );
1308
-        $time_format = get_option( 'time_format' );
1305
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1306
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1307
+        $date_format = get_option('date_format');
1308
+        $time_format = get_option('time_format');
1309 1309
         ?>
1310 1310
         <div id="wpinv-email-notes">
1311
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1311
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1312 1312
             <ol class="wpinv-notes-lists">
1313 1313
         <?php
1314
-        foreach ( $invoice_notes as $note ) {
1315
-            $note_time = strtotime( $note->comment_date );
1314
+        foreach ($invoice_notes as $note) {
1315
+            $note_time = strtotime($note->comment_date);
1316 1316
             ?>
1317 1317
             <li class="comment wpinv-note">
1318
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1319
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1318
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1319
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1320 1320
             </li>
1321 1321
             <?php
1322 1322
         }
@@ -1325,21 +1325,21 @@  discard block
 block discarded – undo
1325 1325
         <?php
1326 1326
     }
1327 1327
 }
1328
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1328
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1329 1329
 
1330 1330
 function wpinv_email_payment_reminders() {    
1331 1331
     global $wpi_auto_reminder;
1332
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1332
+    if (!wpinv_get_option('email_overdue_active')) {
1333 1333
         return;
1334 1334
     }
1335 1335
     
1336
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1337
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1336
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1337
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1338 1338
         
1339
-        if ( empty( $reminder_days ) ) {
1339
+        if (empty($reminder_days)) {
1340 1340
             return;
1341 1341
         }
1342
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1342
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1343 1343
         
1344 1344
         $args = array(
1345 1345
             'post_type'     => 'wpi_invoice',
@@ -1349,7 +1349,7 @@  discard block
 block discarded – undo
1349 1349
             'meta_query'    => array(
1350 1350
                 array(
1351 1351
                     'key'       =>  '_wpinv_due_date',
1352
-                    'value'     =>  array( '', 'none' ),
1352
+                    'value'     =>  array('', 'none'),
1353 1353
                     'compare'   =>  'NOT IN',
1354 1354
                 )
1355 1355
             ),
@@ -1358,64 +1358,64 @@  discard block
 block discarded – undo
1358 1358
             'order'         => 'ASC',
1359 1359
         );
1360 1360
         
1361
-        $invoices = get_posts( $args );
1361
+        $invoices = get_posts($args);
1362 1362
         
1363
-        if ( empty( $invoices ) ) {
1363
+        if (empty($invoices)) {
1364 1364
             return;
1365 1365
         }
1366 1366
         
1367
-        $date_to_send   = array();
1367
+        $date_to_send = array();
1368 1368
         
1369
-        foreach ( $invoices as $id ) {
1370
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1369
+        foreach ($invoices as $id) {
1370
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1371 1371
             
1372
-            foreach ( $reminder_days as $key => $days ) {
1373
-                if ( $days !== '' ) {
1374
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1372
+            foreach ($reminder_days as $key => $days) {
1373
+                if ($days !== '') {
1374
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1375 1375
                 }
1376 1376
             }
1377 1377
         }
1378 1378
 
1379
-        $today              = date_i18n( 'Y-m-d' );
1379
+        $today              = date_i18n('Y-m-d');
1380 1380
         $wpi_auto_reminder  = true;
1381 1381
 
1382
-        foreach ( $date_to_send as $id => $values ) {
1383
-            if ( in_array( $today, $values ) ) {
1384
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1382
+        foreach ($date_to_send as $id => $values) {
1383
+            if (in_array($today, $values)) {
1384
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1385 1385
 
1386
-                if ( isset( $sent ) && !empty( $sent ) ) {
1387
-                    if ( !in_array( $today, $sent ) ) {
1388
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1386
+                if (isset($sent) && !empty($sent)) {
1387
+                    if (!in_array($today, $sent)) {
1388
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1389 1389
                     }
1390 1390
                 } else {
1391
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1391
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1392 1392
                 }
1393 1393
             }
1394 1394
         }
1395 1395
         
1396
-        $wpi_auto_reminder  = false;
1396
+        $wpi_auto_reminder = false;
1397 1397
     }
1398 1398
 }
1399 1399
 
1400
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1400
+function wpinv_send_payment_reminder_notification($invoice_id) {
1401 1401
     global $wpinv_email_search, $wpinv_email_replace;
1402 1402
     
1403 1403
     $email_type = 'overdue';
1404
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1404
+    if (!wpinv_email_is_enabled($email_type)) {
1405 1405
         return false;
1406 1406
     }
1407 1407
     
1408
-    $invoice    = wpinv_get_invoice( $invoice_id );
1409
-    if ( empty( $invoice ) ) {
1408
+    $invoice = wpinv_get_invoice($invoice_id);
1409
+    if (empty($invoice)) {
1410 1410
         return false;
1411 1411
     }
1412 1412
     
1413
-    if ( !$invoice->needs_payment() ) {
1413
+    if (!$invoice->needs_payment()) {
1414 1414
         return false;
1415 1415
     }
1416 1416
     
1417
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1418
-    if ( !is_email( $recipient ) ) {
1417
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1418
+    if (!is_email($recipient)) {
1419 1419
         return false;
1420 1420
     }
1421 1421
         
@@ -1431,60 +1431,60 @@  discard block
 block discarded – undo
1431 1431
     $replace                    = array();
1432 1432
     $replace['full_name']       = $invoice->get_user_full_name();
1433 1433
     $replace['invoice_number']  = $invoice->get_number();
1434
-    $replace['invoice_due_date']= $invoice->get_due_date( true );
1435
-    $replace['invoice_total']   = $invoice->get_total( true );
1436
-    $replace['invoice_link']    = $invoice->get_view_url( true );
1437
-    $replace['invoice_pay_link']= $invoice->get_checkout_payment_url( false, true );
1438
-    $replace['is_was']          = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' );
1434
+    $replace['invoice_due_date'] = $invoice->get_due_date(true);
1435
+    $replace['invoice_total']   = $invoice->get_total(true);
1436
+    $replace['invoice_link']    = $invoice->get_view_url(true);
1437
+    $replace['invoice_pay_link'] = $invoice->get_checkout_payment_url(false, true);
1438
+    $replace['is_was']          = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing');
1439 1439
 
1440 1440
     $wpinv_email_search         = $search;
1441 1441
     $wpinv_email_replace        = $replace;
1442 1442
     
1443
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1444
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1445
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1446
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1443
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1444
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1445
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1446
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1447 1447
     
1448
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1448
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1449 1449
     
1450
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1450
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1451 1451
             'invoice'       => $invoice,
1452 1452
             'email_type'    => $email_type,
1453 1453
             'email_heading' => $email_heading,
1454 1454
             'sent_to_admin' => false,
1455 1455
             'plain_text'    => false,
1456 1456
             'message_body'  => $message_body
1457
-        ) );
1457
+        ));
1458 1458
         
1459
-    $content        = wpinv_email_format_text( $content );
1459
+    $content = wpinv_email_format_text($content);
1460 1460
 
1461
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1462
-    if ( $sent ) {
1463
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1461
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1462
+    if ($sent) {
1463
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1464 1464
     }
1465 1465
         
1466 1466
     return $sent;
1467 1467
 }
1468
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1468
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1469 1469
 
1470
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1470
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1471 1471
     global $wpi_auto_reminder;
1472 1472
     
1473
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1473
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1474 1474
     
1475
-    if ( empty( $sent ) ) {
1475
+    if (empty($sent)) {
1476 1476
         $sent = array();
1477 1477
     }
1478
-    $sent[] = date_i18n( 'Y-m-d' );
1478
+    $sent[] = date_i18n('Y-m-d');
1479 1479
     
1480
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1480
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1481 1481
     
1482
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1483
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1484
-        $invoice->add_note( $note, false, false, true );
1482
+    if ($wpi_auto_reminder) { // Auto reminder note.
1483
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1484
+        $invoice->add_note($note, false, false, true);
1485 1485
     } else { // Menual reminder note.
1486
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1487
-        $invoice->add_note( $note );
1486
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1487
+        $invoice->add_note($note);
1488 1488
     }
1489 1489
 }
1490
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1491 1490
\ No newline at end of file
1491
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1492 1492
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +153 added lines, -153 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,187 +83,187 @@  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() ) {
147
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
148
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
149
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
153
-            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()) {
147
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
148
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
149
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
153
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
154 154
         }
155 155
         
156 156
         // include css inliner
157
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
158
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
157
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
158
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
159 159
         }
160 160
         
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
162 162
     }
163 163
     
164 164
     public function init() {
165 165
     }
166 166
     
167 167
     public function admin_init() {
168
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
168
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
169 169
         }
170 170
         
171
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
171
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
172 172
     }
173 173
 
174 174
     public function activation_redirect() {
175 175
         // Bail if no activation redirect
176
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
176
+        if (!get_transient('_wpinv_activation_redirect')) {
177 177
             return;
178 178
         }
179 179
 
180 180
         // Delete the redirect transient
181
-        delete_transient( '_wpinv_activation_redirect' );
181
+        delete_transient('_wpinv_activation_redirect');
182 182
 
183 183
         // Bail if activating from network, or bulk
184
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
             return;
186 186
         }
187 187
 
188
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
188
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
189 189
         exit;
190 190
     }
191 191
     
192 192
     public function enqueue_scripts() {
193
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
193
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
194 194
         
195
-        wp_deregister_style( 'font-awesome' );
196
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
197
-        wp_enqueue_style( 'font-awesome' );
195
+        wp_deregister_style('font-awesome');
196
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
197
+        wp_enqueue_style('font-awesome');
198 198
         
199
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
200
-        wp_enqueue_style( 'wpinv_front_style' );
199
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
200
+        wp_enqueue_style('wpinv_front_style');
201 201
                
202 202
         // Register scripts
203
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
204
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
203
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
204
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
205 205
         
206 206
         $localize                         = array();
207
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
208
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
207
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
208
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
209 209
         $localize['currency_symbol']      = wpinv_currency_symbol();
210 210
         $localize['currency_pos']         = wpinv_currency_position();
211 211
         $localize['thousand_sep']         = wpinv_thousands_seperator();
212 212
         $localize['decimal_sep']          = wpinv_decimal_seperator();
213 213
         $localize['decimals']             = wpinv_decimals();
214 214
         
215
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
215
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
216 216
         
217
-        wp_enqueue_script( 'jquery-blockui' );
218
-        wp_enqueue_script( 'wpinv-front-script' );
219
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
217
+        wp_enqueue_script('jquery-blockui');
218
+        wp_enqueue_script('wpinv-front-script');
219
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
220 220
     }
221 221
     
222 222
     public function admin_enqueue_scripts() {
223 223
         global $post, $pagenow;
224 224
         
225 225
         $post_type  = wpinv_admin_post_type();
226
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
226
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
227 227
         
228
-        wp_deregister_style( 'font-awesome' );
229
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
230
-        wp_enqueue_style( 'font-awesome' );
228
+        wp_deregister_style('font-awesome');
229
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
230
+        wp_enqueue_style('font-awesome');
231 231
         
232
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
233
-        wp_enqueue_style( 'jquery-ui-css' );
232
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
233
+        wp_enqueue_style('jquery-ui-css');
234 234
         
235
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
236
-        wp_enqueue_style( 'jquery-chosen' );
235
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
236
+        wp_enqueue_style('jquery-chosen');
237 237
 
238
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
239
-        wp_enqueue_script( 'jquery-chosen' );
238
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
239
+        wp_enqueue_script('jquery-chosen');
240 240
         
241
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
242
-        wp_enqueue_style( 'wpinv_meta_box_style' );
241
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
242
+        wp_enqueue_style('wpinv_meta_box_style');
243 243
         
244
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
245
-        wp_enqueue_style( 'wpinv_admin_style' );
244
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
245
+        wp_enqueue_style('wpinv_admin_style');
246 246
         
247
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
248
-            wp_enqueue_script( 'jquery-ui-datepicker' );
247
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
248
+            wp_enqueue_script('jquery-ui-datepicker');
249 249
         }
250 250
 
251
-        wp_enqueue_style( 'wp-color-picker' );
252
-        wp_enqueue_script( 'wp-color-picker' );
251
+        wp_enqueue_style('wp-color-picker');
252
+        wp_enqueue_script('wp-color-picker');
253 253
         
254
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
254
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
255 255
         
256
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
257
-        wp_enqueue_script( 'wpinv-admin-script' );
256
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
257
+        wp_enqueue_script('wpinv-admin-script');
258 258
         
259 259
         $localize                               = array();
260
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
261
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
262
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
263
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
264
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
265
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
266
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
260
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
261
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
262
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
263
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
264
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
265
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
266
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
267 267
         $localize['tax']                        = wpinv_tax_amount();
268 268
         $localize['discount']                   = wpinv_discount_amount();
269 269
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -271,55 +271,55 @@  discard block
 block discarded – undo
271 271
         $localize['thousand_sep']               = wpinv_thousands_seperator();
272 272
         $localize['decimal_sep']                = wpinv_decimal_seperator();
273 273
         $localize['decimals']                   = wpinv_decimals();
274
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
275
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
276
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
277
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
278
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
279
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
280
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
281
-        $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' );
282
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
283
-        $localize['hasGD']                      = wpinv_gd_active();;
274
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
275
+        $localize['status_publish']             = wpinv_status_nicename('publish');
276
+        $localize['status_pending']             = wpinv_status_nicename('pending');
277
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
278
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
279
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
280
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
281
+        $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');
282
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
283
+        $localize['hasGD']                      = wpinv_gd_active(); ;
284 284
         $localize['hasPM']                      = wpinv_pm_active();
285
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
286
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
287
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
288
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
285
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
286
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
287
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
288
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
289 289
         
290
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
290
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
291 291
     }
292 292
     
293
-    public function admin_body_class( $classes ) {
293
+    public function admin_body_class($classes) {
294 294
         global $pagenow;
295 295
         
296
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
296
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
297 297
 
298 298
         $add_class = false;
299
-        if ( $pagenow == 'admin.php' && $page ) {
300
-            $add_class = strpos( $page, 'wpinv-' );
299
+        if ($pagenow == 'admin.php' && $page) {
300
+            $add_class = strpos($page, 'wpinv-');
301 301
         }
302 302
         
303 303
         $settings_class = array();
304
-        if ( $page == 'wpinv-settings' ) {
305
-            if ( !empty( $_REQUEST['tab'] ) ) {
306
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
304
+        if ($page == 'wpinv-settings') {
305
+            if (!empty($_REQUEST['tab'])) {
306
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
307 307
             }
308 308
             
309
-            if ( !empty( $_REQUEST['section'] ) ) {
310
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
309
+            if (!empty($_REQUEST['section'])) {
310
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
311 311
             }
312 312
             
313
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
313
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
314 314
         }
315 315
         
316
-        if ( !empty( $settings_class ) ) {
317
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
316
+        if (!empty($settings_class)) {
317
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
318 318
         }
319 319
         
320 320
         $post_type = wpinv_admin_post_type();
321 321
         
322
-        if ( $post_type == 'wpi_invoice' || $add_class !== false ) {
322
+        if ($post_type == 'wpi_invoice' || $add_class !== false) {
323 323
             return $classes .= ' wpinv';
324 324
         } else {
325 325
             return $classes;
@@ -331,26 +331,26 @@  discard block
 block discarded – undo
331 331
     public function admin_print_scripts_edit_php() {
332 332
         $post_type = wpinv_admin_post_type();
333 333
         
334
-        if ( $post_type == 'wpi_item' ) {
335
-            wp_enqueue_script( 'wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array( 'jquery', 'inline-edit-post' ), '', true );
334
+        if ($post_type == 'wpi_item') {
335
+            wp_enqueue_script('wpinv-inline-edit-post', WPINV_PLUGIN_URL . 'assets/js/quick-edit.js', array('jquery', 'inline-edit-post'), '', true);
336 336
         }
337 337
     }
338 338
     
339 339
     public function wpinv_actions() {
340
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
341
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
340
+        if (isset($_REQUEST['wpi_action'])) {
341
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
342 342
         }
343 343
     }
344 344
     
345
-    public function pre_get_posts( $wp_query ) {
346
-        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() ) {
347
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
345
+    public function pre_get_posts($wp_query) {
346
+        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()) {
347
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
348 348
         }
349 349
         
350 350
         return $wp_query;
351 351
     }
352 352
     
353 353
     public function bp_invoicing_init() {
354
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
354
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
355 355
     }
356 356
 }
357 357
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv-session.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 /**
6 6
  * WPInv_Session Class.
@@ -46,44 +46,44 @@  discard block
 block discarded – undo
46 46
 	public function __construct() {
47 47
 		$this->use_php_sessions = $this->use_php_sessions();
48 48
 
49
-		if ( $this->use_php_sessions ) {
50
-			if ( is_multisite() ) {
49
+		if ($this->use_php_sessions) {
50
+			if (is_multisite()) {
51 51
 				$this->prefix = '_' . get_current_blog_id();
52 52
 			}
53 53
 
54 54
 			// Use PHP SESSION (must be enabled via the WPINV_USE_PHP_SESSIONS constant)
55
-			add_action( 'init', array( $this, 'maybe_start_session' ), -2 );
55
+			add_action('init', array($this, 'maybe_start_session'), -2);
56 56
 		} else {
57 57
 			// Use WP_Session (default)
58
-			if ( !defined( 'WP_SESSION_COOKIE' ) ) {
59
-				define( 'WP_SESSION_COOKIE', 'wpinv_wp_session' );
58
+			if (!defined('WP_SESSION_COOKIE')) {
59
+				define('WP_SESSION_COOKIE', 'wpinv_wp_session');
60 60
 			}
61 61
 
62
-			if ( !class_exists( 'Recursive_ArrayAccess' ) ) {
62
+			if (!class_exists('Recursive_ArrayAccess')) {
63 63
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-recursive-arrayaccess.php';
64 64
 			}
65 65
             
66
-			if ( !class_exists( 'WP_Session_Utils' ) ) {
66
+			if (!class_exists('WP_Session_Utils')) {
67 67
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session-utils.php';
68 68
 			}
69 69
             
70
-			if ( defined( 'WP_CLI' ) && WP_CLI && !class_exists( 'WP_Session_Command' ) ) {
70
+			if (defined('WP_CLI') && WP_CLI && !class_exists('WP_Session_Command')) {
71 71
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-cli.php';
72 72
 			}
73 73
 
74
-			if ( !class_exists( 'WP_Session' ) ) {
74
+			if (!class_exists('WP_Session')) {
75 75
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/class-wp-session.php';
76 76
 				require_once WPINV_PLUGIN_DIR . 'includes/libraries/wp-session/wp-session.php';
77 77
 			}
78 78
 
79
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
80
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
79
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
80
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
81 81
 		}
82 82
 
83
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
84
-			add_action( 'plugins_loaded', array( $this, 'init' ), -1 );
83
+		if (empty($this->session) && !$this->use_php_sessions) {
84
+			add_action('plugins_loaded', array($this, 'init'), -1);
85 85
 		} else {
86
-			add_action( 'init', array( $this, 'init' ), -1 );
86
+			add_action('init', array($this, 'init'), -1);
87 87
 		}
88 88
 	}
89 89
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	public function init() {
98
-		if ( $this->use_php_sessions ) {
99
-			$this->session = isset( $_SESSION['wpi' . $this->prefix ] ) && is_array( $_SESSION['wpi' . $this->prefix ] ) ? $_SESSION['wpi' . $this->prefix ] : array();
98
+		if ($this->use_php_sessions) {
99
+			$this->session = isset($_SESSION['wpi' . $this->prefix]) && is_array($_SESSION['wpi' . $this->prefix]) ? $_SESSION['wpi' . $this->prefix] : array();
100 100
 		} else {
101 101
 			$this->session = WP_Session::get_instance();
102 102
 		}
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 * @return string Session ID
113 113
 	 */
114 114
 	public function get_id() {
115
-		if ( $this->use_php_sessions ) {
116
-			$session_id = !empty( $_SESSION ) && function_exists( 'session_id' ) ? session_id() : NULL;
115
+		if ($this->use_php_sessions) {
116
+			$session_id = !empty($_SESSION) && function_exists('session_id') ? session_id() : NULL;
117 117
 		} else {
118
-			$session_id = !empty( $this->session ) && isset( $this->session->session_id ) ? $this->session->session_id : NULL;
118
+			$session_id = !empty($this->session) && isset($this->session->session_id) ? $this->session->session_id : NULL;
119 119
 		}
120 120
 		return $session_id;
121 121
 	}
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 * @param string $key Session key
129 129
 	 * @return string Session variable
130 130
 	 */
131
-	public function get( $key ) {
132
-		$key = sanitize_key( $key );
133
-		return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false;
131
+	public function get($key) {
132
+		$key = sanitize_key($key);
133
+		return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false;
134 134
 	}
135 135
 
136 136
 	/**
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 	 * @param integer $value Session variable
143 143
 	 * @return string Session variable
144 144
 	 */
145
-	public function set( $key, $value ) {
146
-		$key = sanitize_key( $key );
145
+	public function set($key, $value) {
146
+		$key = sanitize_key($key);
147 147
 
148
-		if ( is_array( $value ) ) {
149
-			$this->session[ $key ] = maybe_serialize( $value );
148
+		if (is_array($value)) {
149
+			$this->session[$key] = maybe_serialize($value);
150 150
 		} else {
151
-			$this->session[ $key ] = $value;
151
+			$this->session[$key] = $value;
152 152
 		}
153 153
 
154
-		if ( $this->use_php_sessions ) {
155
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
154
+		if ($this->use_php_sessions) {
155
+			$_SESSION['wpi' . $this->prefix] = $this->session;
156 156
 		}
157 157
 
158
-		return $this->session[ $key ];
158
+		return $this->session[$key];
159 159
 	}
160 160
 	
161 161
 	/**
@@ -167,29 +167,29 @@  discard block
 block discarded – undo
167 167
 	 * @param integer $value Session variable.
168 168
 	 * @return string Session variable.
169 169
 	 */
170
-	public function un_set( $key ) {
171
-		if ( empty( $key ) ) {
170
+	public function un_set($key) {
171
+		if (empty($key)) {
172 172
 			return false;
173 173
 		}
174 174
 		
175
-		if ( is_array( $key ) ) {
175
+		if (is_array($key)) {
176 176
 			foreach ($key as $index) {
177
-				$index = sanitize_key( $index );
177
+				$index = sanitize_key($index);
178 178
 			
179
-				if ( $index && isset( $this->session[ $index ] ) ) {
180
-					unset( $this->session[ $index ] );
179
+				if ($index && isset($this->session[$index])) {
180
+					unset($this->session[$index]);
181 181
 				}
182 182
 			}
183 183
 		} else {
184
-			$key = sanitize_key( $key );
184
+			$key = sanitize_key($key);
185 185
 			
186
-			if ( isset( $this->session[ $key ] ) ) {
187
-				unset( $this->session[ $key ] );
186
+			if (isset($this->session[$key])) {
187
+				unset($this->session[$key]);
188 188
 			}
189 189
 		}
190 190
 
191
-		if ( $this->use_php_sessions ) {
192
-			$_SESSION['wpi' . $this->prefix ] = $this->session;
191
+		if ($this->use_php_sessions) {
192
+			$_SESSION['wpi' . $this->prefix] = $this->session;
193 193
 		}
194 194
 
195 195
 		return true;
@@ -204,14 +204,14 @@  discard block
 block discarded – undo
204 204
 	 * @param integer $value Session variable.
205 205
 	 * @return string Session variable.
206 206
 	 */
207
-	public function is_set( $key ) {
208
-		$key = sanitize_key( $key );
207
+	public function is_set($key) {
208
+		$key = sanitize_key($key);
209 209
 		
210
-		if ( empty( $key ) ) {
210
+		if (empty($key)) {
211 211
 			return false;
212 212
 		}
213 213
 
214
-		if ( isset( $this->session[ $key ] ) ) {
214
+		if (isset($this->session[$key])) {
215 215
 			return true;
216 216
 		}
217 217
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param int $exp Default expiration (1 hour)
227 227
 	 * @return int
228 228
 	 */
229
-	public function set_expiration_variant_time( $exp ) {
230
-		return ( 30 * 60 * 23 );
229
+	public function set_expiration_variant_time($exp) {
230
+		return (30 * 60 * 23);
231 231
 	}
232 232
 
233 233
 	/**
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param int $exp Default expiration (1 hour)
239 239
 	 * @return int
240 240
 	 */
241
-	public function set_expiration_time( $exp ) {
242
-		return ( 30 * 60 * 24 );
241
+	public function set_expiration_time($exp) {
242
+		return (30 * 60 * 24);
243 243
 	}
244 244
 
245 245
 	/**
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 		$ret = false;
258 258
 
259 259
 		// If the database variable is already set, no need to run autodetection
260
-		$wpinv_use_php_sessions = (bool)get_option( 'wpinv_use_php_sessions' );
260
+		$wpinv_use_php_sessions = (bool)get_option('wpinv_use_php_sessions');
261 261
 
262
-		if (!$wpinv_use_php_sessions ) {
262
+		if (!$wpinv_use_php_sessions) {
263 263
 			// Attempt to detect if the server supports PHP sessions
264
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
265
-				$this->set( 'wpinv_use_php_sessions', 1 );
264
+			if (function_exists('session_start') && !ini_get('safe_mode')) {
265
+				$this->set('wpinv_use_php_sessions', 1);
266 266
 				
267
-				if ( $this->get( 'wpinv_use_php_sessions' ) ) {
267
+				if ($this->get('wpinv_use_php_sessions')) {
268 268
 					$ret = true;
269 269
 
270 270
 					// Set the database option
271
-					update_option( 'wpinv_use_php_sessions', true );
271
+					update_option('wpinv_use_php_sessions', true);
272 272
 				}
273 273
 			}
274 274
 		} else {
@@ -276,20 +276,20 @@  discard block
 block discarded – undo
276 276
 		}
277 277
 
278 278
 		// Enable or disable PHP Sessions based on the WPINV_USE_PHP_SESSIONS constant
279
-		if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && WPINV_USE_PHP_SESSIONS ) {
279
+		if (defined('WPINV_USE_PHP_SESSIONS') && WPINV_USE_PHP_SESSIONS) {
280 280
 			$ret = true;
281
-		} else if ( defined( 'WPINV_USE_PHP_SESSIONS' ) && ! WPINV_USE_PHP_SESSIONS ) {
281
+		} else if (defined('WPINV_USE_PHP_SESSIONS') && !WPINV_USE_PHP_SESSIONS) {
282 282
 			$ret = false;
283 283
 		}
284 284
 
285
-		return (bool) apply_filters( 'wpinv_use_php_sessions', $ret );
285
+		return (bool)apply_filters('wpinv_use_php_sessions', $ret);
286 286
 	}
287 287
 
288 288
 	/**
289 289
 	 * Starts a new session if one hasn't started yet.
290 290
 	 */
291 291
 	public function maybe_start_session() {
292
-		if ( !session_id() && !headers_sent() ) {
292
+		if (!session_id() && !headers_sent()) {
293 293
 			session_start();
294 294
 		}
295 295
 	}
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 class WPInv_Item {
6 6
     public $ID = 0;
@@ -34,26 +34,26 @@  discard block
 block discarded – undo
34 34
     public $filter;
35 35
 
36 36
 
37
-    public function __construct( $_id = false, $_args = array() ) {
38
-        $item = WP_Post::get_instance( $_id );
39
-        return $this->setup_item( $item );
37
+    public function __construct($_id = false, $_args = array()) {
38
+        $item = WP_Post::get_instance($_id);
39
+        return $this->setup_item($item);
40 40
     }
41 41
 
42
-    private function setup_item( $item ) {
43
-        if( ! is_object( $item ) ) {
42
+    private function setup_item($item) {
43
+        if (!is_object($item)) {
44 44
             return false;
45 45
         }
46 46
 
47
-        if( ! is_a( $item, 'WP_Post' ) ) {
47
+        if (!is_a($item, 'WP_Post')) {
48 48
             return false;
49 49
         }
50 50
 
51
-        if( 'wpi_item' !== $item->post_type ) {
51
+        if ('wpi_item' !== $item->post_type) {
52 52
             return false;
53 53
         }
54 54
 
55
-        foreach ( $item as $key => $value ) {
56
-            switch ( $key ) {
55
+        foreach ($item as $key => $value) {
56
+            switch ($key) {
57 57
                 default:
58 58
                     $this->$key = $value;
59 59
                     break;
@@ -63,76 +63,76 @@  discard block
 block discarded – undo
63 63
         return true;
64 64
     }
65 65
 
66
-    public function __get( $key ) {
67
-        if ( method_exists( $this, 'get_' . $key ) ) {
68
-            return call_user_func( array( $this, 'get_' . $key ) );
66
+    public function __get($key) {
67
+        if (method_exists($this, 'get_' . $key)) {
68
+            return call_user_func(array($this, 'get_' . $key));
69 69
         } else {
70
-            return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
70
+            return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
71 71
         }
72 72
     }
73 73
 
74
-    public function create( $data = array(), $wp_error = false ) {
75
-        if ( $this->ID != 0 ) {
74
+    public function create($data = array(), $wp_error = false) {
75
+        if ($this->ID != 0) {
76 76
             return false;
77 77
         }
78 78
 
79 79
         $defaults = array(
80 80
             'post_type'   => 'wpi_item',
81 81
             'post_status' => 'draft',
82
-            'post_title'  => __( 'New Invoice Item', 'invoicing' )
82
+            'post_title'  => __('New Invoice Item', 'invoicing')
83 83
         );
84 84
 
85
-        $args = wp_parse_args( $data, $defaults );
85
+        $args = wp_parse_args($data, $defaults);
86 86
 
87
-        do_action( 'wpinv_item_pre_create', $args );
87
+        do_action('wpinv_item_pre_create', $args);
88 88
 
89
-        $id = wp_insert_post( $args, $wp_error );
89
+        $id = wp_insert_post($args, $wp_error);
90 90
         if ($wp_error && is_wp_error($id)) {
91 91
             return $id;
92 92
         }
93
-        if ( !$id ) {
93
+        if (!$id) {
94 94
             return false;
95 95
         }
96 96
         
97
-        $item = WP_Post::get_instance( $id );
97
+        $item = WP_Post::get_instance($id);
98 98
         
99 99
         if (!empty($item) && !empty($data['meta'])) {
100 100
             $this->ID = $item->ID;
101 101
             $this->save_metas($data['meta']);
102 102
         }
103 103
 
104
-        do_action( 'wpinv_item_create', $id, $args );
104
+        do_action('wpinv_item_create', $id, $args);
105 105
 
106
-        return $this->setup_item( $item );
106
+        return $this->setup_item($item);
107 107
     }
108 108
     
109
-    public function update( $data = array(), $wp_error = false ) {
110
-        if ( !$this->ID > 0 ) {
109
+    public function update($data = array(), $wp_error = false) {
110
+        if (!$this->ID > 0) {
111 111
             return false;
112 112
         }
113 113
         
114 114
         $data['ID'] = $this->ID;
115 115
 
116
-        do_action( 'wpinv_item_pre_update', $data );
116
+        do_action('wpinv_item_pre_update', $data);
117 117
         
118
-        $id = wp_update_post( $data, $wp_error );
118
+        $id = wp_update_post($data, $wp_error);
119 119
         if ($wp_error && is_wp_error($id)) {
120 120
             return $id;
121 121
         }
122 122
         
123
-        if ( !$id ) {
123
+        if (!$id) {
124 124
             return false;
125 125
         }
126 126
 
127
-        $item = WP_Post::get_instance( $id );
127
+        $item = WP_Post::get_instance($id);
128 128
         if (!empty($item) && !empty($data['meta'])) {
129 129
             $this->ID = $item->ID;
130 130
             $this->save_metas($data['meta']);
131 131
         }
132 132
 
133
-        do_action( 'wpinv_item_update', $id, $data );
133
+        do_action('wpinv_item_update', $id, $data);
134 134
 
135
-        return $this->setup_item( $item );
135
+        return $this->setup_item($item);
136 136
     }
137 137
 
138 138
     public function get_ID() {
@@ -140,95 +140,95 @@  discard block
 block discarded – undo
140 140
     }
141 141
 
142 142
     public function get_name() {
143
-        return get_the_title( $this->ID );
143
+        return get_the_title($this->ID);
144 144
     }
145 145
     
146 146
     public function get_summary() {
147
-        return get_the_excerpt( $this->ID );
147
+        return get_the_excerpt($this->ID);
148 148
     }
149 149
 
150 150
     public function get_price() {
151
-        if ( ! isset( $this->price ) ) {
152
-            $this->price = get_post_meta( $this->ID, '_wpinv_price', true );
151
+        if (!isset($this->price)) {
152
+            $this->price = get_post_meta($this->ID, '_wpinv_price', true);
153 153
             
154
-            if ( $this->price ) {
155
-                $this->price = wpinv_sanitize_amount( $this->price );
154
+            if ($this->price) {
155
+                $this->price = wpinv_sanitize_amount($this->price);
156 156
             } else {
157 157
                 $this->price = 0;
158 158
             }
159 159
         }
160 160
         
161
-        return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID );
161
+        return apply_filters('wpinv_get_item_price', $this->price, $this->ID);
162 162
     }
163 163
     
164 164
     public function get_the_price() {
165
-        $item_price = wpinv_price( wpinv_format_amount( $this->price ) );
165
+        $item_price = wpinv_price(wpinv_format_amount($this->price));
166 166
         
167
-        return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID );
167
+        return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID);
168 168
     }
169 169
     
170 170
     public function get_vat_rule() {
171 171
         global $wpinv_euvat;
172 172
         
173
-        if( !isset( $this->vat_rule ) ) {
174
-            $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true );
173
+        if (!isset($this->vat_rule)) {
174
+            $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true);
175 175
 
176
-            if ( empty( $this->vat_rule ) ) {        
176
+            if (empty($this->vat_rule)) {        
177 177
                 $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical';
178 178
             }
179 179
         }
180 180
         
181
-        return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID );
181
+        return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID);
182 182
     }
183 183
     
184 184
     public function get_vat_class() {
185
-        if( !isset( $this->vat_class ) ) {
186
-            $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true );
185
+        if (!isset($this->vat_class)) {
186
+            $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true);
187 187
 
188
-            if ( empty( $this->vat_class ) ) {        
188
+            if (empty($this->vat_class)) {        
189 189
                 $this->vat_class = '_standard';
190 190
             }
191 191
         }
192 192
         
193
-        return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID );
193
+        return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID);
194 194
     }
195 195
     
196 196
     public function get_cpt_singular_name() {
197
-        if( ! isset( $this->cpt_singular_name ) ) {
198
-            $this->cpt_singular_name = get_post_meta( $this->ID, '_wpinv_cpt_singular_name', true );
197
+        if (!isset($this->cpt_singular_name)) {
198
+            $this->cpt_singular_name = get_post_meta($this->ID, '_wpinv_cpt_singular_name', true);
199 199
         }
200 200
 
201
-        return apply_filters( 'wpinv_item_get_cpt_singular_name', $this->cpt_singular_name, $this->ID );
201
+        return apply_filters('wpinv_item_get_cpt_singular_name', $this->cpt_singular_name, $this->ID);
202 202
     }
203 203
 
204 204
     public function get_type() {
205
-        if( ! isset( $this->type ) ) {
206
-            $this->type = get_post_meta( $this->ID, '_wpinv_type', true );
205
+        if (!isset($this->type)) {
206
+            $this->type = get_post_meta($this->ID, '_wpinv_type', true);
207 207
 
208
-            if ( empty( $this->type ) ) {
208
+            if (empty($this->type)) {
209 209
                 $this->type = 'custom';
210 210
             }
211 211
         }
212 212
 
213
-        return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID );
213
+        return apply_filters('wpinv_get_item_type', $this->type, $this->ID);
214 214
     }
215 215
     
216 216
     public function is_recurring() {
217
-        $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true );
217
+        $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true);
218 218
 
219
-        return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID );
219
+        return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID);
220 220
 
221 221
     }
222 222
     
223
-    public function get_recurring_period( $full = false ) {
224
-        $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true );
223
+    public function get_recurring_period($full = false) {
224
+        $period = get_post_meta($this->ID, '_wpinv_recurring_period', true);
225 225
         
226
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
226
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
227 227
             $period = 'D';
228 228
         }
229 229
         
230
-        if ( $full ) {
231
-            switch( $period ) {
230
+        if ($full) {
231
+            switch ($period) {
232 232
                 case 'D':
233 233
                     $period = 'day';
234 234
                 break;
@@ -244,45 +244,45 @@  discard block
 block discarded – undo
244 244
             }
245 245
         }
246 246
 
247
-        return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID );
247
+        return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID);
248 248
 
249 249
     }
250 250
     
251 251
     public function get_recurring_interval() {
252
-        $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true );
252
+        $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true);
253 253
         
254
-        if ( !$interval > 0 ) {
254
+        if (!$interval > 0) {
255 255
             $interval = 1;
256 256
         }
257 257
 
258
-        return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID );
258
+        return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID);
259 259
 
260 260
     }
261 261
     
262 262
     public function get_recurring_limit() {
263
-        $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true );
263
+        $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true);
264 264
 
265
-        return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID );
265
+        return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID);
266 266
 
267 267
     }
268 268
     
269 269
     public function has_free_trial() {
270
-        $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true );
271
-        $free_trial = $this->is_recurring() && !empty( $free_trial ) ? true : false;
270
+        $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true);
271
+        $free_trial = $this->is_recurring() && !empty($free_trial) ? true : false;
272 272
 
273
-        return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID );
273
+        return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID);
274 274
 
275 275
     }
276 276
     
277
-    public function get_trial_period( $full = false ) {
278
-        $period = get_post_meta( $this->ID, '_wpinv_trial_period', true );
277
+    public function get_trial_period($full = false) {
278
+        $period = get_post_meta($this->ID, '_wpinv_trial_period', true);
279 279
         
280
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
280
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
281 281
             $period = 'D';
282 282
         }
283 283
         
284
-        if ( $full ) {
285
-            switch( $period ) {
284
+        if ($full) {
285
+            switch ($period) {
286 286
                 case 'D':
287 287
                     $period = 'day';
288 288
                 break;
@@ -298,47 +298,47 @@  discard block
 block discarded – undo
298 298
             }
299 299
         }
300 300
 
301
-        return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID );
301
+        return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID);
302 302
 
303 303
     }
304 304
     
305 305
     public function get_trial_interval() {
306
-        $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) );
306
+        $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true));
307 307
         
308
-        if ( !$interval > 0 ) {
308
+        if (!$interval > 0) {
309 309
             $interval = 1;
310 310
         }
311 311
 
312
-        return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID );
312
+        return apply_filters('wpinv_item_trial_interval', $interval, $this->ID);
313 313
 
314 314
     }
315 315
 
316 316
     public function is_free() {
317 317
         $is_free = false;
318 318
         
319
-        $price = get_post_meta( $this->ID, '_wpinv_price', true );
319
+        $price = get_post_meta($this->ID, '_wpinv_price', true);
320 320
 
321
-        if ( (float)$price == 0 ) {
321
+        if ((float)$price == 0) {
322 322
             $is_free = true;
323 323
         }
324 324
 
325
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID );
325
+        return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID);
326 326
 
327 327
     }
328 328
     
329 329
     public function is_package() {
330 330
         $is_package = $this->get_type() == 'package' ? true : false;
331 331
 
332
-        return (bool) apply_filters( 'wpinv_is_package_item', $is_package, $this->ID );
332
+        return (bool)apply_filters('wpinv_is_package_item', $is_package, $this->ID);
333 333
 
334 334
     }
335 335
     
336
-    public function save_metas( $metas = array() ) {
337
-        if ( empty( $metas ) ) {
336
+    public function save_metas($metas = array()) {
337
+        if (empty($metas)) {
338 338
             return false;
339 339
         }
340 340
         
341
-        foreach ( $metas as $meta_key => $meta_value ) {
341
+        foreach ($metas as $meta_key => $meta_value) {
342 342
             $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key;
343 343
             
344 344
             $this->update_meta($meta_key, $meta_value);
@@ -347,66 +347,66 @@  discard block
 block discarded – undo
347 347
         return true;
348 348
     }
349 349
 
350
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
351
-        if ( empty( $meta_key ) ) {
350
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
351
+        if (empty($meta_key)) {
352 352
             return false;
353 353
         }
354 354
         
355
-        $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID );
355
+        $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID);
356 356
 
357
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
357
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
358 358
     }
359 359
     
360
-    public function get_fees( $type = 'fee', $item_id = 0 ) {
360
+    public function get_fees($type = 'fee', $item_id = 0) {
361 361
         global $wpi_session;
362 362
         
363
-        $fees = $wpi_session->get( 'wpi_cart_fees' );
363
+        $fees = $wpi_session->get('wpi_cart_fees');
364 364
 
365
-        if ( ! wpinv_get_cart_contents() ) {
365
+        if (!wpinv_get_cart_contents()) {
366 366
             // We can only get item type fees when the cart is empty
367 367
             $type = 'custom';
368 368
         }
369 369
 
370
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
371
-            foreach( $fees as $key => $fee ) {
372
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
373
-                    unset( $fees[ $key ] );
370
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
371
+            foreach ($fees as $key => $fee) {
372
+                if (!empty($fee['type']) && $type != $fee['type']) {
373
+                    unset($fees[$key]);
374 374
                 }
375 375
             }
376 376
         }
377 377
 
378
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
378
+        if (!empty($fees) && !empty($item_id)) {
379 379
             // Remove fees that don't belong to the specified Item
380
-            foreach ( $fees as $key => $fee ) {
381
-                if ( (int) $item_id !== (int)$fee['item_id'] ) {
382
-                    unset( $fees[ $key ] );
380
+            foreach ($fees as $key => $fee) {
381
+                if ((int)$item_id !== (int)$fee['item_id']) {
382
+                    unset($fees[$key]);
383 383
                 }
384 384
             }
385 385
         }
386 386
 
387
-        if ( ! empty( $fees ) ) {
387
+        if (!empty($fees)) {
388 388
             // Remove fees that belong to a specific item but are not in the cart
389
-            foreach( $fees as $key => $fee ) {
390
-                if( empty( $fee['item_id'] ) ) {
389
+            foreach ($fees as $key => $fee) {
390
+                if (empty($fee['item_id'])) {
391 391
                     continue;
392 392
                 }
393 393
 
394
-                if ( !wpinv_item_in_cart( $fee['item_id'] ) ) {
395
-                    unset( $fees[ $key ] );
394
+                if (!wpinv_item_in_cart($fee['item_id'])) {
395
+                    unset($fees[$key]);
396 396
                 }
397 397
             }
398 398
         }
399 399
 
400
-        return ! empty( $fees ) ? $fees : array();
400
+        return !empty($fees) ? $fees : array();
401 401
     }
402 402
     
403 403
     public function can_purchase() {
404 404
         $can_purchase = true;
405 405
 
406
-        if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
406
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
407 407
             $can_purchase = false;
408 408
         }
409 409
 
410
-        return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
410
+        return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
411 411
     }
412 412
 }
Please login to merge, or discard this patch.
includes/gateways/worldpay.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_worldpay_cc_form', '__return_false' );
5
+add_action('wpinv_worldpay_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_worldpay_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_worldpay_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
     
12 12
     // Collect payment data
@@ -24,120 +24,120 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
29
+    if (!empty($invoice)) {
30 30
         $quantities_enabled = wpinv_item_quantities_enabled();
31 31
         
32
-        $instId     = wpinv_get_option( 'worldpay_instId', false );
32
+        $instId     = wpinv_get_option('worldpay_instId', false);
33 33
         $cartId     = $invoice->get_number();
34
-        $testMode   = wpinv_is_test_mode( 'worldpay' ) ? 100 : 0;
34
+        $testMode   = wpinv_is_test_mode('worldpay') ? 100 : 0;
35 35
         $name       = $invoice->get_user_full_name();
36
-        $address    = wp_strip_all_tags( $invoice->get_address(), true );
36
+        $address    = wp_strip_all_tags($invoice->get_address(), true);
37 37
         $postcode   = $invoice->zip;
38 38
         $tel        = $invoice->phone;
39 39
         $email      = $invoice->get_email();
40 40
         $country    = $invoice->country;
41
-        $amount     = wpinv_sanitize_amount( $invoice->get_total() );
41
+        $amount     = wpinv_sanitize_amount($invoice->get_total());
42 42
         $currency   = wpinv_get_currency();
43 43
         
44 44
         $items      = array();
45
-        foreach ( $invoice->get_cart_details() as $item ) {
45
+        foreach ($invoice->get_cart_details() as $item) {
46 46
             $item_desc  = $item['name'];
47
-            $quantity   = !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
-            $item_desc .= ' (' . ( $quantities_enabled ? $quantity . 'x ' : '' ) . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')';
47
+            $quantity   = !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1;
48
+            $item_desc .= ' (' . ($quantities_enabled ? $quantity . 'x ' : '') . wpinv_price(wpinv_format_amount($item['item_price'])) . ')';
49 49
             
50 50
             $items[] = $item_desc;
51 51
         }
52 52
         
53
-        $desc = implode( ', ', $items );
54
-        if ( wpinv_use_taxes() && $invoice->get_tax() > 0 ) {
55
-            $desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) );
53
+        $desc = implode(', ', $items);
54
+        if (wpinv_use_taxes() && $invoice->get_tax() > 0) {
55
+            $desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true));
56 56
         }
57 57
         
58 58
         $extra_params                   = array();
59 59
         $extra_params['MC_description'] = $desc;
60
-        $extra_params['MC_callback']    = wpinv_get_ipn_url( 'worldpay' );
60
+        $extra_params['MC_callback']    = wpinv_get_ipn_url('worldpay');
61 61
         $extra_params['MC_key']         = $invoice->get_key();
62 62
         $extra_params['MC_invoice_id']  = $invoice->ID;
63 63
         $extra_params['address1']       = $address;
64 64
         $extra_params['town']           = $invoice->city;
65 65
         $extra_params['region']         = $invoice->state;
66
-        $extra_params['amountString']   = $invoice->get_total( true );
67
-        $extra_params['countryString']  = wpinv_country_name( $invoice->country );
66
+        $extra_params['amountString']   = $invoice->get_total(true);
67
+        $extra_params['countryString']  = wpinv_country_name($invoice->country);
68 68
         $extra_params['compName']       = $invoice->company;
69 69
         
70
-        $extra_params   = apply_filters( 'wpinv_worldpay_form_extra_parameters', $extra_params, $invoice );
70
+        $extra_params   = apply_filters('wpinv_worldpay_form_extra_parameters', $extra_params, $invoice);
71 71
         
72
-        $redirect_text  = __( 'Redirecting to Worldpay site, click on button if not redirected.', 'invoicing' );
73
-        $redirect_text  = apply_filters( 'wpinv_worldpay_redirect_text', $redirect_text, $invoice );
72
+        $redirect_text  = __('Redirecting to Worldpay site, click on button if not redirected.', 'invoicing');
73
+        $redirect_text  = apply_filters('wpinv_worldpay_redirect_text', $redirect_text, $invoice);
74 74
         
75 75
         // Empty the shopping cart
76 76
         wpinv_empty_cart();
77 77
         ?>
78 78
 <div class="wpi-worldpay-form" style="padding:20px;font-family:arial,sans-serif;text-align:center;color:#555">
79
-<?php do_action( 'wpinv_worldpay_form_before', $invoice ); ?>
80
-<h3><?php echo $redirect_text ;?></h3>
79
+<?php do_action('wpinv_worldpay_form_before', $invoice); ?>
80
+<h3><?php echo $redirect_text; ?></h3>
81 81
 <form action="<?php echo wpinv_get_worldpay_redirect(); ?>" name="wpi_worldpay_form" method="POST">
82
-    <input type="hidden" value="<?php echo $amount;?>" name="amount">
83
-    <input type="hidden" value="<?php echo esc_attr( $cartId );?>" name="cartId">
84
-    <input type="hidden" value="<?php echo $currency;?>" name="currency">
85
-    <input type="hidden" value="<?php echo $instId;?>" name="instId">
86
-    <input type="hidden" value="<?php echo $testMode;?>" name="testMode">
87
-    <input type="hidden" value="<?php echo esc_attr( $name );?>" name="name">
88
-    <input type="hidden" value="<?php echo esc_attr( $address );?>" name="address">
89
-    <input type="hidden" value="<?php echo esc_attr( $postcode );?>" name="postcode">
90
-    <input type="hidden" value="<?php echo esc_attr( $tel );?>" name="tel">
91
-    <input type="hidden" value="<?php echo esc_attr( $email );?>" name="email">
92
-    <input type="hidden" value="<?php echo esc_attr( $country );?>" name="country">
93
-    <input type="hidden" value="<?php echo esc_attr( $desc );?>" name="desc">
94
-    <?php foreach ( $extra_params as $param => $value ) { ?>
95
-        <?php if ( !empty( $value !== false ) ) { ?>
96
-    <input type="hidden" value="<?php echo esc_attr( $value );?>" name="<?php echo esc_attr( $param );?>">
82
+    <input type="hidden" value="<?php echo $amount; ?>" name="amount">
83
+    <input type="hidden" value="<?php echo esc_attr($cartId); ?>" name="cartId">
84
+    <input type="hidden" value="<?php echo $currency; ?>" name="currency">
85
+    <input type="hidden" value="<?php echo $instId; ?>" name="instId">
86
+    <input type="hidden" value="<?php echo $testMode; ?>" name="testMode">
87
+    <input type="hidden" value="<?php echo esc_attr($name); ?>" name="name">
88
+    <input type="hidden" value="<?php echo esc_attr($address); ?>" name="address">
89
+    <input type="hidden" value="<?php echo esc_attr($postcode); ?>" name="postcode">
90
+    <input type="hidden" value="<?php echo esc_attr($tel); ?>" name="tel">
91
+    <input type="hidden" value="<?php echo esc_attr($email); ?>" name="email">
92
+    <input type="hidden" value="<?php echo esc_attr($country); ?>" name="country">
93
+    <input type="hidden" value="<?php echo esc_attr($desc); ?>" name="desc">
94
+    <?php foreach ($extra_params as $param => $value) { ?>
95
+        <?php if (!empty($value !== false)) { ?>
96
+    <input type="hidden" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($param); ?>">
97 97
         <?php } ?>
98 98
     <?php } ?>
99
-    <?php do_action( 'wpinv_worldpay_form_parameters', $invoice ); ?>
100
-    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e( 'Pay by Debit/Credit Card (WorldPay)', 'invoicing' ) ;?>">
99
+    <?php do_action('wpinv_worldpay_form_parameters', $invoice); ?>
100
+    <input type="submit" name="wpi_worldpay_submit" value="<?php esc_attr_e('Pay by Debit/Credit Card (WorldPay)', 'invoicing'); ?>">
101 101
 </form>
102 102
 <script type="text/javascript">document.wpi_worldpay_form.submit();</script>
103
-<?php do_action( 'wpinv_worldpay_form_after', $invoice ); ?>
103
+<?php do_action('wpinv_worldpay_form_after', $invoice); ?>
104 104
 </div>
105 105
         <?php
106 106
     } else {
107
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
107
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a worldpay payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
108 108
         // If errors are present, send the user back to the purchase page so they can be corrected
109
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
109
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
110 110
     }
111 111
 }
112
-add_action( 'wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment' );
112
+add_action('wpinv_gateway_worldpay', 'wpinv_process_worldpay_payment');
113 113
 
114 114
 function wpinv_get_worldpay_redirect() {
115
-    $redirect = wpinv_is_test_mode( 'worldpay' ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
115
+    $redirect = wpinv_is_test_mode('worldpay') ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
116 116
     
117
-    return apply_filters( 'wpinv_worldpay_redirect', $redirect );
117
+    return apply_filters('wpinv_worldpay_redirect', $redirect);
118 118
 }
119 119
 
120 120
 function wpinv_process_worldpay_ipn() {
121
-    $request = wpinv_get_post_data( 'post' );
121
+    $request = wpinv_get_post_data('post');
122 122
     
123
-    if ( !empty( $request['cartId'] ) && !empty( $request['transStatus'] ) && !empty( $request['installation'] ) && isset( $request['testMode'] ) && isset( $request['MC_invoice_id'] ) && isset( $request['MC_key'] ) ) {
123
+    if (!empty($request['cartId']) && !empty($request['transStatus']) && !empty($request['installation']) && isset($request['testMode']) && isset($request['MC_invoice_id']) && isset($request['MC_key'])) {
124 124
         $invoice_id = $request['MC_invoice_id'];
125 125
         
126
-        if ( $invoice_id == wpinv_get_invoice_id_by_key( $request['MC_key'] ) && $invoice = wpinv_get_invoice( $invoice_id ) ) {
127
-            if ( $request['transStatus'] == 'Y' ) {                
128
-                wpinv_update_payment_status( $invoice_id, 'publish' );
129
-                wpinv_set_payment_transaction_id( $invoice_id, $request['transId'] );
130
-                wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Worldpay Transaction ID: %s', 'invoicing' ), $request['transId'] ) );
126
+        if ($invoice_id == wpinv_get_invoice_id_by_key($request['MC_key']) && $invoice = wpinv_get_invoice($invoice_id)) {
127
+            if ($request['transStatus'] == 'Y') {                
128
+                wpinv_update_payment_status($invoice_id, 'publish');
129
+                wpinv_set_payment_transaction_id($invoice_id, $request['transId']);
130
+                wpinv_insert_payment_note($invoice_id, sprintf(__('Worldpay Transaction ID: %s', 'invoicing'), $request['transId']));
131 131
                 return;
132
-            } else if ( $request['transStatus'] == 'C' ) {
133
-                wpinv_update_payment_status( $invoice_id, 'failed' );
134
-                wpinv_insert_payment_note( $invoice_id, __( 'Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing' ) );
132
+            } else if ($request['transStatus'] == 'C') {
133
+                wpinv_update_payment_status($invoice_id, 'failed');
134
+                wpinv_insert_payment_note($invoice_id, __('Payment transaction failed while processing Worldpay payment, kindly check IPN log.', 'invoicing'));
135 135
                 
136
-                wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing' ), json_encode( $request ) ), $invoice_id );
136
+                wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Payment transaction failed while processing Worldpay payment. IPN data: %s', 'invoicing'), json_encode($request)), $invoice_id);
137 137
                 return;
138 138
             }
139 139
         }
140 140
     }
141 141
     return;
142 142
 }
143
-add_action( 'wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn' );
144 143
\ No newline at end of file
144
+add_action('wpinv_verify_worldpay_ipn', 'wpinv_process_worldpay_ipn');
145 145
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 	public function __construct($login, $transkey, $test = self::USE_PRODUCTION_SERVER)
52 52
 	{
53
-		$login    = trim($login);
53
+		$login = trim($login);
54 54
         $transkey = trim($transkey);
55 55
         if (empty($login) || empty($transkey))
56 56
         {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
         $this->login    = trim($login);
61 61
         $this->transkey = trim($transkey);
62
-        $test           = (bool) $test;
62
+        $test           = (bool)$test;
63 63
 
64 64
         $subdomain = ($test) ? 'apitest' : 'api';
65 65
         $this->url = 'https://' . $subdomain . '.authorize.net/xml/v1/request.api';
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
     private function removeResponseXMLNS($input)
74 74
     {
75 75
         // why remove them one at a time? all three aren't consistantly used in the response
76
-        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"','',$input);
77
-        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"','',$input);
78
-        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"','',$input);
76
+        $input = str_replace(' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $input);
77
+        $input = str_replace(' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', '', $input);
78
+        return str_replace(' xmlns:xsd="http://www.w3.org/2001/XMLSchema"', '', $input);
79 79
     }
80 80
 
81 81
 	public function __toString()
82 82
 	{
83
-	    $output  = '';
83
+	    $output = '';
84 84
         $output .= '<table summary="Authorize.Net Results" id="authnet">' . "\n";
85 85
         $output .= '<tr>' . "\n\t\t" . '<th colspan="2"><b>Class Parameters</b></th>' . "\n" . '</tr>' . "\n";
86 86
         $output .= '<tr>' . "\n\t\t" . '<td><b>API Login ID</b></td><td>' . $this->login . '</td>' . "\n" . '</tr>' . "\n";
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
             {
160 160
                 if (is_array($value))
161 161
                 {
162
-                    if(is_numeric($key))
162
+                    if (is_numeric($key))
163 163
                     {
164
-                        if($first === true)
164
+                        if ($first === true)
165 165
                         {
166 166
                             $xmlx  = $xml;
167 167
                             $first = false;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
     	curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 2);
201 201
     	curl_setopt($this->ch, CURLOPT_CAINFO, dirname(__FILE__) . '/ssl/cert.pem');
202 202
 
203
-        if(($this->response = curl_exec($this->ch)) !== false)
203
+        if (($this->response = curl_exec($this->ch)) !== false)
204 204
         {
205 205
             $this->response_xml = @new SimpleXMLElement($this->response);
206 206
 
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetAIM.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
      * A list of all fields in the AIM API.
78 78
      * Used to warn user if they try to set a field not offered in the API.
79 79
      */
80
-    private $_all_aim_fields = array("address","allow_partial_auth","amount",
81
-        "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name",
82
-        "bank_acct_num","bank_acct_type","bank_check_number","bank_name",
83
-        "card_code","card_num","cardholder_authentication_value","city","company",
84
-        "country","cust_id","customer_ip","delim_char","delim_data","description",
85
-        "duplicate_window","duty","echeck_type","email","email_customer",
86
-        "encap_char","exp_date","fax","first_name","footer_email_receipt",
87
-        "freight","header_email_receipt","invoice_num","last_name","line_item",
88
-        "login","method","phone","po_num","recurring_billing","relay_response",
89
-        "ship_to_address","ship_to_city","ship_to_company","ship_to_country",
90
-        "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip",
91
-        "split_tender_id","state","tax","tax_exempt","test_request","tran_key",
92
-        "trans_id","type","version","zip"
80
+    private $_all_aim_fields = array("address", "allow_partial_auth", "amount",
81
+        "auth_code", "authentication_indicator", "bank_aba_code", "bank_acct_name",
82
+        "bank_acct_num", "bank_acct_type", "bank_check_number", "bank_name",
83
+        "card_code", "card_num", "cardholder_authentication_value", "city", "company",
84
+        "country", "cust_id", "customer_ip", "delim_char", "delim_data", "description",
85
+        "duplicate_window", "duty", "echeck_type", "email", "email_customer",
86
+        "encap_char", "exp_date", "fax", "first_name", "footer_email_receipt",
87
+        "freight", "header_email_receipt", "invoice_num", "last_name", "line_item",
88
+        "login", "method", "phone", "po_num", "recurring_billing", "relay_response",
89
+        "ship_to_address", "ship_to_city", "ship_to_company", "ship_to_country",
90
+        "ship_to_first_name", "ship_to_last_name", "ship_to_state", "ship_to_zip",
91
+        "split_tender_id", "state", "tax", "tax_exempt", "test_request", "tran_key",
92
+        "trans_id", "type", "version", "zip"
93 93
         );
94 94
     
95 95
     /**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
             // Split Array
404 404
             $this->response = $response;
405 405
             if ($encap_char) {
406
-                $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
406
+                $this->_response_array = explode($encap_char . $delimiter . $encap_char, substr($response, 1, -1));
407 407
             } else {
408 408
                 $this->_response_array = explode($delimiter, $response);
409 409
             }
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
             $this->duty                 = $this->_response_array[33];
458 458
             $this->freight              = $this->_response_array[34];
459 459
             $this->tax_exempt           = $this->_response_array[35];
460
-            $this->purchase_order_number= $this->_response_array[36];
460
+            $this->purchase_order_number = $this->_response_array[36];
461 461
             $this->md5_hash             = $this->_response_array[37];
462 462
             $this->card_code_response   = $this->_response_array[38];
463 463
             $this->cavv_response        = $this->_response_array[39];
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
             
485 485
             if ($this->error) {
486 486
                 $this->error_message = "AuthorizeNet Error:
487
-                Response Code: ".$this->response_code."
488
-                Response Subcode: ".$this->response_subcode."
489
-                Response Reason Code: ".$this->response_reason_code."
490
-                Response Reason Text: ".$this->response_reason_text."
487
+                Response Code: ".$this->response_code . "
488
+                Response Subcode: ".$this->response_subcode . "
489
+                Response Reason Code: ".$this->response_reason_code . "
490
+                Response Reason Text: ".$this->response_reason_text . "
491 491
                 ";
492 492
             }
493 493
         } else {
Please login to merge, or discard this patch.
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetRequest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
             curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
97 97
         }
98 98
         
99
-        if (preg_match('/xml/',$post_url)) {
99
+        if (preg_match('/xml/', $post_url)) {
100 100
             curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
101 101
         }
102 102
         
Please login to merge, or discard this patch.
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetXMLResponse.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
             $this->xml = @simplexml_load_string($response);
30 30
             
31 31
             // Remove namespaces for use with XPath.
32
-            $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/','',$response));
32
+            $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/', '', $response));
33 33
         }
34 34
     }
35 35
     
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
     {
117 117
         $start = "<$elementName>";
118 118
         $end = "</$elementName>";
119
-        if (strpos($this->response,$start) === false || strpos($this->response,$end) === false) {
119
+        if (strpos($this->response, $start) === false || strpos($this->response, $end) === false) {
120 120
             return false;
121 121
         } else {
122
-            $start_position = strpos($this->response, $start)+strlen($start);
122
+            $start_position = strpos($this->response, $start) + strlen($start);
123 123
             $end_position = strpos($this->response, $end);
124
-            return substr($this->response, $start_position, $end_position-$start_position);
124
+            return substr($this->response, $start_position, $end_position - $start_position);
125 125
         }
126 126
     }
127 127
 
Please login to merge, or discard this patch.