Passed
Push — master ( 258987...abdd42 )
by Brian
11:44 queued 05:35
created
includes/wpinv-email-functions.php 1 patch
Spacing   +449 added lines, -449 removed lines patch added patch discarded remove patch
@@ -4,47 +4,47 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 // Backwards compatibility.
10 10
 function wpinv_init_transactional_emails() {
11
-    foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) {
12
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
11
+    foreach (apply_filters('wpinv_email_actions', array()) as $action) {
12
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
13 13
     }
14 14
 }
15
-add_action( 'init', 'wpinv_init_transactional_emails' );
15
+add_action('init', 'wpinv_init_transactional_emails');
16 16
 
17
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
18
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
19
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
20
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
21
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
17
+add_action('wpinv_email_header', 'wpinv_email_header');
18
+add_action('wpinv_email_footer', 'wpinv_email_footer');
19
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
20
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
21
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
22 22
 
23 23
 function wpinv_send_transactional_email() {
24 24
     $args       = func_get_args();
25 25
     $function   = current_filter() . '_notification';
26
-    do_action_ref_array( $function, $args );
26
+    do_action_ref_array($function, $args);
27 27
 }
28 28
 
29 29
 function wpinv_mail_get_from_address() {
30
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
31
-    return sanitize_email( $from_address );
30
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
31
+    return sanitize_email($from_address);
32 32
 }
33 33
 
34 34
 function wpinv_mail_get_from_name() {
35
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
36
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
35
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
36
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
37 37
 }
38 38
 
39
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
40
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
41
-    return ( $active ? true : false );
39
+function wpinv_mail_admin_bcc_active($mail_type = '') {
40
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
41
+    return ($active ? true : false);
42 42
 }
43 43
     
44
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
45
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
44
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
45
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
46 46
 
47
-    switch ( $email_type ) {
47
+    switch ($email_type) {
48 48
         case 'html' :
49 49
             $content_type = 'text/html';
50 50
             break;
@@ -59,43 +59,43 @@  discard block
 block discarded – undo
59 59
     return $content_type;
60 60
 }
61 61
     
62
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments, $cc = array() ) {
63
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
64
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
65
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
62
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments, $cc = array()) {
63
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
64
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
65
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
66 66
 
67
-    $message = wpinv_email_style_body( $message );
68
-    $message = apply_filters( 'wpinv_mail_content', $message );
67
+    $message = wpinv_email_style_body($message);
68
+    $message = apply_filters('wpinv_mail_content', $message);
69 69
 
70
-    if ( ! empty( $cc ) && is_array( $cc ) ) {
71
-        if ( ! is_array( $to ) ) {
72
-            $to = array( $to );
70
+    if (!empty($cc) && is_array($cc)) {
71
+        if (!is_array($to)) {
72
+            $to = array($to);
73 73
         }
74 74
 
75
-        $to = array_unique( array_merge( $to, $cc ) );
75
+        $to = array_unique(array_merge($to, $cc));
76 76
     }
77 77
 
78
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
78
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
79 79
 
80
-    if ( !$sent ) {
81
-        $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 );
82
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
80
+    if (!$sent) {
81
+        $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);
82
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
83 83
     }
84 84
 
85
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
86
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
87
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
85
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
86
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
87
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
88 88
 
89 89
     return $sent;
90 90
 }
91 91
     
92 92
 function wpinv_get_emails() {
93 93
     $overdue_days_options       = array();
94
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
95
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
94
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
95
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
96 96
 
97
-    for ( $i = 2; $i <= 10; $i++ ) {
98
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
97
+    for ($i = 2; $i <= 10; $i++) {
98
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
99 99
     }
100 100
 
101 101
     // Default, built-in gateways
@@ -103,39 +103,39 @@  discard block
 block discarded – undo
103 103
             'new_invoice' => array(
104 104
             'email_new_invoice_header' => array(
105 105
                 'id'   => 'email_new_invoice_header',
106
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
107
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
106
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
107
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
108 108
                 'type' => 'header',
109 109
             ),
110 110
             'email_new_invoice_active' => array(
111 111
                 'id'   => 'email_new_invoice_active',
112
-                'name' => __( 'Enable/Disable', 'invoicing' ),
113
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
112
+                'name' => __('Enable/Disable', 'invoicing'),
113
+                'desc' => __('Enable this email notification', 'invoicing'),
114 114
                 'type' => 'checkbox',
115 115
                 'std'  => 1
116 116
             ),
117 117
             'email_new_invoice_subject' => array(
118 118
                 'id'   => 'email_new_invoice_subject',
119
-                'name' => __( 'Subject', 'invoicing' ),
120
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
119
+                'name' => __('Subject', 'invoicing'),
120
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
121 121
                 'type' => 'text',
122
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
122
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
123 123
                 'size' => 'large'
124 124
             ),
125 125
             'email_new_invoice_heading' => array(
126 126
                 'id'   => 'email_new_invoice_heading',
127
-                'name' => __( 'Email Heading', 'invoicing' ),
128
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
127
+                'name' => __('Email Heading', 'invoicing'),
128
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
129 129
                 'type' => 'text',
130
-                'std'  => __( 'New payment invoice', 'invoicing' ),
130
+                'std'  => __('New payment invoice', 'invoicing'),
131 131
                 'size' => 'large'
132 132
             ),
133 133
             'email_new_invoice_body' => array(
134 134
                 'id'   => 'email_new_invoice_body',
135
-                'name' => __( 'Email Content', 'invoicing' ),
136
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
135
+                'name' => __('Email Content', 'invoicing'),
136
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
137 137
                 'type' => 'rich_editor',
138
-                'std'  => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
138
+                'std'  => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
139 139
                 'class' => 'large',
140 140
                 'size' => '10'
141 141
             ),
@@ -143,39 +143,39 @@  discard block
 block discarded – undo
143 143
         'cancelled_invoice' => array(
144 144
             'email_cancelled_invoice_header' => array(
145 145
                 'id'   => 'email_cancelled_invoice_header',
146
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
147
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
146
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
147
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
148 148
                 'type' => 'header',
149 149
             ),
150 150
             'email_cancelled_invoice_active' => array(
151 151
                 'id'   => 'email_cancelled_invoice_active',
152
-                'name' => __( 'Enable/Disable', 'invoicing' ),
153
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
152
+                'name' => __('Enable/Disable', 'invoicing'),
153
+                'desc' => __('Enable this email notification', 'invoicing'),
154 154
                 'type' => 'checkbox',
155 155
                 'std'  => 1
156 156
             ),
157 157
             'email_cancelled_invoice_subject' => array(
158 158
                 'id'   => 'email_cancelled_invoice_subject',
159
-                'name' => __( 'Subject', 'invoicing' ),
160
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
159
+                'name' => __('Subject', 'invoicing'),
160
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
161 161
                 'type' => 'text',
162
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
162
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
163 163
                 'size' => 'large'
164 164
             ),
165 165
             'email_cancelled_invoice_heading' => array(
166 166
                 'id'   => 'email_cancelled_invoice_heading',
167
-                'name' => __( 'Email Heading', 'invoicing' ),
168
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
167
+                'name' => __('Email Heading', 'invoicing'),
168
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
169 169
                 'type' => 'text',
170
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
170
+                'std'  => __('Cancelled invoice', 'invoicing'),
171 171
                 'size' => 'large'
172 172
             ),
173 173
             'email_cancelled_invoice_body' => array(
174 174
                 'id'   => 'email_cancelled_invoice_body',
175
-                'name' => __( 'Email Content', 'invoicing' ),
176
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
175
+                'name' => __('Email Content', 'invoicing'),
176
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
177 177
                 'type' => 'rich_editor',
178
-                'std'  => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
178
+                'std'  => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
179 179
                 'class' => 'large',
180 180
                 'size' => '10'
181 181
             ),
@@ -183,39 +183,39 @@  discard block
 block discarded – undo
183 183
         'failed_invoice' => array(
184 184
             'email_failed_invoice_header' => array(
185 185
                 'id'   => 'email_failed_invoice_header',
186
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
187
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
186
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
187
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
188 188
                 'type' => 'header',
189 189
             ),
190 190
             'email_failed_invoice_active' => array(
191 191
                 'id'   => 'email_failed_invoice_active',
192
-                'name' => __( 'Enable/Disable', 'invoicing' ),
193
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
192
+                'name' => __('Enable/Disable', 'invoicing'),
193
+                'desc' => __('Enable this email notification', 'invoicing'),
194 194
                 'type' => 'checkbox',
195 195
                 'std'  => 1
196 196
             ),
197 197
             'email_failed_invoice_subject' => array(
198 198
                 'id'   => 'email_failed_invoice_subject',
199
-                'name' => __( 'Subject', 'invoicing' ),
200
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
199
+                'name' => __('Subject', 'invoicing'),
200
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
201 201
                 'type' => 'text',
202
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
202
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
203 203
                 'size' => 'large'
204 204
             ),
205 205
             'email_failed_invoice_heading' => array(
206 206
                 'id'   => 'email_failed_invoice_heading',
207
-                'name' => __( 'Email Heading', 'invoicing' ),
208
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
207
+                'name' => __('Email Heading', 'invoicing'),
208
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
209 209
                 'type' => 'text',
210
-                'std'  => __( 'Failed invoice', 'invoicing' ),
210
+                'std'  => __('Failed invoice', 'invoicing'),
211 211
                 'size' => 'large'
212 212
             ),
213 213
             'email_failed_invoice_body' => array(
214 214
                 'id'   => 'email_failed_invoice_body',
215
-                'name' => __( 'Email Content', 'invoicing' ),
216
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
215
+                'name' => __('Email Content', 'invoicing'),
216
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
217 217
                 'type' => 'rich_editor',
218
-                'std'  => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
218
+                'std'  => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
219 219
                 'class' => 'large',
220 220
                 'size' => '10'
221 221
             ),
@@ -223,46 +223,46 @@  discard block
 block discarded – undo
223 223
         'onhold_invoice' => array(
224 224
             'email_onhold_invoice_header' => array(
225 225
                 'id'   => 'email_onhold_invoice_header',
226
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
227
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
226
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
227
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
228 228
                 'type' => 'header',
229 229
             ),
230 230
             'email_onhold_invoice_active' => array(
231 231
                 'id'   => 'email_onhold_invoice_active',
232
-                'name' => __( 'Enable/Disable', 'invoicing' ),
233
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
232
+                'name' => __('Enable/Disable', 'invoicing'),
233
+                'desc' => __('Enable this email notification', 'invoicing'),
234 234
                 'type' => 'checkbox',
235 235
                 'std'  => 1
236 236
             ),
237 237
             'email_onhold_invoice_subject' => array(
238 238
                 'id'   => 'email_onhold_invoice_subject',
239
-                'name' => __( 'Subject', 'invoicing' ),
240
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
239
+                'name' => __('Subject', 'invoicing'),
240
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
241 241
                 'type' => 'text',
242
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
242
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
243 243
                 'size' => 'large'
244 244
             ),
245 245
             'email_onhold_invoice_heading' => array(
246 246
                 'id'   => 'email_onhold_invoice_heading',
247
-                'name' => __( 'Email Heading', 'invoicing' ),
248
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
247
+                'name' => __('Email Heading', 'invoicing'),
248
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
249 249
                 'type' => 'text',
250
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
250
+                'std'  => __('Thank you for your invoice', 'invoicing'),
251 251
                 'size' => 'large'
252 252
             ),
253 253
             'email_onhold_invoice_admin_bcc' => array(
254 254
                 'id'   => 'email_onhold_invoice_admin_bcc',
255
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
256
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
255
+                'name' => __('Enable Admin BCC', 'invoicing'),
256
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
257 257
                 'type' => 'checkbox',
258 258
                 'std'  => 1
259 259
             ),
260 260
             'email_onhold_invoice_body' => array(
261 261
                 'id'   => 'email_onhold_invoice_body',
262
-                'name' => __( 'Email Content', 'invoicing' ),
263
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
262
+                'name' => __('Email Content', 'invoicing'),
263
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
264 264
                 'type' => 'rich_editor',
265
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
265
+                'std'  => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
266 266
                 'class' => 'large',
267 267
                 'size' => '10'
268 268
             ),
@@ -270,46 +270,46 @@  discard block
 block discarded – undo
270 270
         'processing_invoice' => array(
271 271
             'email_processing_invoice_header' => array(
272 272
                 'id'   => 'email_processing_invoice_header',
273
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
274
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
273
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
274
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
275 275
                 'type' => 'header',
276 276
             ),
277 277
             'email_processing_invoice_active' => array(
278 278
                 'id'   => 'email_processing_invoice_active',
279
-                'name' => __( 'Enable/Disable', 'invoicing' ),
280
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
279
+                'name' => __('Enable/Disable', 'invoicing'),
280
+                'desc' => __('Enable this email notification', 'invoicing'),
281 281
                 'type' => 'checkbox',
282 282
                 'std'  => 1
283 283
             ),
284 284
             'email_processing_invoice_subject' => array(
285 285
                 'id'   => 'email_processing_invoice_subject',
286
-                'name' => __( 'Subject', 'invoicing' ),
287
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
286
+                'name' => __('Subject', 'invoicing'),
287
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
288 288
                 'type' => 'text',
289
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
289
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
290 290
                 'size' => 'large'
291 291
             ),
292 292
             'email_processing_invoice_heading' => array(
293 293
                 'id'   => 'email_processing_invoice_heading',
294
-                'name' => __( 'Email Heading', 'invoicing' ),
295
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
294
+                'name' => __('Email Heading', 'invoicing'),
295
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
296 296
                 'type' => 'text',
297
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
297
+                'std'  => __('Thank you for your invoice', 'invoicing'),
298 298
                 'size' => 'large'
299 299
             ),
300 300
             'email_processing_invoice_admin_bcc' => array(
301 301
                 'id'   => 'email_processing_invoice_admin_bcc',
302
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
303
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
302
+                'name' => __('Enable Admin BCC', 'invoicing'),
303
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
304 304
                 'type' => 'checkbox',
305 305
                 'std'  => 1
306 306
             ),
307 307
             'email_processing_invoice_body' => array(
308 308
                 'id'   => 'email_processing_invoice_body',
309
-                'name' => __( 'Email Content', 'invoicing' ),
310
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
309
+                'name' => __('Email Content', 'invoicing'),
310
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
311 311
                 'type' => 'rich_editor',
312
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
312
+                'std'  => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
313 313
                 'class' => 'large',
314 314
                 'size' => '10'
315 315
             ),
@@ -317,52 +317,52 @@  discard block
 block discarded – undo
317 317
         'completed_invoice' => array(
318 318
             'email_completed_invoice_header' => array(
319 319
                 'id'   => 'email_completed_invoice_header',
320
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
321
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
320
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
321
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
322 322
                 'type' => 'header',
323 323
             ),
324 324
             'email_completed_invoice_active' => array(
325 325
                 'id'   => 'email_completed_invoice_active',
326
-                'name' => __( 'Enable/Disable', 'invoicing' ),
327
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
326
+                'name' => __('Enable/Disable', 'invoicing'),
327
+                'desc' => __('Enable this email notification', 'invoicing'),
328 328
                 'type' => 'checkbox',
329 329
                 'std'  => 1
330 330
             ),
331 331
             'email_completed_invoice_renewal_active' => array(
332 332
                 'id'   => 'email_completed_invoice_renewal_active',
333
-                'name' => __( 'Enable renewal notification', 'invoicing' ),
334
-                'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ),
333
+                'name' => __('Enable renewal notification', 'invoicing'),
334
+                'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'),
335 335
                 'type' => 'checkbox',
336 336
                 'std'  => 0
337 337
             ),
338 338
             'email_completed_invoice_subject' => array(
339 339
                 'id'   => 'email_completed_invoice_subject',
340
-                'name' => __( 'Subject', 'invoicing' ),
341
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
340
+                'name' => __('Subject', 'invoicing'),
341
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
342 342
                 'type' => 'text',
343
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
343
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
344 344
                 'size' => 'large'
345 345
             ),
346 346
             'email_completed_invoice_heading' => array(
347 347
                 'id'   => 'email_completed_invoice_heading',
348
-                'name' => __( 'Email Heading', 'invoicing' ),
349
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
348
+                'name' => __('Email Heading', 'invoicing'),
349
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
350 350
                 'type' => 'text',
351
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
351
+                'std'  => __('Your invoice has been paid', 'invoicing'),
352 352
                 'size' => 'large'
353 353
             ),
354 354
             'email_completed_invoice_admin_bcc' => array(
355 355
                 'id'   => 'email_completed_invoice_admin_bcc',
356
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
357
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
356
+                'name' => __('Enable Admin BCC', 'invoicing'),
357
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
358 358
                 'type' => 'checkbox',
359 359
             ),
360 360
             'email_completed_invoice_body' => array(
361 361
                 'id'   => 'email_completed_invoice_body',
362
-                'name' => __( 'Email Content', 'invoicing' ),
363
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
362
+                'name' => __('Email Content', 'invoicing'),
363
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
364 364
                 'type' => 'rich_editor',
365
-                'std'  => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
365
+                'std'  => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
366 366
                 'class' => 'large',
367 367
                 'size' => '10'
368 368
             ),
@@ -371,46 +371,46 @@  discard block
 block discarded – undo
371 371
         'refunded_invoice' => array(
372 372
             'email_refunded_invoice_header' => array(
373 373
                 'id'   => 'email_refunded_invoice_header',
374
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
375
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
374
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
375
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
376 376
                 'type' => 'header',
377 377
             ),
378 378
             'email_refunded_invoice_active' => array(
379 379
                 'id'   => 'email_refunded_invoice_active',
380
-                'name' => __( 'Enable/Disable', 'invoicing' ),
381
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
380
+                'name' => __('Enable/Disable', 'invoicing'),
381
+                'desc' => __('Enable this email notification', 'invoicing'),
382 382
                 'type' => 'checkbox',
383 383
                 'std'  => 1
384 384
             ),
385 385
             'email_refunded_invoice_subject' => array(
386 386
                 'id'   => 'email_refunded_invoice_subject',
387
-                'name' => __( 'Subject', 'invoicing' ),
388
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
387
+                'name' => __('Subject', 'invoicing'),
388
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
389 389
                 'type' => 'text',
390
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
390
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
391 391
                 'size' => 'large'
392 392
             ),
393 393
             'email_refunded_invoice_heading' => array(
394 394
                 'id'   => 'email_refunded_invoice_heading',
395
-                'name' => __( 'Email Heading', 'invoicing' ),
396
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
395
+                'name' => __('Email Heading', 'invoicing'),
396
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
397 397
                 'type' => 'text',
398
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
398
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
399 399
                 'size' => 'large'
400 400
             ),
401 401
             'email_refunded_invoice_admin_bcc' => array(
402 402
                 'id'   => 'email_refunded_invoice_admin_bcc',
403
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
404
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
403
+                'name' => __('Enable Admin BCC', 'invoicing'),
404
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
405 405
                 'type' => 'checkbox',
406 406
                 'std'  => 1
407 407
             ),
408 408
             'email_refunded_invoice_body' => array(
409 409
                 'id'   => 'email_refunded_invoice_body',
410
-                'name' => __( 'Email Content', 'invoicing' ),
411
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
410
+                'name' => __('Email Content', 'invoicing'),
411
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
412 412
                 'type' => 'rich_editor',
413
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
413
+                'std'  => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
414 414
                 'class' => 'large',
415 415
                 'size' => '10'
416 416
             ),
@@ -418,46 +418,46 @@  discard block
 block discarded – undo
418 418
         'user_invoice' => array(
419 419
             'email_user_invoice_header' => array(
420 420
                 'id'   => 'email_user_invoice_header',
421
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
422
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
421
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
422
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
423 423
                 'type' => 'header',
424 424
             ),
425 425
             'email_user_invoice_active' => array(
426 426
                 'id'   => 'email_user_invoice_active',
427
-                'name' => __( 'Enable/Disable', 'invoicing' ),
428
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
427
+                'name' => __('Enable/Disable', 'invoicing'),
428
+                'desc' => __('Enable this email notification', 'invoicing'),
429 429
                 'type' => 'checkbox',
430 430
                 'std'  => 1
431 431
             ),
432 432
             'email_user_invoice_subject' => array(
433 433
                 'id'   => 'email_user_invoice_subject',
434
-                'name' => __( 'Subject', 'invoicing' ),
435
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
434
+                'name' => __('Subject', 'invoicing'),
435
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
436 436
                 'type' => 'text',
437
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
437
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
438 438
                 'size' => 'large'
439 439
             ),
440 440
             'email_user_invoice_heading' => array(
441 441
                 'id'   => 'email_user_invoice_heading',
442
-                'name' => __( 'Email Heading', 'invoicing' ),
443
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
442
+                'name' => __('Email Heading', 'invoicing'),
443
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
444 444
                 'type' => 'text',
445
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
445
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
446 446
                 'size' => 'large'
447 447
             ),
448 448
             'email_user_invoice_admin_bcc' => array(
449 449
                 'id'   => 'email_user_invoice_admin_bcc',
450
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
451
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
450
+                'name' => __('Enable Admin BCC', 'invoicing'),
451
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
452 452
                 'type' => 'checkbox',
453 453
                 'std'  => 1
454 454
             ),
455 455
             'email_user_invoice_body' => array(
456 456
                 'id'   => 'email_user_invoice_body',
457
-                'name' => __( 'Email Content', 'invoicing' ),
458
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
457
+                'name' => __('Email Content', 'invoicing'),
458
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
459 459
                 'type' => 'rich_editor',
460
-                'std'  => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
460
+                'std'  => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
461 461
                 'class' => 'large',
462 462
                 'size' => '10'
463 463
             ),
@@ -465,39 +465,39 @@  discard block
 block discarded – undo
465 465
         'user_note' => array(
466 466
             'email_user_note_header' => array(
467 467
                 'id'   => 'email_user_note_header',
468
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
469
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
468
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
469
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
470 470
                 'type' => 'header',
471 471
             ),
472 472
             'email_user_note_active' => array(
473 473
                 'id'   => 'email_user_note_active',
474
-                'name' => __( 'Enable/Disable', 'invoicing' ),
475
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
474
+                'name' => __('Enable/Disable', 'invoicing'),
475
+                'desc' => __('Enable this email notification', 'invoicing'),
476 476
                 'type' => 'checkbox',
477 477
                 'std'  => 1
478 478
             ),
479 479
             'email_user_note_subject' => array(
480 480
                 'id'   => 'email_user_note_subject',
481
-                'name' => __( 'Subject', 'invoicing' ),
482
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
481
+                'name' => __('Subject', 'invoicing'),
482
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
483 483
                 'type' => 'text',
484
-                'std'  => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
484
+                'std'  => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
485 485
                 'size' => 'large'
486 486
             ),
487 487
             'email_user_note_heading' => array(
488 488
                 'id'   => 'email_user_note_heading',
489
-                'name' => __( 'Email Heading', 'invoicing' ),
490
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
489
+                'name' => __('Email Heading', 'invoicing'),
490
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
491 491
                 'type' => 'text',
492
-                'std'  => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
492
+                'std'  => __('A note has been added to your {invoice_label}', 'invoicing'),
493 493
                 'size' => 'large'
494 494
             ),
495 495
             'email_user_note_body' => array(
496 496
                 'id'   => 'email_user_note_body',
497
-                'name' => __( 'Email Content', 'invoicing' ),
498
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
497
+                'name' => __('Email Content', 'invoicing'),
498
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
499 499
                 'type' => 'rich_editor',
500
-                'std'  => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
500
+                'std'  => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
501 501
                 'class' => 'large',
502 502
                 'size' => '10'
503 503
             ),
@@ -506,54 +506,54 @@  discard block
 block discarded – undo
506 506
         'pre_payment' => array(
507 507
             'email_pre_payment_header' => array(
508 508
                 'id'   => 'email_pre_payment_header',
509
-                'name' => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>',
510
-                'desc' => __( 'Renewal reminder emails are sent to user automatically.', 'invoicing' ),
509
+                'name' => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>',
510
+                'desc' => __('Renewal reminder emails are sent to user automatically.', 'invoicing'),
511 511
                 'type' => 'header',
512 512
             ),
513 513
             'email_pre_payment_active' => array(
514 514
                 'id'   => 'email_pre_payment_active',
515
-                'name' => __( 'Enable/Disable', 'invoicing' ),
516
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
515
+                'name' => __('Enable/Disable', 'invoicing'),
516
+                'desc' => __('Enable this email notification', 'invoicing'),
517 517
                 'type' => 'checkbox',
518 518
                 'std'  => 1
519 519
             ),
520 520
             'email_pre_payment_reminder_days' => array(
521 521
                 'id'            => 'email_pre_payment_reminder_days',
522
-                'name'          => __( 'When to Send', 'invoicing' ),
523
-                'desc'          => __( 'Enter a comma separated list of days before renewal when this email should be sent.', 'invoicing' ),
522
+                'name'          => __('When to Send', 'invoicing'),
523
+                'desc'          => __('Enter a comma separated list of days before renewal when this email should be sent.', 'invoicing'),
524 524
                 'default'       => '',
525 525
                 'type'          => 'text',
526 526
                 'std'           => '1,5,10',
527 527
             ),
528 528
             'email_pre_payment_subject' => array(
529 529
                 'id'   => 'email_pre_payment_subject',
530
-                'name' => __( 'Subject', 'invoicing' ),
531
-                'desc' => __( 'Enter the subject line for the email.', 'invoicing' ),
530
+                'name' => __('Subject', 'invoicing'),
531
+                'desc' => __('Enter the subject line for the email.', 'invoicing'),
532 532
                 'type' => 'text',
533
-                'std'  => __( '[{site_title}] Renewal Reminder', 'invoicing' ),
533
+                'std'  => __('[{site_title}] Renewal Reminder', 'invoicing'),
534 534
                 'size' => 'large'
535 535
             ),
536 536
             'email_pre_payment_heading' => array(
537 537
                 'id'   => 'email_pre_payment_heading',
538
-                'name' => __( 'Email Heading', 'invoicing' ),
539
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
538
+                'name' => __('Email Heading', 'invoicing'),
539
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
540 540
                 'type' => 'text',
541
-                'std'  => __( 'Upcoming renewal reminder', 'invoicing' ),
541
+                'std'  => __('Upcoming renewal reminder', 'invoicing'),
542 542
                 'size' => 'large'
543 543
             ),
544 544
             'email_pre_payment_admin_bcc' => array(
545 545
                 'id'   => 'email_pre_payment_admin_bcc',
546
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
547
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
546
+                'name' => __('Enable Admin BCC', 'invoicing'),
547
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
548 548
                 'type' => 'checkbox',
549 549
                 'std'  => 1
550 550
             ),
551 551
             'email_pre_payment_body' => array(
552 552
                 'id'   => 'email_pre_payment_body',
553
-                'name' => __( 'Email Content', 'invoicing' ),
554
-                'desc' => __( 'The content of the email.', 'invoicing' ),
553
+                'name' => __('Email Content', 'invoicing'),
554
+                'desc' => __('The content of the email.', 'invoicing'),
555 555
                 'type' => 'rich_editor',
556
-                'std'  => __( '<p>Hi {full_name},</p><p>Your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ),
556
+                'std'  => __('<p>Hi {full_name},</p><p>Your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'),
557 557
                 'class' => 'large',
558 558
                 'size'  => 10,
559 559
             ),
@@ -562,54 +562,54 @@  discard block
 block discarded – undo
562 562
         'overdue' => array(
563 563
             'email_overdue_header' => array(
564 564
                 'id'   => 'email_overdue_header',
565
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
566
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
565
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
566
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
567 567
                 'type' => 'header',
568 568
             ),
569 569
             'email_overdue_active' => array(
570 570
                 'id'   => 'email_overdue_active',
571
-                'name' => __( 'Enable/Disable', 'invoicing' ),
572
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
571
+                'name' => __('Enable/Disable', 'invoicing'),
572
+                'desc' => __('Enable this email notification', 'invoicing'),
573 573
                 'type' => 'checkbox',
574 574
                 'std'  => 1
575 575
             ),
576 576
             'email_due_reminder_days' => array(
577 577
                 'id'        => 'email_due_reminder_days',
578
-                'name'      => __( 'When to Send', 'invoicing' ),
579
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
578
+                'name'      => __('When to Send', 'invoicing'),
579
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
580 580
                 'default'   => '',
581 581
                 'type'      => 'multicheck',
582 582
                 'options'   => $overdue_days_options,
583 583
             ),
584 584
             'email_overdue_subject' => array(
585 585
                 'id'   => 'email_overdue_subject',
586
-                'name' => __( 'Subject', 'invoicing' ),
587
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
586
+                'name' => __('Subject', 'invoicing'),
587
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
588 588
                 'type' => 'text',
589
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
589
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
590 590
                 'size' => 'large'
591 591
             ),
592 592
             'email_overdue_heading' => array(
593 593
                 'id'   => 'email_overdue_heading',
594
-                'name' => __( 'Email Heading', 'invoicing' ),
595
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
594
+                'name' => __('Email Heading', 'invoicing'),
595
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
596 596
                 'type' => 'text',
597
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
597
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
598 598
                 'size' => 'large'
599 599
             ),
600 600
             'email_overdue_admin_bcc' => array(
601 601
                 'id'   => 'email_overdue_admin_bcc',
602
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
603
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
602
+                'name' => __('Enable Admin BCC', 'invoicing'),
603
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
604 604
                 'type' => 'checkbox',
605 605
                 'std'  => 1
606 606
             ),
607 607
             'email_overdue_body' => array(
608 608
                 'id'   => 'email_overdue_body',
609
-                'name' => __( 'Email Content', 'invoicing' ),
610
-                'desc' => __( 'The content of the email.', 'invoicing' ),
609
+                'name' => __('Email Content', 'invoicing'),
610
+                'desc' => __('The content of the email.', 'invoicing'),
611 611
                 'type' => 'rich_editor',
612
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
612
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
613 613
                 'class' => 'large',
614 614
                 'size'  => 10,
615 615
             ),
@@ -618,256 +618,256 @@  discard block
 block discarded – undo
618 618
         'subscription_trial' => array(
619 619
             'email_subscription_trial_header' => array(
620 620
                 'id'   => 'email_subscription_trial_header',
621
-                'name' => '<h3>' . __( 'Start Trial', 'invoicing' ) . '</h3>',
622
-                'desc' => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ),
621
+                'name' => '<h3>' . __('Start Trial', 'invoicing') . '</h3>',
622
+                'desc' => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'),
623 623
                 'type' => 'header',
624 624
             ),
625 625
             'email_subscription_trial_active' => array(
626 626
                 'id'   => 'email_subscription_trial_active',
627
-                'name' => __( 'Enable/Disable', 'invoicing' ),
628
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
627
+                'name' => __('Enable/Disable', 'invoicing'),
628
+                'desc' => __('Enable this email notification', 'invoicing'),
629 629
                 'type' => 'checkbox',
630 630
                 'std'  => 0
631 631
             ),
632 632
             'email_subscription_trial_subject' => array(
633 633
                 'id'   => 'email_subscription_trial_subject',
634
-                'name' => __( 'Subject', 'invoicing' ),
635
-                'desc' => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ),
634
+                'name' => __('Subject', 'invoicing'),
635
+                'desc' => __('Enter the subject line for the subscription trial email.', 'invoicing'),
636 636
                 'type' => 'text',
637
-                'std'  => __( '[{site_title}] Trial Started', 'invoicing' ),
637
+                'std'  => __('[{site_title}] Trial Started', 'invoicing'),
638 638
                 'size' => 'large'
639 639
             ),
640 640
             'email_subscription_trial_heading' => array(
641 641
                 'id'   => 'email_subscription_trial_heading',
642
-                'name' => __( 'Email Heading', 'invoicing' ),
643
-                'desc' => __( 'Enter the main heading of this email.', 'invoicing' ),
642
+                'name' => __('Email Heading', 'invoicing'),
643
+                'desc' => __('Enter the main heading of this email.', 'invoicing'),
644 644
                 'type' => 'text',
645
-                'std'  => __( 'Trial Started', 'invoicing' ),
645
+                'std'  => __('Trial Started', 'invoicing'),
646 646
                 'size' => 'large'
647 647
             ),
648 648
             'email_overdue_admin_bcc' => array(
649 649
                 'id'   => 'email_subscription_trial_admin_bcc',
650
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
651
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
650
+                'name' => __('Enable Admin BCC', 'invoicing'),
651
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
652 652
                 'type' => 'checkbox',
653 653
                 'std'  => 1
654 654
             ),
655 655
             'email_overdue_body' => array(
656 656
                 'id'   => 'email_overdue_body',
657
-                'name' => __( 'Email Content', 'invoicing' ),
658
-                'desc' => __( 'The content of the email.', 'invoicing' ),
657
+                'name' => __('Email Content', 'invoicing'),
658
+                'desc' => __('The content of the email.', 'invoicing'),
659 659
                 'type' => 'rich_editor',
660
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
660
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
661 661
                 'class' => 'large',
662 662
                 'size'  => 10,
663 663
             ),
664 664
         ),
665 665
     );
666 666
 
667
-    return apply_filters( 'wpinv_get_emails', $emails );
667
+    return apply_filters('wpinv_get_emails', $emails);
668 668
 }
669 669
 
670
-function wpinv_settings_emails( $settings = array() ) {
670
+function wpinv_settings_emails($settings = array()) {
671 671
     $emails = wpinv_get_emails();
672 672
 
673
-    if ( !empty( $emails ) ) {
674
-        foreach ( $emails as $key => $email ) {
673
+    if (!empty($emails)) {
674
+        foreach ($emails as $key => $email) {
675 675
             $settings[$key] = $email;
676 676
         }
677 677
     }
678 678
 
679
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
679
+    return apply_filters('wpinv_settings_get_emails', $settings);
680 680
 }
681
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
681
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
682 682
 
683
-function wpinv_settings_sections_emails( $settings ) {
683
+function wpinv_settings_sections_emails($settings) {
684 684
     $emails = wpinv_get_emails();
685 685
 
686 686
     if (!empty($emails)) {
687
-        foreach  ($emails as $key => $email) {
688
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
687
+        foreach ($emails as $key => $email) {
688
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
689 689
         }
690 690
     }
691 691
 
692 692
     return $settings;    
693 693
 }
694
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
694
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
695 695
 
696
-function wpinv_email_is_enabled( $email_type ) {
696
+function wpinv_email_is_enabled($email_type) {
697 697
     $emails = wpinv_get_emails();
698
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
698
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
699 699
 
700
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
700
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
701 701
 }
702 702
 
703
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
704
-    switch ( $email_type ) {
703
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
704
+    switch ($email_type) {
705 705
         case 'new_invoice':
706 706
         case 'cancelled_invoice':
707 707
         case 'failed_invoice':
708 708
             $recipient  = wpinv_get_admin_email();
709 709
         break;
710 710
         default:
711
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
712
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
711
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
712
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
713 713
         break;
714 714
     }
715 715
 
716
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
716
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
717 717
 }
718 718
 
719 719
 /**
720 720
  * Returns invoice CC recipients
721 721
  */
722
-function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) {
723
-    switch ( $email_type ) {
722
+function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) {
723
+    switch ($email_type) {
724 724
         case 'new_invoice':
725 725
         case 'cancelled_invoice':
726 726
         case 'failed_invoice':
727 727
             return array();
728 728
         break;
729 729
         default:
730
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
731
-            $recipient  = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true );
732
-            if ( empty( $recipient ) ) {
730
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
731
+            $recipient  = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true);
732
+            if (empty($recipient)) {
733 733
                 return array();
734 734
             }
735
-            return  array_filter( array_map( 'trim', explode( ',', $recipient ) ) );
735
+            return  array_filter(array_map('trim', explode(',', $recipient)));
736 736
         break;
737 737
     }
738 738
 
739 739
 }
740 740
 
741
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
742
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
743
-    $subject    = __( $subject, 'invoicing' );
741
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
742
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
743
+    $subject    = __($subject, 'invoicing');
744 744
 
745
-    $subject    = wpinv_email_format_text( $subject, $invoice );
745
+    $subject    = wpinv_email_format_text($subject, $invoice);
746 746
 
747
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
747
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
748 748
 }
749 749
 
750
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
751
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
752
-    $email_heading = __( $email_heading, 'invoicing' );
750
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
751
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
752
+    $email_heading = __($email_heading, 'invoicing');
753 753
 
754
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
754
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
755 755
 
756
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
756
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
757 757
 }
758 758
 
759
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
760
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
761
-    $content    = __( $content, 'invoicing' );
759
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
760
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
761
+    $content    = __($content, 'invoicing');
762 762
 
763
-    $content    = wpinv_email_format_text( $content, $invoice );
763
+    $content    = wpinv_email_format_text($content, $invoice);
764 764
 
765
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
765
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
766 766
 }
767 767
 
768
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
768
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
769 769
     $from_name = wpinv_mail_get_from_address();
770 770
     $from_email = wpinv_mail_get_from_address();
771 771
     
772
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
772
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
773 773
     
774
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
775
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
774
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
775
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
776 776
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
777 777
     
778
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
778
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
779 779
 }
780 780
 
781
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
781
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
782 782
     $attachments = array();
783 783
     
784
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
784
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
785 785
 }
786 786
 
787 787
 /**
788 788
  * Searches for and replaces certain placeholders in an email.
789 789
  */
790
-function wpinv_email_format_text( $content, $invoice ) {
790
+function wpinv_email_format_text($content, $invoice) {
791 791
 
792 792
     $replace_array = array(
793 793
         '{site_title}'      => wpinv_get_blogname(),
794
-        '{date}'            => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ),
794
+        '{date}'            => date_i18n(get_option('date_format'), (int) current_time('timestamp')),
795 795
     );
796 796
 
797
-    $invoice = new WPInv_Invoice( $invoice );
797
+    $invoice = new WPInv_Invoice($invoice);
798 798
 
799
-    if ( $invoice->get_id() ) {
799
+    if ($invoice->get_id()) {
800 800
 
801 801
         $replace_array = array_merge(
802 802
             $replace_array, 
803 803
             array(
804
-                '{name}'            => sanitize_text_field( $invoice->get_user_full_name() ),
805
-                '{full_name}'       => sanitize_text_field( $invoice->get_user_full_name() ),
806
-                '{first_name}'      => sanitize_text_field( $invoice->get_first_name() ),
807
-                '{last_name}'       => sanitize_text_field( $invoice->get_last_name() ),
808
-                '{email}'           => sanitize_email( $invoice->get_email() ),
809
-                '{invoice_number}'  => sanitize_text_field( $invoice->get_number() ),
810
-                '{invoice_total}'   => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ),
811
-                '{invoice_link}'    => esc_url( $invoice->get_view_url() ),
812
-                '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ),
813
-                '{invoice_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
814
-                '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
815
-                '{invoice_quote}'   => sanitize_text_field( $invoice->get_type() ),
816
-                '{invoice_label}'   => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
817
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
804
+                '{name}'            => sanitize_text_field($invoice->get_user_full_name()),
805
+                '{full_name}'       => sanitize_text_field($invoice->get_user_full_name()),
806
+                '{first_name}'      => sanitize_text_field($invoice->get_first_name()),
807
+                '{last_name}'       => sanitize_text_field($invoice->get_last_name()),
808
+                '{email}'           => sanitize_email($invoice->get_email()),
809
+                '{invoice_number}'  => sanitize_text_field($invoice->get_number()),
810
+                '{invoice_total}'   => wpinv_price(wpinv_format_amount($invoice->get_total(true))),
811
+                '{invoice_link}'    => esc_url($invoice->get_view_url()),
812
+                '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()),
813
+                '{invoice_date}'    => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))),
814
+                '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))),
815
+                '{invoice_quote}'   => sanitize_text_field($invoice->get_type()),
816
+                '{invoice_label}'   => sanitize_text_field(ucfirst($invoice->get_type())),
817
+                '{is_was}'          => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
818 818
             )
819 819
         );
820 820
 
821 821
     }
822 822
 
823 823
     // Let third party plugins filter the arra.
824
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
824
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
825 825
 
826
-    foreach ( $replace_array as $key => $value ) {
827
-        $content = str_replace( $key, $value, $content );
826
+    foreach ($replace_array as $key => $value) {
827
+        $content = str_replace($key, $value, $content);
828 828
     }
829 829
 
830
-    return apply_filters( 'wpinv_email_content_replace', $content );
830
+    return apply_filters('wpinv_email_content_replace', $content);
831 831
 }
832 832
 
833
-function wpinv_email_style_body( $content ) {
833
+function wpinv_email_style_body($content) {
834 834
     // make sure we only inline CSS for html emails
835
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
835
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
836 836
         ob_start();
837
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
838
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
837
+        wpinv_get_template('emails/wpinv-email-styles.php');
838
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
839 839
 
840 840
         // apply CSS styles inline for picky email clients
841 841
         try {
842
-            $emogrifier = new Emogrifier( $content, $css );
842
+            $emogrifier = new Emogrifier($content, $css);
843 843
             $content    = $emogrifier->emogrify();
844
-        } catch ( Exception $e ) {
845
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
844
+        } catch (Exception $e) {
845
+            wpinv_error_log($e->getMessage(), 'emogrifier');
846 846
         }
847 847
     }
848 848
     return $content;
849 849
 }
850 850
 
851
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
852
-    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 ) );
851
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
852
+    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));
853 853
 }
854 854
 
855 855
 /**
856 856
  * Get the email footer.
857 857
  */
858
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
859
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
858
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
859
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
860 860
 }
861 861
 
862
-function wpinv_email_wrap_message( $message ) {
862
+function wpinv_email_wrap_message($message) {
863 863
     // Buffer
864 864
     ob_start();
865 865
 
866
-    do_action( 'wpinv_email_header' );
866
+    do_action('wpinv_email_header');
867 867
 
868
-    echo wpautop( wptexturize( $message ) );
868
+    echo wpautop(wptexturize($message));
869 869
 
870
-    do_action( 'wpinv_email_footer' );
870
+    do_action('wpinv_email_footer');
871 871
 
872 872
     // Get contents
873 873
     $message = ob_get_clean();
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
     return $message;
876 876
 }
877 877
 
878
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
879
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
878
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
879
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
880 880
 }
881 881
 
882 882
 /**
@@ -886,96 +886,96 @@  discard block
 block discarded – undo
886 886
  * @param string $email_type
887 887
  * @param bool $sent_to_admin
888 888
  */
889
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
889
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
890 890
 
891 891
     // Prepare the invoice.
892
-    $invoice = new WPInv_Invoice( $invoice );
892
+    $invoice = new WPInv_Invoice($invoice);
893 893
 
894 894
     // Abort if there is no invoice.
895
-    if ( 0 == $invoice->get_id() ) {
895
+    if (0 == $invoice->get_id()) {
896 896
         return;
897 897
     }
898 898
 
899 899
     // Prepare line items.
900
-    $columns = getpaid_invoice_item_columns( $invoice );
901
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
900
+    $columns = getpaid_invoice_item_columns($invoice);
901
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
902 902
 
903 903
     // Load the template.
904
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) );
904
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin'));
905 905
 }
906 906
 
907
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
908
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
907
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
908
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
909 909
 }
910 910
 
911
-function wpinv_send_customer_invoice( $data = array() ) {
912
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
911
+function wpinv_send_customer_invoice($data = array()) {
912
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
913 913
 
914
-    if ( empty( $invoice_id ) ) {
914
+    if (empty($invoice_id)) {
915 915
         return;
916 916
     }
917 917
 
918
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
919
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
918
+    if (!wpinv_current_user_can_manage_invoicing()) {
919
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
920 920
     }
921 921
     
922
-    $sent = wpinv_user_invoice_notification( $invoice_id );
922
+    $sent = wpinv_user_invoice_notification($invoice_id);
923 923
 
924 924
     if ( -1 === $sent ) {
925 925
         $status = 'email_disabled';
926
-    } elseif ( $sent ) {
926
+    } elseif ($sent) {
927 927
         $status = 'email_sent';
928 928
     } else {
929 929
         $status = 'email_fail';
930 930
     }
931 931
 
932
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
933
-    wp_redirect( $redirect );
932
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
933
+    wp_redirect($redirect);
934 934
     exit;
935 935
 }
936
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
936
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
937 937
 
938
-function wpinv_send_overdue_reminder( $data = array() ) {
939
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
938
+function wpinv_send_overdue_reminder($data = array()) {
939
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
940 940
 
941
-    if ( empty( $invoice_id ) ) {
941
+    if (empty($invoice_id)) {
942 942
         return;
943 943
     }
944 944
 
945
-    if ( !wpinv_current_user_can_manage_invoicing() ) {
946
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
945
+    if (!wpinv_current_user_can_manage_invoicing()) {
946
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
947 947
     }
948 948
 
949
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
949
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
950 950
     
951 951
     $status = $sent ? 'email_sent' : 'email_fail';
952 952
 
953
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
954
-    wp_redirect( $redirect );
953
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
954
+    wp_redirect($redirect);
955 955
     exit;
956 956
 }
957
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
957
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
958 958
 
959 959
 /**
960 960
  * @deprecated
961 961
  */
962 962
 function wpinv_send_customer_note_email() {}
963 963
 
964
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
965
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
966
-        $date_format = get_option( 'date_format' );
967
-        $time_format = get_option( 'time_format' );
964
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
965
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
966
+        $date_format = get_option('date_format');
967
+        $time_format = get_option('time_format');
968 968
         ?>
969 969
         <div id="wpinv-email-notes">
970
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
970
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
971 971
             <ol class="wpinv-notes-lists">
972 972
         <?php
973
-        foreach ( $invoice_notes as $note ) {
974
-            $note_time = strtotime( $note->comment_date );
973
+        foreach ($invoice_notes as $note) {
974
+            $note_time = strtotime($note->comment_date);
975 975
             ?>
976 976
             <li class="comment wpinv-note">
977
-            <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>
978
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
977
+            <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>
978
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
979 979
             </li>
980 980
             <?php
981 981
         }
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
         <?php
985 985
     }
986 986
 }
987
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
987
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
988 988
 
989 989
 /**
990 990
  * Sends renewal reminders.
@@ -992,35 +992,35 @@  discard block
 block discarded – undo
992 992
 function wpinv_email_renewal_reminders() {
993 993
     global $wpdb;
994 994
 
995
-    if ( ! wpinv_get_option( 'email_pre_payment_active' ) ) {
995
+    if (!wpinv_get_option('email_pre_payment_active')) {
996 996
         return;
997 997
     }
998 998
 
999
-    $reminder_days = wpinv_get_option( 'email_pre_payment_reminder_days' );
999
+    $reminder_days = wpinv_get_option('email_pre_payment_reminder_days');
1000 1000
 
1001
-    if ( empty( $reminder_days ) ) {
1001
+    if (empty($reminder_days)) {
1002 1002
         return;
1003 1003
     }
1004 1004
 
1005 1005
     // How many days before renewal should we send this email?
1006
-    $reminder_days = array_unique( array_map( 'absint', array_filter( wpinv_parse_list( $reminder_days ) ) ) );
1007
-    if ( empty( $reminder_days ) ) {
1006
+    $reminder_days = array_unique(array_map('absint', array_filter(wpinv_parse_list($reminder_days))));
1007
+    if (empty($reminder_days)) {
1008 1008
         return;
1009 1009
     }
1010 1010
 
1011
-    if ( 1 == count( $reminder_days ) ) {
1011
+    if (1 == count($reminder_days)) {
1012 1012
         $days  = $reminder_days[0];
1013
-        $date  = date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) );
1014
-        $where = $wpdb->prepare( "DATE(expiration)=%s", $date );
1013
+        $date  = date('Y-m-d', strtotime("+$days days", current_time('timestamp')));
1014
+        $where = $wpdb->prepare("DATE(expiration)=%s", $date);
1015 1015
     } else {
1016 1016
         $in    = array();
1017 1017
 
1018
-        foreach ( $reminder_days as $days ) {
1019
-            $date  = date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) );
1020
-            $in[]  = $wpdb->prepare( "%s", $date );
1018
+        foreach ($reminder_days as $days) {
1019
+            $date  = date('Y-m-d', strtotime("+$days days", current_time('timestamp')));
1020
+            $in[]  = $wpdb->prepare("%s", $date);
1021 1021
         }
1022 1022
 
1023
-        $in    = implode( ',', $in );
1023
+        $in    = implode(',', $in);
1024 1024
         $where = "DATE(expiration) IN ($in)";
1025 1025
     }
1026 1026
 
@@ -1028,20 +1028,20 @@  discard block
 block discarded – undo
1028 1028
     $table = $wpdb->prefix . 'wpinv_subscriptions';
1029 1029
 
1030 1030
     // Fetch invoices.
1031
-	$subscriptions  = $wpdb->get_results(
1031
+	$subscriptions = $wpdb->get_results(
1032 1032
 		"SELECT parent_payment_id, product_id, expiration FROM $table
1033 1033
 		WHERE
1034 1034
             $where
1035 1035
             AND status IN ( 'trialling', 'active' )");
1036 1036
 
1037
-    foreach ( $subscriptions as $subscription ) {
1037
+    foreach ($subscriptions as $subscription) {
1038 1038
 
1039 1039
         // Skip packages.
1040
-        if ( get_post_meta( $subscription->product_id, '_wpinv_type', true ) == 'package' ) {
1040
+        if (get_post_meta($subscription->product_id, '_wpinv_type', true) == 'package') {
1041 1041
             continue;
1042 1042
         }
1043 1043
 
1044
-        wpinv_send_pre_payment_reminder_notification( $subscription->parent_payment_id, $subscription->expiration );
1044
+        wpinv_send_pre_payment_reminder_notification($subscription->parent_payment_id, $subscription->expiration);
1045 1045
     }
1046 1046
 
1047 1047
 }
@@ -1049,44 +1049,44 @@  discard block
 block discarded – undo
1049 1049
 function wpinv_email_payment_reminders() {
1050 1050
     global $wpi_auto_reminder, $wpdb;
1051 1051
 
1052
-    if ( ! wpinv_get_option( 'email_overdue_active' ) ) {
1052
+    if (!wpinv_get_option('email_overdue_active')) {
1053 1053
         return;
1054 1054
     }
1055 1055
 
1056
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1056
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1057 1057
 
1058 1058
         // Get a list of all reminder dates.
1059
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : array();
1059
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : array();
1060 1060
 
1061 1061
         // Ensure we have integers.
1062
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1062
+        $reminder_days  = array_unique(array_map('absint', $reminder_days));
1063 1063
 
1064 1064
         // Abort if non is selected.
1065
-        if ( empty( $reminder_days ) ) {
1065
+        if (empty($reminder_days)) {
1066 1066
             return;
1067 1067
         }
1068 1068
 
1069 1069
         // Fetch the max reminder day.
1070
-        $max_date = max( $reminder_days );
1070
+        $max_date = max($reminder_days);
1071 1071
 
1072 1072
         // Todays date.
1073
-        $today = date( 'Y-m-d', current_time( 'timestamp' ) );
1073
+        $today = date('Y-m-d', current_time('timestamp'));
1074 1074
 
1075
-        if ( empty( $max_date ) ) {
1076
-            $where = $wpdb->prepare( "DATE(invoices.due_date)=%s", $today );
1077
-        } else if ( 1 == count( $reminder_days ) ) {
1075
+        if (empty($max_date)) {
1076
+            $where = $wpdb->prepare("DATE(invoices.due_date)=%s", $today);
1077
+        } else if (1 == count($reminder_days)) {
1078 1078
             $days  = $reminder_days[0];
1079
-            $date  = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
1080
-            $where = $wpdb->prepare( "DATE(invoices.due_date)=%s", $date );
1079
+            $date  = date('Y-m-d', strtotime("-$days days", current_time('timestamp')));
1080
+            $where = $wpdb->prepare("DATE(invoices.due_date)=%s", $date);
1081 1081
         } else {
1082 1082
             $in    = array();
1083 1083
 
1084
-            foreach ( $reminder_days as $days ) {
1085
-                $date  = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) );
1086
-                $in[]  = $wpdb->prepare( "%s", $date );
1084
+            foreach ($reminder_days as $days) {
1085
+                $date  = date('Y-m-d', strtotime("-$days days", current_time('timestamp')));
1086
+                $in[]  = $wpdb->prepare("%s", $date);
1087 1087
             }
1088 1088
 
1089
-            $in    = implode( ',', $in );
1089
+            $in    = implode(',', $in);
1090 1090
             $where = "DATE(invoices.due_date) IN ($in)";
1091 1091
         }
1092 1092
 
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
         $table = $wpdb->prefix . 'getpaid_invoices';
1095 1095
 
1096 1096
         // Fetch invoices.
1097
-		$invoices  = $wpdb->get_col(
1097
+		$invoices = $wpdb->get_col(
1098 1098
 			"SELECT posts.ID FROM $wpdb->posts as posts
1099 1099
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
1100 1100
 			WHERE
@@ -1102,174 +1102,174 @@  discard block
 block discarded – undo
1102 1102
 				AND posts.post_type = 'wpi_invoice'
1103 1103
                 AND posts.post_status = 'wpi-pending'");
1104 1104
 
1105
-        $wpi_auto_reminder  = true;
1105
+        $wpi_auto_reminder = true;
1106 1106
 
1107
-        foreach ( $invoices as $invoice ) {
1107
+        foreach ($invoices as $invoice) {
1108 1108
 
1109
-            if ( 'payment_form' != get_post_meta( $invoice, 'wpinv_created_via', true ) ) {
1110
-                do_action( 'wpinv_send_payment_reminder_notification', $invoice );
1109
+            if ('payment_form' != get_post_meta($invoice, 'wpinv_created_via', true)) {
1110
+                do_action('wpinv_send_payment_reminder_notification', $invoice);
1111 1111
             }
1112 1112
 
1113 1113
         }
1114 1114
 
1115
-        $wpi_auto_reminder  = false;
1115
+        $wpi_auto_reminder = false;
1116 1116
     }
1117 1117
 }
1118 1118
 
1119 1119
 /**
1120 1120
  * Sends an upcoming renewal notification.
1121 1121
  */
1122
-function wpinv_send_pre_payment_reminder_notification( $invoice_id, $renewal_date ) {
1122
+function wpinv_send_pre_payment_reminder_notification($invoice_id, $renewal_date) {
1123 1123
 
1124 1124
     $email_type = 'pre_payment';
1125
-    if ( ! wpinv_email_is_enabled( $email_type ) ) {
1125
+    if (!wpinv_email_is_enabled($email_type)) {
1126 1126
         return false;
1127 1127
     }
1128 1128
 
1129
-    $invoice    = wpinv_get_invoice( $invoice_id );
1130
-    if ( empty( $invoice ) ) {
1129
+    $invoice = wpinv_get_invoice($invoice_id);
1130
+    if (empty($invoice)) {
1131 1131
         return false;
1132 1132
     }
1133 1133
 
1134
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1135
-    if ( ! is_email( $recipient ) ) {
1134
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1135
+    if (!is_email($recipient)) {
1136 1136
         return false;
1137 1137
     }
1138 1138
 
1139
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1140
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1141
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1142
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1143
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1139
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1140
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1141
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1142
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1143
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1144 1144
 
1145
-    $renewal_date = date_i18n( 'Y-m-d', strtotime( $renewal_date ) );
1146
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1145
+    $renewal_date = date_i18n('Y-m-d', strtotime($renewal_date));
1146
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1147 1147
             'invoice'       => $invoice,
1148 1148
             'email_type'    => $email_type,
1149
-            'email_heading' => str_replace( '{subscription_renewal_date}', $renewal_date, $email_heading ),
1149
+            'email_heading' => str_replace('{subscription_renewal_date}', $renewal_date, $email_heading),
1150 1150
             'sent_to_admin' => false,
1151 1151
             'plain_text'    => false,
1152
-            'message_body'  => str_replace( '{subscription_renewal_date}', $renewal_date, $message_body )
1153
-        ) );
1152
+            'message_body'  => str_replace('{subscription_renewal_date}', $renewal_date, $message_body)
1153
+        ));
1154 1154
 
1155
-    $content        = wpinv_email_format_text( $content, $invoice );
1155
+    $content = wpinv_email_format_text($content, $invoice);
1156 1156
 
1157
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1157
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1158 1158
 
1159
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
1160
-        $recipient  = wpinv_get_admin_email();
1161
-        $subject    .= ' - ADMIN BCC COPY';
1162
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1159
+    if (wpinv_mail_admin_bcc_active($email_type)) {
1160
+        $recipient = wpinv_get_admin_email();
1161
+        $subject .= ' - ADMIN BCC COPY';
1162
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1163 1163
     }
1164 1164
 
1165 1165
     return $sent;
1166 1166
 
1167 1167
 }
1168 1168
 
1169
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1169
+function wpinv_send_payment_reminder_notification($invoice_id) {
1170 1170
     $email_type = 'overdue';
1171
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1171
+    if (!wpinv_email_is_enabled($email_type)) {
1172 1172
         return false;
1173 1173
     }
1174 1174
 
1175
-    $invoice    = wpinv_get_invoice( $invoice_id );
1176
-    if ( empty( $invoice ) ) {
1175
+    $invoice = wpinv_get_invoice($invoice_id);
1176
+    if (empty($invoice)) {
1177 1177
         return false;
1178 1178
     }
1179 1179
 
1180
-    if ( !$invoice->needs_payment() ) {
1180
+    if (!$invoice->needs_payment()) {
1181 1181
         return false;
1182 1182
     }
1183 1183
 
1184
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1185
-    if ( !is_email( $recipient ) ) {
1184
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1185
+    if (!is_email($recipient)) {
1186 1186
         return false;
1187 1187
     }
1188 1188
 
1189
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
1189
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
1190 1190
 
1191
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1192
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1193
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1194
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1195
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1191
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1192
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1193
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1194
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1195
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1196 1196
 
1197
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1197
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1198 1198
             'invoice'       => $invoice,
1199 1199
             'email_type'    => $email_type,
1200 1200
             'email_heading' => $email_heading,
1201 1201
             'sent_to_admin' => false,
1202 1202
             'plain_text'    => false,
1203 1203
             'message_body'  => $message_body
1204
-        ) );
1204
+        ));
1205 1205
 
1206
-    $content        = wpinv_email_format_text( $content, $invoice );
1206
+    $content = wpinv_email_format_text($content, $invoice);
1207 1207
 
1208
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1209
-    if ( $sent ) {
1210
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1208
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1209
+    if ($sent) {
1210
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1211 1211
     }
1212 1212
 
1213
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
1214
-        $recipient  = wpinv_get_admin_email();
1215
-        $subject    .= ' - ADMIN BCC COPY';
1216
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1213
+    if (wpinv_mail_admin_bcc_active($email_type)) {
1214
+        $recipient = wpinv_get_admin_email();
1215
+        $subject .= ' - ADMIN BCC COPY';
1216
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1217 1217
     }
1218 1218
 
1219
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
1219
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
1220 1220
 
1221 1221
     return $sent;
1222 1222
 }
1223
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1223
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1224 1224
 
1225
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1225
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1226 1226
     global $wpi_auto_reminder;
1227 1227
 
1228
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1228
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1229 1229
 
1230
-    if ( empty( $sent ) ) {
1230
+    if (empty($sent)) {
1231 1231
         $sent = array();
1232 1232
     }
1233
-    $sent[] = date_i18n( 'Y-m-d' );
1233
+    $sent[] = date_i18n('Y-m-d');
1234 1234
 
1235
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1235
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1236 1236
 
1237
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1238
-        $note = __( 'Automated reminder sent to the user.', 'invoicing' );
1239
-        $invoice->add_note( $note, false, false, true );
1237
+    if ($wpi_auto_reminder) { // Auto reminder note.
1238
+        $note = __('Automated reminder sent to the user.', 'invoicing');
1239
+        $invoice->add_note($note, false, false, true);
1240 1240
     } else { // Menual reminder note.
1241
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1242
-        $invoice->add_note( $note );
1241
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1242
+        $invoice->add_note($note);
1243 1243
     }
1244 1244
 }
1245
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1245
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1246 1246
 
1247
-function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) {
1248
-    if ( empty( $invoice ) ) {
1247
+function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) {
1248
+    if (empty($invoice)) {
1249 1249
         return;
1250 1250
     }
1251 1251
 
1252
-    if ( is_int( $invoice ) ) {
1253
-        $invoice = wpinv_get_invoice( $invoice );
1252
+    if (is_int($invoice)) {
1253
+        $invoice = wpinv_get_invoice($invoice);
1254 1254
     }
1255 1255
 
1256
-    if ( ! empty( $invoice ) && is_object( $invoice ) ) {
1257
-        if ( ! $site && function_exists( 'get_user_locale' ) ) {
1258
-            $locale = get_user_locale( $invoice->get_user_id() );
1256
+    if (!empty($invoice) && is_object($invoice)) {
1257
+        if (!$site && function_exists('get_user_locale')) {
1258
+            $locale = get_user_locale($invoice->get_user_id());
1259 1259
         } else {
1260 1260
             $locale = get_locale();
1261 1261
         }
1262 1262
 
1263
-        wpinv_switch_to_locale( $locale );
1263
+        wpinv_switch_to_locale($locale);
1264 1264
     }
1265 1265
 }
1266
-add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 );
1266
+add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3);
1267 1267
 
1268
-function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) {
1269
-    if ( empty( $invoice ) ) {
1268
+function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) {
1269
+    if (empty($invoice)) {
1270 1270
         return;
1271 1271
     }
1272 1272
 
1273 1273
     wpinv_restore_locale();
1274 1274
 }
1275
-add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 );
1275
+add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3);
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +735 added lines, -735 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 	
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( wpinv_format_amount( $this->get_price() ) );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,63 +527,63 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538 538
 
539
-		if ( $interval < 1 ) {
540
-			$interval = 1;
541
-		}
539
+        if ( $interval < 1 ) {
540
+            $interval = 1;
541
+        }
542 542
 
543 543
         return $interval;
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the recurring limit.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return int
552
-	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
547
+     * Get the recurring limit.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return int
552
+     */
553
+    public function get_recurring_limit( $context = 'view' ) {
554 554
         return (int) $this->get_prop( 'recurring_limit', $context );
555 555
     }
556 556
 
557 557
     /**
558
-	 * Checks if we have a free trial.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return int
563
-	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
558
+     * Checks if we have a free trial.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return int
563
+     */
564
+    public function get_is_free_trial( $context = 'view' ) {
565 565
         return (int) $this->get_prop( 'is_free_trial', $context );
566 566
     }
567 567
 
568 568
     /**
569
-	 * Alias for self::get_is_free_trial().
570
-	 *
571
-	 * @since 1.0.19
572
-	 * @param  string $context View or edit context.
573
-	 * @return int
574
-	 */
575
-	public function get_free_trial( $context = 'view' ) {
569
+     * Alias for self::get_is_free_trial().
570
+     *
571
+     * @since 1.0.19
572
+     * @param  string $context View or edit context.
573
+     * @return int
574
+     */
575
+    public function get_free_trial( $context = 'view' ) {
576 576
         return $this->get_is_free_trial( $context );
577 577
     }
578 578
 
579 579
     /**
580
-	 * Get the trial period.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  bool $full Return abbreviation or in full.
584
-	 * @return string
585
-	 */
586
-	public function get_trial_period( $full = false ) {
580
+     * Get the trial period.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  bool $full Return abbreviation or in full.
584
+     * @return string
585
+     */
586
+    public function get_trial_period( $full = false ) {
587 587
         $period = $this->get_prop( 'trial_period', 'view' );
588 588
 
589 589
         if ( $full && ! is_bool( $full ) ) {
@@ -594,104 +594,104 @@  discard block
 block discarded – undo
594 594
     }
595 595
 
596 596
     /**
597
-	 * Get the trial interval.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  string $context View or edit context.
601
-	 * @return int
602
-	 */
603
-	public function get_trial_interval( $context = 'view' ) {
597
+     * Get the trial interval.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  string $context View or edit context.
601
+     * @return int
602
+     */
603
+    public function get_trial_interval( $context = 'view' ) {
604 604
         return (int) $this->get_prop( 'trial_interval', $context );
605
-	}
605
+    }
606 606
 	
607
-	/**
608
-	 * Get the item's edit url.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @return string
612
-	 */
613
-	public function get_edit_url() {
607
+    /**
608
+     * Get the item's edit url.
609
+     *
610
+     * @since 1.0.19
611
+     * @return string
612
+     */
613
+    public function get_edit_url() {
614 614
         return get_edit_post_link( $this->get_id() );
615
-	}
616
-
617
-	/**
618
-	 * Given an item's name/custom id, it returns its id.
619
-	 *
620
-	 *
621
-	 * @static
622
-	 * @param string $value The item name or custom id.
623
-	 * @param string $field Either name or custom_id.
624
-	 * @param string $type in case you need to search for a given type.
625
-	 * @since 1.0.15
626
-	 * @return int
627
-	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
-
630
-		// Trim the value.
631
-		$value = sanitize_text_field( $value );
632
-
633
-		if ( empty( $value ) ) {
634
-			return 0;
635
-		}
615
+    }
616
+
617
+    /**
618
+     * Given an item's name/custom id, it returns its id.
619
+     *
620
+     *
621
+     * @static
622
+     * @param string $value The item name or custom id.
623
+     * @param string $field Either name or custom_id.
624
+     * @param string $type in case you need to search for a given type.
625
+     * @since 1.0.15
626
+     * @return int
627
+     */
628
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
+
630
+        // Trim the value.
631
+        $value = sanitize_text_field( $value );
632
+
633
+        if ( empty( $value ) ) {
634
+            return 0;
635
+        }
636 636
 
637 637
         // Valid fields.
638 638
         $fields = array( 'custom_id', 'name', 'slug' );
639 639
 
640
-		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
-			return 0;
643
-		}
644
-
645
-		if ( $field == 'name' ) {
646
-			$field = 'slug';
647
-		} 
648
-
649
-		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
652
-			return $item_id;
653
-		}
654
-
655
-		// Fetch from the db.
656
-		if ( $field =='slug' ) {
657
-			$items = get_posts(
658
-				array(
659
-					'post_type'      => 'wpi_item',
660
-					'name'           => $value,
661
-					'posts_per_page' => 1,
662
-					'post_status'    => 'any',
663
-				)
664
-			);
665
-		}
666
-
667
-		if ( $field =='custom_id' ) {
668
-			$items = get_posts(
669
-				array(
670
-					'post_type'      => 'wpi_item',
671
-					'posts_per_page' => 1,
672
-					'post_status'    => 'any',
673
-					'meta_query'     => array(
674
-						array(
675
-							'key'   => '_wpinv_type',
676
-                			'value' => $type,
677
-						),
678
-						array(
679
-							'key'   => '_wpinv_custom_id',
680
-                			'value' => $type,
681
-						)
682
-					)
683
-				)
684
-			);
685
-		}
686
-
687
-		if ( empty( $items ) ) {
688
-			return 0;
689
-		}
690
-
691
-		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
-
694
-		return $items[0]->ID;
640
+        // Ensure a field has been passed.
641
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
+            return 0;
643
+        }
644
+
645
+        if ( $field == 'name' ) {
646
+            $field = 'slug';
647
+        } 
648
+
649
+        // Maybe retrieve from the cache.
650
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
+        if ( ! empty( $item_id ) ) {
652
+            return $item_id;
653
+        }
654
+
655
+        // Fetch from the db.
656
+        if ( $field =='slug' ) {
657
+            $items = get_posts(
658
+                array(
659
+                    'post_type'      => 'wpi_item',
660
+                    'name'           => $value,
661
+                    'posts_per_page' => 1,
662
+                    'post_status'    => 'any',
663
+                )
664
+            );
665
+        }
666
+
667
+        if ( $field =='custom_id' ) {
668
+            $items = get_posts(
669
+                array(
670
+                    'post_type'      => 'wpi_item',
671
+                    'posts_per_page' => 1,
672
+                    'post_status'    => 'any',
673
+                    'meta_query'     => array(
674
+                        array(
675
+                            'key'   => '_wpinv_type',
676
+                            'value' => $type,
677
+                        ),
678
+                        array(
679
+                            'key'   => '_wpinv_custom_id',
680
+                            'value' => $type,
681
+                        )
682
+                    )
683
+                )
684
+            );
685
+        }
686
+
687
+        if ( empty( $items ) ) {
688
+            return 0;
689
+        }
690
+
691
+        // Update the cache with our data
692
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
+
694
+        return $items[0]->ID;
695 695
     }
696 696
 
697 697
     /**
@@ -724,52 +724,52 @@  discard block
 block discarded – undo
724 724
     */
725 725
 
726 726
     /**
727
-	 * Set parent order ID.
728
-	 *
729
-	 * @since 1.0.19
730
-	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
-			return;
734
-		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
736
-	}
737
-
738
-    /**
739
-	 * Sets item status.
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $status New status.
743
-	 * @return array details of change.
744
-	 */
745
-	public function set_status( $status ) {
727
+     * Set parent order ID.
728
+     *
729
+     * @since 1.0.19
730
+     */
731
+    public function set_parent_id( $value ) {
732
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
733
+            return;
734
+        }
735
+        $this->set_prop( 'parent_id', absint( $value ) );
736
+    }
737
+
738
+    /**
739
+     * Sets item status.
740
+     *
741
+     * @since 1.0.19
742
+     * @param  string $status New status.
743
+     * @return array details of change.
744
+     */
745
+    public function set_status( $status ) {
746 746
         $old_status = $this->get_status();
747 747
 
748 748
         $this->set_prop( 'status', $status );
749 749
 
750
-		return array(
751
-			'from' => $old_status,
752
-			'to'   => $status,
753
-		);
750
+        return array(
751
+            'from' => $old_status,
752
+            'to'   => $status,
753
+        );
754 754
     }
755 755
 
756 756
     /**
757
-	 * Set plugin version when the item was created.
758
-	 *
759
-	 * @since 1.0.19
760
-	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
757
+     * Set plugin version when the item was created.
758
+     *
759
+     * @since 1.0.19
760
+     */
761
+    public function set_version( $value ) {
762
+        $this->set_prop( 'version', $value );
763 763
     }
764 764
 
765 765
     /**
766
-	 * Set date when the item was created.
767
-	 *
768
-	 * @since 1.0.19
769
-	 * @param string $value Value to set.
766
+     * Set date when the item was created.
767
+     *
768
+     * @since 1.0.19
769
+     * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771
-	 */
772
-	public function set_date_created( $value ) {
771
+     */
772
+    public function set_date_created( $value ) {
773 773
         $date = strtotime( $value );
774 774
 
775 775
         if ( $date ) {
@@ -782,13 +782,13 @@  discard block
 block discarded – undo
782 782
     }
783 783
 
784 784
     /**
785
-	 * Set date when the item was last modified.
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param string $value Value to set.
785
+     * Set date when the item was last modified.
786
+     *
787
+     * @since 1.0.19
788
+     * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790
-	 */
791
-	public function set_date_modified( $value ) {
790
+     */
791
+    public function set_date_modified( $value ) {
792 792
         $date = strtotime( $value );
793 793
 
794 794
         if ( $date ) {
@@ -801,115 +801,115 @@  discard block
 block discarded – undo
801 801
     }
802 802
 
803 803
     /**
804
-	 * Set the item name.
805
-	 *
806
-	 * @since 1.0.19
807
-	 * @param  string $value New name.
808
-	 */
809
-	public function set_name( $value ) {
804
+     * Set the item name.
805
+     *
806
+     * @since 1.0.19
807
+     * @param  string $value New name.
808
+     */
809
+    public function set_name( $value ) {
810 810
         $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
811
+        $this->set_prop( 'name', $name );
812 812
     }
813 813
 
814 814
     /**
815
-	 * Alias of self::set_name().
816
-	 *
817
-	 * @since 1.0.19
818
-	 * @param  string $value New name.
819
-	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
815
+     * Alias of self::set_name().
816
+     *
817
+     * @since 1.0.19
818
+     * @param  string $value New name.
819
+     */
820
+    public function set_title( $value ) {
821
+        $this->set_name( $value );
822 822
     }
823 823
 
824 824
     /**
825
-	 * Set the item description.
826
-	 *
827
-	 * @since 1.0.19
828
-	 * @param  string $value New description.
829
-	 */
830
-	public function set_description( $value ) {
825
+     * Set the item description.
826
+     *
827
+     * @since 1.0.19
828
+     * @param  string $value New description.
829
+     */
830
+    public function set_description( $value ) {
831 831
         $description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
832
+        return $this->set_prop( 'description', $description );
833 833
     }
834 834
 
835 835
     /**
836
-	 * Alias of self::set_description().
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  string $value New description.
840
-	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
836
+     * Alias of self::set_description().
837
+     *
838
+     * @since 1.0.19
839
+     * @param  string $value New description.
840
+     */
841
+    public function set_excerpt( $value ) {
842
+        $this->set_description( $value );
843 843
     }
844 844
 
845 845
     /**
846
-	 * Alias of self::set_description().
847
-	 *
848
-	 * @since 1.0.19
849
-	 * @param  string $value New description.
850
-	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
846
+     * Alias of self::set_description().
847
+     *
848
+     * @since 1.0.19
849
+     * @param  string $value New description.
850
+     */
851
+    public function set_summary( $value ) {
852
+        $this->set_description( $value );
853 853
     }
854 854
 
855 855
     /**
856
-	 * Set the owner of the item.
857
-	 *
858
-	 * @since 1.0.19
859
-	 * @param  int $value New author.
860
-	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
863
-	}
856
+     * Set the owner of the item.
857
+     *
858
+     * @since 1.0.19
859
+     * @param  int $value New author.
860
+     */
861
+    public function set_author( $value ) {
862
+        $this->set_prop( 'author', (int) $value );
863
+    }
864 864
 	
865
-	/**
866
-	 * Alias of self::set_author().
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  int $value New author.
870
-	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
873
-    }
874
-
875
-    /**
876
-	 * Set the price of the item.
877
-	 *
878
-	 * @since 1.0.19
879
-	 * @param  float $value New price.
880
-	 */
881
-	public function set_price( $value ) {
865
+    /**
866
+     * Alias of self::set_author().
867
+     *
868
+     * @since 1.0.19
869
+     * @param  int $value New author.
870
+     */
871
+    public function set_owner( $value ) {
872
+        $this->set_author( $value );
873
+    }
874
+
875
+    /**
876
+     * Set the price of the item.
877
+     *
878
+     * @since 1.0.19
879
+     * @param  float $value New price.
880
+     */
881
+    public function set_price( $value ) {
882 882
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
883 883
     }
884 884
 
885 885
     /**
886
-	 * Set the VAT rule of the item.
887
-	 *
888
-	 * @since 1.0.19
889
-	 * @param  string $value new rule.
890
-	 */
891
-	public function set_vat_rule( $value ) {
886
+     * Set the VAT rule of the item.
887
+     *
888
+     * @since 1.0.19
889
+     * @param  string $value new rule.
890
+     */
891
+    public function set_vat_rule( $value ) {
892 892
         $this->set_prop( 'vat_rule', $value );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Set the VAT class of the item.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $value new class.
900
-	 */
901
-	public function set_vat_class( $value ) {
896
+     * Set the VAT class of the item.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $value new class.
900
+     */
901
+    public function set_vat_class( $value ) {
902 902
         $this->set_prop( 'vat_class', $value );
903 903
     }
904 904
 
905 905
     /**
906
-	 * Set the type of the item.
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $value new item type.
910
-	 * @return string
911
-	 */
912
-	public function set_type( $value ) {
906
+     * Set the type of the item.
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $value new item type.
910
+     * @return string
911
+     */
912
+    public function set_type( $value ) {
913 913
 
914 914
         if ( empty( $value ) ) {
915 915
             $value = 'custom';
@@ -919,134 +919,134 @@  discard block
 block discarded – undo
919 919
     }
920 920
 
921 921
     /**
922
-	 * Set the custom id of the item.
923
-	 *
924
-	 * @since 1.0.19
925
-	 * @param  string $value new custom id.
926
-	 */
927
-	public function set_custom_id( $value ) {
922
+     * Set the custom id of the item.
923
+     *
924
+     * @since 1.0.19
925
+     * @param  string $value new custom id.
926
+     */
927
+    public function set_custom_id( $value ) {
928 928
         $this->set_prop( 'custom_id', $value );
929 929
     }
930 930
 
931 931
     /**
932
-	 * Set the custom name of the item.
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $value new custom name.
936
-	 */
937
-	public function set_custom_name( $value ) {
932
+     * Set the custom name of the item.
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $value new custom name.
936
+     */
937
+    public function set_custom_name( $value ) {
938 938
         $this->set_prop( 'custom_name', $value );
939 939
     }
940 940
 
941 941
     /**
942
-	 * Set the custom singular name of the item.
943
-	 *
944
-	 * @since 1.0.19
945
-	 * @param  string $value new custom singular name.
946
-	 */
947
-	public function set_custom_singular_name( $value ) {
942
+     * Set the custom singular name of the item.
943
+     *
944
+     * @since 1.0.19
945
+     * @param  string $value new custom singular name.
946
+     */
947
+    public function set_custom_singular_name( $value ) {
948 948
         $this->set_prop( 'custom_singular_name', $value );
949 949
     }
950 950
 
951 951
     /**
952
-	 * Sets if an item is editable..
953
-	 *
954
-	 * @since 1.0.19
955
-	 * @param  int|bool $value whether or not the item is editable.
956
-	 */
957
-	public function set_is_editable( $value ) {
958
-		if ( is_numeric( $value ) ) {
959
-			$this->set_prop( 'is_editable', (int) $value );
960
-		}
952
+     * Sets if an item is editable..
953
+     *
954
+     * @since 1.0.19
955
+     * @param  int|bool $value whether or not the item is editable.
956
+     */
957
+    public function set_is_editable( $value ) {
958
+        if ( is_numeric( $value ) ) {
959
+            $this->set_prop( 'is_editable', (int) $value );
960
+        }
961 961
     }
962 962
 
963 963
     /**
964
-	 * Sets if dynamic pricing is enabled.
965
-	 *
966
-	 * @since 1.0.19
967
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
968
-	 */
969
-	public function set_is_dynamic_pricing( $value ) {
964
+     * Sets if dynamic pricing is enabled.
965
+     *
966
+     * @since 1.0.19
967
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
968
+     */
969
+    public function set_is_dynamic_pricing( $value ) {
970 970
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
971 971
     }
972 972
 
973 973
     /**
974
-	 * Sets the minimum price if dynamic pricing is enabled.
975
-	 *
976
-	 * @since 1.0.19
977
-	 * @param  float $value minimum price.
978
-	 */
979
-	public function set_minimum_price( $value ) {
974
+     * Sets the minimum price if dynamic pricing is enabled.
975
+     *
976
+     * @since 1.0.19
977
+     * @param  float $value minimum price.
978
+     */
979
+    public function set_minimum_price( $value ) {
980 980
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
981 981
     }
982 982
 
983 983
     /**
984
-	 * Sets if this is a recurring item.
985
-	 *
986
-	 * @since 1.0.19
987
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
988
-	 */
989
-	public function set_is_recurring( $value ) {
984
+     * Sets if this is a recurring item.
985
+     *
986
+     * @since 1.0.19
987
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
988
+     */
989
+    public function set_is_recurring( $value ) {
990 990
         $this->set_prop( 'is_recurring', (int) $value );
991 991
     }
992 992
 
993 993
     /**
994
-	 * Set the recurring period.
995
-	 *
996
-	 * @since 1.0.19
997
-	 * @param  string $value new period.
998
-	 */
999
-	public function set_recurring_period( $value ) {
994
+     * Set the recurring period.
995
+     *
996
+     * @since 1.0.19
997
+     * @param  string $value new period.
998
+     */
999
+    public function set_recurring_period( $value ) {
1000 1000
         $this->set_prop( 'recurring_period', $value );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Set the recurring interval.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  int $value recurring interval.
1008
-	 */
1009
-	public function set_recurring_interval( $value ) {
1004
+     * Set the recurring interval.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  int $value recurring interval.
1008
+     */
1009
+    public function set_recurring_interval( $value ) {
1010 1010
         return $this->set_prop( 'recurring_interval', (int) $value );
1011 1011
     }
1012 1012
 
1013 1013
     /**
1014
-	 * Get the recurring limit.
1015
-	 * @since 1.0.19
1016
-	 * @param  int $value The recurring limit.
1017
-	 * @return int
1018
-	 */
1019
-	public function set_recurring_limit( $value ) {
1014
+     * Get the recurring limit.
1015
+     * @since 1.0.19
1016
+     * @param  int $value The recurring limit.
1017
+     * @return int
1018
+     */
1019
+    public function set_recurring_limit( $value ) {
1020 1020
         $this->set_prop( 'recurring_limit', (int) $value );
1021 1021
     }
1022 1022
 
1023 1023
     /**
1024
-	 * Checks if we have a free trial.
1025
-	 *
1026
-	 * @since 1.0.19
1027
-	 * @param  int|bool $value whether or not it has a free trial.
1028
-	 */
1029
-	public function set_is_free_trial( $value ) {
1024
+     * Checks if we have a free trial.
1025
+     *
1026
+     * @since 1.0.19
1027
+     * @param  int|bool $value whether or not it has a free trial.
1028
+     */
1029
+    public function set_is_free_trial( $value ) {
1030 1030
         $this->set_prop( 'is_free_trial', (int) $value );
1031 1031
     }
1032 1032
 
1033 1033
     /**
1034
-	 * Set the trial period.
1035
-	 *
1036
-	 * @since 1.0.19
1037
-	 * @param  string $value trial period.
1038
-	 */
1039
-	public function set_trial_period( $value ) {
1034
+     * Set the trial period.
1035
+     *
1036
+     * @since 1.0.19
1037
+     * @param  string $value trial period.
1038
+     */
1039
+    public function set_trial_period( $value ) {
1040 1040
         $this->set_prop( 'trial_period', $value );
1041 1041
     }
1042 1042
 
1043 1043
     /**
1044
-	 * Set the trial interval.
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  int $value trial interval.
1048
-	 */
1049
-	public function set_trial_interval( $value ) {
1044
+     * Set the trial interval.
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  int $value trial interval.
1048
+     */
1049
+    public function set_trial_interval( $value ) {
1050 1050
         $this->set_prop( 'trial_interval', $value );
1051 1051
     }
1052 1052
 
@@ -1054,17 +1054,17 @@  discard block
 block discarded – undo
1054 1054
      * Create an item. For backwards compatibilty.
1055 1055
      * 
1056 1056
      * @deprecated
1057
-	 * @return int item id
1057
+     * @return int item id
1058 1058
      */
1059 1059
     public function create( $data = array() ) {
1060 1060
 
1061
-		// Set the properties.
1062
-		if ( is_array( $data ) ) {
1063
-			$this->set_props( $data );
1064
-		}
1061
+        // Set the properties.
1062
+        if ( is_array( $data ) ) {
1063
+            $this->set_props( $data );
1064
+        }
1065 1065
 
1066
-		// Save the item.
1067
-		return $this->save();
1066
+        // Save the item.
1067
+        return $this->save();
1068 1068
 
1069 1069
     }
1070 1070
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
      * Updates an item. For backwards compatibilty.
1073 1073
      * 
1074 1074
      * @deprecated
1075
-	 * @return int item id
1075
+     * @return int item id
1076 1076
      */
1077 1077
     public function update( $data = array() ) {
1078 1078
         return $this->create( $data );
@@ -1088,84 +1088,84 @@  discard block
 block discarded – undo
1088 1088
 	*/
1089 1089
 
1090 1090
     /**
1091
-	 * Checks whether the item has enabled dynamic pricing.
1092
-	 *
1093
-	 * @since 1.0.19
1094
-	 * @return bool
1095
-	 */
1096
-	public function user_can_set_their_price() {
1091
+     * Checks whether the item has enabled dynamic pricing.
1092
+     *
1093
+     * @since 1.0.19
1094
+     * @return bool
1095
+     */
1096
+    public function user_can_set_their_price() {
1097 1097
         return (bool) $this->get_is_dynamic_pricing();
1098
-	}
1098
+    }
1099 1099
 	
1100
-	/**
1101
-	 * Checks whether the item is recurring.
1102
-	 *
1103
-	 * @since 1.0.19
1104
-	 * @return bool
1105
-	 */
1106
-	public function is_recurring() {
1100
+    /**
1101
+     * Checks whether the item is recurring.
1102
+     *
1103
+     * @since 1.0.19
1104
+     * @return bool
1105
+     */
1106
+    public function is_recurring() {
1107 1107
         return (bool) $this->get_is_recurring();
1108 1108
     }
1109 1109
 
1110 1110
     /**
1111
-	 * Checks whether the item has a free trial.
1112
-	 *
1113
-	 * @since 1.0.19
1114
-	 * @return bool
1115
-	 */
1111
+     * Checks whether the item has a free trial.
1112
+     *
1113
+     * @since 1.0.19
1114
+     * @return bool
1115
+     */
1116 1116
     public function has_free_trial() {
1117 1117
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1118 1118
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1119 1119
     }
1120 1120
 
1121 1121
     /**
1122
-	 * Checks whether the item is free.
1123
-	 *
1124
-	 * @since 1.0.19
1125
-	 * @return bool
1126
-	 */
1122
+     * Checks whether the item is free.
1123
+     *
1124
+     * @since 1.0.19
1125
+     * @return bool
1126
+     */
1127 1127
     public function is_free() {
1128 1128
         $is_free   = $this->get_price() == 0;
1129 1129
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1130 1130
     }
1131 1131
 
1132 1132
     /**
1133
-	 * Checks the item status against a passed in status.
1134
-	 *
1135
-	 * @param array|string $status Status to check.
1136
-	 * @return bool
1137
-	 */
1138
-	public function has_status( $status ) {
1139
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1133
+     * Checks the item status against a passed in status.
1134
+     *
1135
+     * @param array|string $status Status to check.
1136
+     * @return bool
1137
+     */
1138
+    public function has_status( $status ) {
1139
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1141 1141
     }
1142 1142
 
1143 1143
     /**
1144
-	 * Checks the item type against a passed in types.
1145
-	 *
1146
-	 * @param array|string $type Type to check.
1147
-	 * @return bool
1148
-	 */
1149
-	public function is_type( $type ) {
1150
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1152
-	}
1144
+     * Checks the item type against a passed in types.
1145
+     *
1146
+     * @param array|string $type Type to check.
1147
+     * @return bool
1148
+     */
1149
+    public function is_type( $type ) {
1150
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1152
+    }
1153 1153
 
1154 1154
     /**
1155
-	 * Checks whether the item is editable.
1156
-	 *
1157
-	 * @since 1.0.19
1158
-	 * @return bool
1159
-	 */
1155
+     * Checks whether the item is editable.
1156
+     *
1157
+     * @since 1.0.19
1158
+     * @return bool
1159
+     */
1160 1160
     public function is_editable() {
1161 1161
         $is_editable = $this->get_is_editable();
1162 1162
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1163
-	}
1163
+    }
1164 1164
 
1165
-	/**
1166
-	 * Returns an array of cart fees.
1167
-	 */
1168
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1165
+    /**
1166
+     * Returns an array of cart fees.
1167
+     */
1168
+    public function get_fees( $type = 'fee', $item_id = 0 ) {
1169 1169
         
1170 1170
         $fees = getpaid_session()->get( 'wpi_cart_fees' );
1171 1171
 
@@ -1208,11 +1208,11 @@  discard block
 block discarded – undo
1208 1208
     }
1209 1209
 
1210 1210
     /**
1211
-	 * Checks whether the item is purchasable.
1212
-	 *
1213
-	 * @since 1.0.19
1214
-	 * @return bool
1215
-	 */
1211
+     * Checks whether the item is purchasable.
1212
+     *
1213
+     * @since 1.0.19
1214
+     * @return bool
1215
+     */
1216 1216
     public function can_purchase() {
1217 1217
         $can_purchase = null !== $this->get_id();
1218 1218
 
@@ -1224,11 +1224,11 @@  discard block
 block discarded – undo
1224 1224
     }
1225 1225
 
1226 1226
     /**
1227
-	 * Checks whether the item supports dynamic pricing.
1228
-	 *
1229
-	 * @since 1.0.19
1230
-	 * @return bool
1231
-	 */
1227
+     * Checks whether the item supports dynamic pricing.
1228
+     *
1229
+     * @since 1.0.19
1230
+     * @return bool
1231
+     */
1232 1232
     public function supports_dynamic_pricing() {
1233 1233
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1234 1234
     }
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
325
+        return wpinv_price(wpinv_format_amount($this->get_price()));
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
336
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
480
+        return wpinv_price(wpinv_format_amount($this->get_recurring_price()));
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,35 +625,35 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = sanitize_text_field( $value );
631
+		$value = sanitize_text_field($value);
632 632
 
633
-		if ( empty( $value ) ) {
633
+		if (empty($value)) {
634 634
 			return 0;
635 635
 		}
636 636
 
637 637
         // Valid fields.
638
-        $fields = array( 'custom_id', 'name', 'slug' );
638
+        $fields = array('custom_id', 'name', 'slug');
639 639
 
640 640
 		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+		if (empty($field) || !in_array($field, $fields)) {
642 642
 			return 0;
643 643
 		}
644 644
 
645
-		if ( $field == 'name' ) {
645
+		if ($field == 'name') {
646 646
 			$field = 'slug';
647 647
 		} 
648 648
 
649 649
 		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
650
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
651
+		if (!empty($item_id)) {
652 652
 			return $item_id;
653 653
 		}
654 654
 
655 655
 		// Fetch from the db.
656
-		if ( $field =='slug' ) {
656
+		if ($field == 'slug') {
657 657
 			$items = get_posts(
658 658
 				array(
659 659
 					'post_type'      => 'wpi_item',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			);
665 665
 		}
666 666
 
667
-		if ( $field =='custom_id' ) {
667
+		if ($field == 'custom_id') {
668 668
 			$items = get_posts(
669 669
 				array(
670 670
 					'post_type'      => 'wpi_item',
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 			);
685 685
 		}
686 686
 
687
-		if ( empty( $items ) ) {
687
+		if (empty($items)) {
688 688
 			return 0;
689 689
 		}
690 690
 
691 691
 		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
692
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
693 693
 
694 694
 		return $items[0]->ID;
695 695
     }
@@ -697,19 +697,19 @@  discard block
 block discarded – undo
697 697
     /**
698 698
      * Margic method for retrieving a property.
699 699
      */
700
-    public function __get( $key ) {
700
+    public function __get($key) {
701 701
 
702 702
         // Check if we have a helper method for that.
703
-        if ( method_exists( $this, 'get_' . $key ) ) {
704
-            return call_user_func( array( $this, 'get_' . $key ) );
703
+        if (method_exists($this, 'get_' . $key)) {
704
+            return call_user_func(array($this, 'get_' . $key));
705 705
         }
706 706
 
707 707
         // Check if the key is in the associated $post object.
708
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
708
+        if (!empty($this->post) && isset($this->post->$key)) {
709 709
             return $this->post->$key;
710 710
         }
711 711
 
712
-        return $this->get_prop( $key );
712
+        return $this->get_prop($key);
713 713
 
714 714
     }
715 715
 
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	 *
729 729
 	 * @since 1.0.19
730 730
 	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
731
+	public function set_parent_id($value) {
732
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
733 733
 			return;
734 734
 		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
735
+		$this->set_prop('parent_id', absint($value));
736 736
 	}
737 737
 
738 738
     /**
@@ -742,10 +742,10 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $status New status.
743 743
 	 * @return array details of change.
744 744
 	 */
745
-	public function set_status( $status ) {
745
+	public function set_status($status) {
746 746
         $old_status = $this->get_status();
747 747
 
748
-        $this->set_prop( 'status', $status );
748
+        $this->set_prop('status', $status);
749 749
 
750 750
 		return array(
751 751
 			'from' => $old_status,
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @since 1.0.19
760 760
 	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
761
+	public function set_version($value) {
762
+		$this->set_prop('version', $value);
763 763
     }
764 764
 
765 765
     /**
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 	 * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771 771
 	 */
772
-	public function set_date_created( $value ) {
773
-        $date = strtotime( $value );
772
+	public function set_date_created($value) {
773
+        $date = strtotime($value);
774 774
 
775
-        if ( $date ) {
776
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
775
+        if ($date) {
776
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
777 777
             return true;
778 778
         }
779 779
 
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790 790
 	 */
791
-	public function set_date_modified( $value ) {
792
-        $date = strtotime( $value );
791
+	public function set_date_modified($value) {
792
+        $date = strtotime($value);
793 793
 
794
-        if ( $date ) {
795
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
794
+        if ($date) {
795
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
796 796
             return true;
797 797
         }
798 798
 
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 	 * @since 1.0.19
807 807
 	 * @param  string $value New name.
808 808
 	 */
809
-	public function set_name( $value ) {
810
-        $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
809
+	public function set_name($value) {
810
+        $name = sanitize_text_field($value);
811
+		$this->set_prop('name', $name);
812 812
     }
813 813
 
814 814
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @since 1.0.19
818 818
 	 * @param  string $value New name.
819 819
 	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
820
+	public function set_title($value) {
821
+		$this->set_name($value);
822 822
     }
823 823
 
824 824
     /**
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 	 * @since 1.0.19
828 828
 	 * @param  string $value New description.
829 829
 	 */
830
-	public function set_description( $value ) {
831
-        $description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
830
+	public function set_description($value) {
831
+        $description = wp_kses_post($value);
832
+		return $this->set_prop('description', $description);
833 833
     }
834 834
 
835 835
     /**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 * @param  string $value New description.
840 840
 	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
841
+	public function set_excerpt($value) {
842
+		$this->set_description($value);
843 843
     }
844 844
 
845 845
     /**
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	 * @since 1.0.19
849 849
 	 * @param  string $value New description.
850 850
 	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
851
+	public function set_summary($value) {
852
+		$this->set_description($value);
853 853
     }
854 854
 
855 855
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @since 1.0.19
859 859
 	 * @param  int $value New author.
860 860
 	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
861
+	public function set_author($value) {
862
+		$this->set_prop('author', (int) $value);
863 863
 	}
864 864
 	
865 865
 	/**
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	 * @since 1.0.19
869 869
 	 * @param  int $value New author.
870 870
 	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
871
+	public function set_owner($value) {
872
+		$this->set_author($value);
873 873
     }
874 874
 
875 875
     /**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @since 1.0.19
879 879
 	 * @param  float $value New price.
880 880
 	 */
881
-	public function set_price( $value ) {
882
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
881
+	public function set_price($value) {
882
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
883 883
     }
884 884
 
885 885
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @since 1.0.19
889 889
 	 * @param  string $value new rule.
890 890
 	 */
891
-	public function set_vat_rule( $value ) {
892
-        $this->set_prop( 'vat_rule', $value );
891
+	public function set_vat_rule($value) {
892
+        $this->set_prop('vat_rule', $value);
893 893
     }
894 894
 
895 895
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @since 1.0.19
899 899
 	 * @param  string $value new class.
900 900
 	 */
901
-	public function set_vat_class( $value ) {
902
-        $this->set_prop( 'vat_class', $value );
901
+	public function set_vat_class($value) {
902
+        $this->set_prop('vat_class', $value);
903 903
     }
904 904
 
905 905
     /**
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $value new item type.
910 910
 	 * @return string
911 911
 	 */
912
-	public function set_type( $value ) {
912
+	public function set_type($value) {
913 913
 
914
-        if ( empty( $value ) ) {
914
+        if (empty($value)) {
915 915
             $value = 'custom';
916 916
         }
917 917
 
918
-        $this->set_prop( 'type', $value );
918
+        $this->set_prop('type', $value);
919 919
     }
920 920
 
921 921
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @since 1.0.19
925 925
 	 * @param  string $value new custom id.
926 926
 	 */
927
-	public function set_custom_id( $value ) {
928
-        $this->set_prop( 'custom_id', $value );
927
+	public function set_custom_id($value) {
928
+        $this->set_prop('custom_id', $value);
929 929
     }
930 930
 
931 931
     /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @since 1.0.19
935 935
 	 * @param  string $value new custom name.
936 936
 	 */
937
-	public function set_custom_name( $value ) {
938
-        $this->set_prop( 'custom_name', $value );
937
+	public function set_custom_name($value) {
938
+        $this->set_prop('custom_name', $value);
939 939
     }
940 940
 
941 941
     /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 	 * @since 1.0.19
945 945
 	 * @param  string $value new custom singular name.
946 946
 	 */
947
-	public function set_custom_singular_name( $value ) {
948
-        $this->set_prop( 'custom_singular_name', $value );
947
+	public function set_custom_singular_name($value) {
948
+        $this->set_prop('custom_singular_name', $value);
949 949
     }
950 950
 
951 951
     /**
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
 	 * @since 1.0.19
955 955
 	 * @param  int|bool $value whether or not the item is editable.
956 956
 	 */
957
-	public function set_is_editable( $value ) {
958
-		if ( is_numeric( $value ) ) {
959
-			$this->set_prop( 'is_editable', (int) $value );
957
+	public function set_is_editable($value) {
958
+		if (is_numeric($value)) {
959
+			$this->set_prop('is_editable', (int) $value);
960 960
 		}
961 961
     }
962 962
 
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 	 * @since 1.0.19
967 967
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
968 968
 	 */
969
-	public function set_is_dynamic_pricing( $value ) {
970
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
969
+	public function set_is_dynamic_pricing($value) {
970
+        $this->set_prop('is_dynamic_pricing', (int) $value);
971 971
     }
972 972
 
973 973
     /**
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 	 * @since 1.0.19
977 977
 	 * @param  float $value minimum price.
978 978
 	 */
979
-	public function set_minimum_price( $value ) {
980
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
979
+	public function set_minimum_price($value) {
980
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
981 981
     }
982 982
 
983 983
     /**
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 	 * @since 1.0.19
987 987
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
988 988
 	 */
989
-	public function set_is_recurring( $value ) {
990
-        $this->set_prop( 'is_recurring', (int) $value );
989
+	public function set_is_recurring($value) {
990
+        $this->set_prop('is_recurring', (int) $value);
991 991
     }
992 992
 
993 993
     /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @since 1.0.19
997 997
 	 * @param  string $value new period.
998 998
 	 */
999
-	public function set_recurring_period( $value ) {
1000
-        $this->set_prop( 'recurring_period', $value );
999
+	public function set_recurring_period($value) {
1000
+        $this->set_prop('recurring_period', $value);
1001 1001
     }
1002 1002
 
1003 1003
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @since 1.0.19
1007 1007
 	 * @param  int $value recurring interval.
1008 1008
 	 */
1009
-	public function set_recurring_interval( $value ) {
1010
-        return $this->set_prop( 'recurring_interval', (int) $value );
1009
+	public function set_recurring_interval($value) {
1010
+        return $this->set_prop('recurring_interval', (int) $value);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @param  int $value The recurring limit.
1017 1017
 	 * @return int
1018 1018
 	 */
1019
-	public function set_recurring_limit( $value ) {
1020
-        $this->set_prop( 'recurring_limit', (int) $value );
1019
+	public function set_recurring_limit($value) {
1020
+        $this->set_prop('recurring_limit', (int) $value);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	 * @since 1.0.19
1027 1027
 	 * @param  int|bool $value whether or not it has a free trial.
1028 1028
 	 */
1029
-	public function set_is_free_trial( $value ) {
1030
-        $this->set_prop( 'is_free_trial', (int) $value );
1029
+	public function set_is_free_trial($value) {
1030
+        $this->set_prop('is_free_trial', (int) $value);
1031 1031
     }
1032 1032
 
1033 1033
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @since 1.0.19
1037 1037
 	 * @param  string $value trial period.
1038 1038
 	 */
1039
-	public function set_trial_period( $value ) {
1040
-        $this->set_prop( 'trial_period', $value );
1039
+	public function set_trial_period($value) {
1040
+        $this->set_prop('trial_period', $value);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	 * @since 1.0.19
1047 1047
 	 * @param  int $value trial interval.
1048 1048
 	 */
1049
-	public function set_trial_interval( $value ) {
1050
-        $this->set_prop( 'trial_interval', $value );
1049
+	public function set_trial_interval($value) {
1050
+        $this->set_prop('trial_interval', $value);
1051 1051
     }
1052 1052
 
1053 1053
     /**
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
      * @deprecated
1057 1057
 	 * @return int item id
1058 1058
      */
1059
-    public function create( $data = array() ) {
1059
+    public function create($data = array()) {
1060 1060
 
1061 1061
 		// Set the properties.
1062
-		if ( is_array( $data ) ) {
1063
-			$this->set_props( $data );
1062
+		if (is_array($data)) {
1063
+			$this->set_props($data);
1064 1064
 		}
1065 1065
 
1066 1066
 		// Save the item.
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
      * @deprecated
1075 1075
 	 * @return int item id
1076 1076
      */
1077
-    public function update( $data = array() ) {
1078
-        return $this->create( $data );
1077
+    public function update($data = array()) {
1078
+        return $this->create($data);
1079 1079
     }
1080 1080
 
1081 1081
     /*
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
     public function has_free_trial() {
1117 1117
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1118
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1118
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1119 1119
     }
1120 1120
 
1121 1121
     /**
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
     public function is_free() {
1128
-        $is_free   = $this->get_price() == 0;
1129
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1128
+        $is_free = $this->get_price() == 0;
1129
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1130 1130
     }
1131 1131
 
1132 1132
     /**
@@ -1135,9 +1135,9 @@  discard block
 block discarded – undo
1135 1135
 	 * @param array|string $status Status to check.
1136 1136
 	 * @return bool
1137 1137
 	 */
1138
-	public function has_status( $status ) {
1139
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1138
+	public function has_status($status) {
1139
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1140
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 * @param array|string $type Type to check.
1147 1147
 	 * @return bool
1148 1148
 	 */
1149
-	public function is_type( $type ) {
1150
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1149
+	public function is_type($type) {
1150
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1151
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1152 1152
 	}
1153 1153
 
1154 1154
     /**
@@ -1159,52 +1159,52 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
     public function is_editable() {
1161 1161
         $is_editable = $this->get_is_editable();
1162
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1162
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1163 1163
 	}
1164 1164
 
1165 1165
 	/**
1166 1166
 	 * Returns an array of cart fees.
1167 1167
 	 */
1168
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1168
+	public function get_fees($type = 'fee', $item_id = 0) {
1169 1169
         
1170
-        $fees = getpaid_session()->get( 'wpi_cart_fees' );
1170
+        $fees = getpaid_session()->get('wpi_cart_fees');
1171 1171
 
1172
-        if ( ! wpinv_get_cart_contents() ) {
1172
+        if (!wpinv_get_cart_contents()) {
1173 1173
             // We can only get item type fees when the cart is empty
1174 1174
             $type = 'custom';
1175 1175
         }
1176 1176
 
1177
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1178
-            foreach( $fees as $key => $fee ) {
1179
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1180
-                    unset( $fees[ $key ] );
1177
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1178
+            foreach ($fees as $key => $fee) {
1179
+                if (!empty($fee['type']) && $type != $fee['type']) {
1180
+                    unset($fees[$key]);
1181 1181
                 }
1182 1182
             }
1183 1183
         }
1184 1184
 
1185
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1185
+        if (!empty($fees) && !empty($item_id)) {
1186 1186
             // Remove fees that don't belong to the specified Item
1187
-            foreach ( $fees as $key => $fee ) {
1188
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1189
-                    unset( $fees[ $key ] );
1187
+            foreach ($fees as $key => $fee) {
1188
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1189
+                    unset($fees[$key]);
1190 1190
                 }
1191 1191
             }
1192 1192
         }
1193 1193
 
1194
-        if ( ! empty( $fees ) ) {
1194
+        if (!empty($fees)) {
1195 1195
             // Remove fees that belong to a specific item but are not in the cart
1196
-            foreach( $fees as $key => $fee ) {
1197
-                if( empty( $fee['custom_id'] ) ) {
1196
+            foreach ($fees as $key => $fee) {
1197
+                if (empty($fee['custom_id'])) {
1198 1198
                     continue;
1199 1199
                 }
1200 1200
 
1201
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1202
-                    unset( $fees[ $key ] );
1201
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1202
+                    unset($fees[$key]);
1203 1203
                 }
1204 1204
             }
1205 1205
         }
1206 1206
 
1207
-        return ! empty( $fees ) ? $fees : array();
1207
+        return !empty($fees) ? $fees : array();
1208 1208
     }
1209 1209
 
1210 1210
     /**
@@ -1216,11 +1216,11 @@  discard block
 block discarded – undo
1216 1216
     public function can_purchase() {
1217 1217
         $can_purchase = null !== $this->get_id();
1218 1218
 
1219
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1219
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1220 1220
             $can_purchase = false;
1221 1221
         }
1222 1222
 
1223
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1223
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1224 1224
     }
1225 1225
 
1226 1226
     /**
@@ -1230,6 +1230,6 @@  discard block
 block discarded – undo
1230 1230
 	 * @return bool
1231 1231
 	 */
1232 1232
     public function supports_dynamic_pricing() {
1233
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1233
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1234 1234
     }
1235 1235
 }
Please login to merge, or discard this patch.
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,38 +17,38 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
33
+        $args = array(
34 34
             'limit'    => 30,
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
         );
38 38
 
39
-        $invoices = wpinv_get_invoices( $args );
39
+        $invoices = wpinv_get_invoices($args);
40 40
 
41
-        if ( 0 < count( $invoices ) ) {
42
-            foreach ( $invoices as $invoice ) {
41
+        if (0 < count($invoices)) {
42
+            foreach ($invoices as $invoice) {
43 43
                 $data_to_export[] = array(
44 44
                     'group_id'          => 'customer_invoices',
45
-                    'group_label'       => __( 'Invoicing Data', 'invoicing' ),
46
-                    'group_description' => __( 'Customer invoicing data.', 'invoicing' ),
45
+                    'group_label'       => __('Invoicing Data', 'invoicing'),
46
+                    'group_description' => __('Customer invoicing data.', 'invoicing'),
47 47
                     'item_id'           => "wpinv-{$invoice->ID}",
48
-                    'data'              => self::get_customer_invoice_data( $invoice ),
48
+                    'data'              => self::get_customer_invoice_data($invoice),
49 49
                 );
50 50
             }
51
-            $done = 30 > count( $invoices );
51
+            $done = 30 > count($invoices);
52 52
         } else {
53 53
             $done = true;
54 54
         }
@@ -66,59 +66,59 @@  discard block
 block discarded – undo
66 66
      * @param WPInv_Invoice $invoice invoice object.
67 67
      * @return array
68 68
      */
69
-    public static function get_customer_invoice_data( $invoice ) {
69
+    public static function get_customer_invoice_data($invoice) {
70 70
         $personal_data = array();
71 71
 
72 72
         $props_to_export = array(
73
-            'number'               => __( 'Invoice Number', 'invoicing' ),
74
-            'created_date'         => __( 'Invoice Date', 'invoicing' ),
75
-            'status'               => __( 'Invoice Status', 'invoicing' ),
76
-            'total'                => __( 'Invoice Total', 'invoicing' ),
77
-            'items'                => __( 'Invoice Items', 'invoicing' ),
78
-            'first_name'           => __( 'First Name', 'invoicing' ),
79
-            'last_name'            => __( 'Last Name', 'invoicing' ),
80
-            'email'                => __( 'Email Address', 'invoicing' ),
81
-            '_wpinv_company'       => __( 'Company', 'invoicing' ),
82
-            'phone'                => __( 'Phone Number', 'invoicing' ),
83
-            'address'              => __( 'Address', 'invoicing' ),
84
-            '_wpinv_city'          => __( 'City', 'invoicing' ),
85
-            '_wpinv_country'       => __( 'Country', 'invoicing' ),
86
-            '_wpinv_state'         => __( 'State', 'invoicing' ),
87
-            '_wpinv_zip'           => __( 'Zip Code', 'invoicing' ),
73
+            'number'               => __('Invoice Number', 'invoicing'),
74
+            'created_date'         => __('Invoice Date', 'invoicing'),
75
+            'status'               => __('Invoice Status', 'invoicing'),
76
+            'total'                => __('Invoice Total', 'invoicing'),
77
+            'items'                => __('Invoice Items', 'invoicing'),
78
+            'first_name'           => __('First Name', 'invoicing'),
79
+            'last_name'            => __('Last Name', 'invoicing'),
80
+            'email'                => __('Email Address', 'invoicing'),
81
+            '_wpinv_company'       => __('Company', 'invoicing'),
82
+            'phone'                => __('Phone Number', 'invoicing'),
83
+            'address'              => __('Address', 'invoicing'),
84
+            '_wpinv_city'          => __('City', 'invoicing'),
85
+            '_wpinv_country'       => __('Country', 'invoicing'),
86
+            '_wpinv_state'         => __('State', 'invoicing'),
87
+            '_wpinv_zip'           => __('Zip Code', 'invoicing'),
88 88
         );
89 89
 
90
-        $subscription = wpinv_get_subscription( $invoice );
90
+        $subscription = wpinv_get_subscription($invoice);
91 91
         $period = $initial_amt = $bill_times = $billed = $renewal_date = '';
92 92
 
93
-        if ( $invoice->is_recurring() && !empty( $subscription ) ) {
94
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() );
95
-            $period = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency;
96
-            $initial_amt = wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() );
97
-            $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() );
98
-            $renewal_date = ! empty( $subscription->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration ) ) : __( 'N/A', 'invoicing' );
99
-
100
-            $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' );
101
-            $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' );
102
-            $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' );
103
-            $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' );
93
+        if ($invoice->is_recurring() && !empty($subscription)) {
94
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->get_period(), $subscription->get_frequency());
95
+            $period = wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency;
96
+            $initial_amt = wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $subscription->get_parent_payment()->get_currency());
97
+            $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times());
98
+            $renewal_date = !empty($subscription->expiration) ? date_i18n(get_option('date_format'), strtotime($subscription->expiration)) : __('N/A', 'invoicing');
99
+
100
+            $props_to_export['period'] = __('Billing Cycle', 'invoicing');
101
+            $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing');
102
+            $props_to_export['bill_times'] = __('Times Billed', 'invoicing');
103
+            $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing');
104 104
         }
105 105
 
106
-        $props_to_export['ip'] = __( 'IP Address', 'invoicing' );
107
-        $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' );
106
+        $props_to_export['ip'] = __('IP Address', 'invoicing');
107
+        $props_to_export['view_url'] = __('Invoice Link', 'invoicing');
108 108
 
109
-        $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
109
+        $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
110 110
 
111
-        foreach ( $props_to_export as $prop => $name ) {
111
+        foreach ($props_to_export as $prop => $name) {
112 112
             $value = '';
113 113
 
114
-            switch ( $prop ) {
114
+            switch ($prop) {
115 115
                 case 'items':
116 116
                     $item_names = array();
117
-                    foreach ( $invoice->get_cart_details() as $key => $cart_item ) {
118
-                        $item_quantity  = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
117
+                    foreach ($invoice->get_cart_details() as $key => $cart_item) {
118
+                        $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
119 119
                         $item_names[] = $cart_item['name'] . ' x ' . $item_quantity;
120 120
                     }
121
-                    $value = implode( ', ', $item_names );
121
+                    $value = implode(', ', $item_names);
122 122
                     break;
123 123
                 case 'status':
124 124
                     $value = $invoice->get_status(true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                     $value = $renewal_date;
140 140
                     break;
141 141
                 default:
142
-                    if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) {
142
+                    if (is_callable(array($invoice, 'get_' . $prop))) {
143 143
                         $value = $invoice->{"get_$prop"}();
144 144
                     } else {
145 145
                         $value = $invoice->get_meta($prop);
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
                     break;
148 148
             }
149 149
 
150
-            $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice );
150
+            $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice);
151 151
 
152
-            if ( $value ) {
152
+            if ($value) {
153 153
                 $personal_data[] = array(
154 154
                     'name'  => $name,
155 155
                     'value' => $value,
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
         }
160 160
 
161
-        $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice );
161
+        $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice);
162 162
 
163 163
         return $personal_data;
164 164
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -14,439 +14,439 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * Tax instance.
40
-	 *
41
-	 * @var WPInv_EUVat
42
-	 */
43
-	public $tax;
44
-
45
-	/**
46
-	 * @param array An array of payment gateways.
47
-	 */
48
-	public $gateways;
49
-
50
-	/**
51
-	 * Class constructor.
52
-	 */
53
-	public function __construct() {
54
-		$this->define_constants();
55
-		$this->includes();
56
-		$this->init_hooks();
57
-		$this->set_properties();
58
-	}
59
-
60
-	/**
61
-	 * Sets a custom data property.
62
-	 * 
63
-	 * @param string $prop The prop to set.
64
-	 * @param mixed $value The value to retrieve.
65
-	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
68
-	}
69
-
70
-	/**
71
-	 * Gets a custom data property.
72
-	 * 
73
-	 * @param string $prop The prop to set.
74
-	 * @return mixed The value.
75
-	 */
76
-	public function get( $prop ) {
77
-
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
80
-		}
81
-
82
-		return null;
83
-	}
84
-
85
-	/**
86
-	 * Define class properties.
87
-	 */
88
-	public function set_properties() {
89
-
90
-		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
-		$this->form_elements = new WPInv_Payment_Form_Elements();
94
-		$this->tax           = new WPInv_EUVat();
95
-		$this->tax->init();
96
-		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
-
98
-		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
107
-
108
-	}
109
-
110
-	 /**
111
-	 * Define plugin constants.
112
-	 */
113
-	public function define_constants() {
114
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
115
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
116
-		$this->version = WPINV_VERSION;
117
-	}
118
-
119
-	/**
120
-	 * Hook into actions and filters.
121
-	 *
122
-	 * @since 1.0.19
123
-	 */
124
-	protected function init_hooks() {
125
-		/* Internationalize the text strings used. */
126
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
127
-
128
-		// Init the plugin after WordPress inits.
129
-		add_action( 'init', array( $this, 'init' ), 1 );
130
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
131
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
132
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ) );
133
-
134
-		if ( class_exists( 'BuddyPress' ) ) {
135
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
136
-		}
137
-
138
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
139
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
140
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
141
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
142
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
143
-
144
-		// Fires after registering actions.
145
-		do_action( 'wpinv_actions', $this );
146
-		do_action( 'getpaid_actions', $this );
147
-
148
-	}
149
-
150
-	public function plugins_loaded() {
151
-		/* Internationalize the text strings used. */
152
-		$this->load_textdomain();
153
-
154
-		do_action( 'wpinv_loaded' );
155
-
156
-		// Fix oxygen page builder conflict
157
-		if ( function_exists( 'ct_css_output' ) ) {
158
-			wpinv_oxygen_fix_conflict();
159
-		}
160
-	}
161
-
162
-	/**
163
-	 * Load the translation of the plugin.
164
-	 *
165
-	 * @since 1.0
166
-	 */
167
-	public function load_textdomain( $locale = NULL ) {
168
-		if ( empty( $locale ) ) {
169
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
170
-		}
171
-
172
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
173
-
174
-		unload_textdomain( 'invoicing' );
175
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
176
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
177
-
178
-		/**
179
-		 * Define language constants.
180
-		 */
181
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
182
-	}
183
-
184
-	/**
185
-	 * Include required core files used in admin and on the frontend.
186
-	 */
187
-	public function includes() {
188
-
189
-		// Start with the settings.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
191
-
192
-		// Packages/libraries.
193
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
196
-
197
-		// Load functions.
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
212
-
213
-		// Register autoloader.
214
-		try {
215
-			spl_autoload_register( array( $this, 'autoload' ), true );
216
-		} catch ( Exception $e ) {
217
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
218
-		}
219
-
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
242
-
243
-		/**
244
-		 * Load the tax class.
245
-		 */
246
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
247
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
248
-		}
249
-
250
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
251
-		if ( !empty( $gateways ) ) {
252
-			foreach ( $gateways as $gateway ) {
253
-				if ( $gateway == 'manual' ) {
254
-					continue;
255
-				}
256
-
257
-				$gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
258
-
259
-				if ( file_exists( $gateway_file ) ) {
260
-					require_once( $gateway_file );
261
-				}
262
-			}
263
-		}
264
-
265
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
266
-			GetPaid_Post_Types_Admin::init();
267
-
268
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
269
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
270
-			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
271
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
272
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
273
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
274
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
275
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
276
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
277
-			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
278
-			// load the user class only on the users.php page
279
-			global $pagenow;
280
-			if($pagenow=='users.php'){
281
-				new WPInv_Admin_Users();
282
-			}
283
-		}
284
-
285
-		// Register cli commands
286
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
287
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
288
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
289
-		}
290
-
291
-		// include css inliner
292
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
293
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
294
-		}
295
-
296
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
297
-	}
298
-
299
-	/**
300
-	 * Class autoloader
301
-	 *
302
-	 * @param       string $class_name The name of the class to load.
303
-	 * @access      public
304
-	 * @since       1.0.19
305
-	 * @return      void
306
-	 */
307
-	public function autoload( $class_name ) {
308
-
309
-		// Normalize the class name...
310
-		$class_name  = strtolower( $class_name );
311
-
312
-		// ... and make sure it is our class.
313
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
314
-			return;
315
-		}
316
-
317
-		// Next, prepare the file name from the class.
318
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
319
-
320
-		// Base path of the classes.
321
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
322
-
323
-		// And an array of possible locations in order of importance.
324
-		$locations = array(
325
-			"$plugin_path/includes",
326
-			"$plugin_path/includes/data-stores",
327
-			"$plugin_path/includes/gateways",
328
-			"$plugin_path/includes/api",
329
-			"$plugin_path/includes/admin",
330
-			"$plugin_path/includes/admin/meta-boxes",
331
-		);
332
-
333
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
334
-
335
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
336
-				include trailingslashit( $location ) . $file_name;
337
-				break;
338
-			}
339
-
340
-		}
341
-
342
-	}
343
-
344
-	/**
345
-	 * Inits hooks etc.
346
-	 */
347
-	public function init() {
348
-
349
-		// Fires before getpaid inits.
350
-		do_action( 'before_getpaid_init', $this );
351
-
352
-		// Load default gateways.
353
-		$gateways = apply_filters(
354
-			'getpaid_default_gateways',
355
-			array(
356
-				'manual'        => 'GetPaid_Manual_Gateway',
357
-				'paypal'        => 'GetPaid_Paypal_Gateway',
358
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
359
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
360
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
361
-			)
362
-		);
363
-
364
-		foreach ( $gateways as $id => $class ) {
365
-			$this->gateways[ $id ] = new $class();
366
-		}
367
-
368
-		// Fires after getpaid inits.
369
-		do_action( 'getpaid_init', $this );
370
-
371
-	}
372
-
373
-	/**
374
-	 * Checks if this is an IPN request and processes it.
375
-	 */
376
-	public function maybe_process_ipn() {
377
-
378
-		// Ensure that this is an IPN request.
379
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
380
-			return;
381
-		}
382
-
383
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
384
-
385
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
386
-		do_action( "wpinv_verify_{$gateway}_ipn" );
387
-		exit;
388
-
389
-	}
390
-
391
-	public function enqueue_scripts() {
392
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
393
-
394
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
395
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
396
-		wp_enqueue_style( 'wpinv_front_style' );
397
-
398
-		// Register scripts
399
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
400
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
401
-
402
-		$localize                         = array();
403
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
404
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
405
-		$localize['currency_symbol']      = wpinv_currency_symbol();
406
-		$localize['currency_pos']         = wpinv_currency_position();
407
-		$localize['thousand_sep']         = wpinv_thousands_separator();
408
-		$localize['decimal_sep']          = wpinv_decimal_separator();
409
-		$localize['decimals']             = wpinv_decimals();
410
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
411
-		$localize['UseTaxes']             = wpinv_use_taxes();
412
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
413
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
414
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
415
-
416
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
417
-
418
-		wp_enqueue_script( 'jquery-blockui' );
419
-		$autofill_api = wpinv_get_option('address_autofill_api');
420
-		$autofill_active = wpinv_get_option('address_autofill_active');
421
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
422
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
423
-				wp_dequeue_script( 'google-maps-api' );
424
-			}
425
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
426
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
427
-		}
428
-
429
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
430
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
431
-
432
-		wp_enqueue_script( 'wpinv-front-script' );
433
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
434
-
435
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
436
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
437
-	}
438
-
439
-	public function wpinv_actions() {
440
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
441
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
442
-		}
443
-	}
444
-
445
-	/**
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * Tax instance.
40
+     *
41
+     * @var WPInv_EUVat
42
+     */
43
+    public $tax;
44
+
45
+    /**
46
+     * @param array An array of payment gateways.
47
+     */
48
+    public $gateways;
49
+
50
+    /**
51
+     * Class constructor.
52
+     */
53
+    public function __construct() {
54
+        $this->define_constants();
55
+        $this->includes();
56
+        $this->init_hooks();
57
+        $this->set_properties();
58
+    }
59
+
60
+    /**
61
+     * Sets a custom data property.
62
+     * 
63
+     * @param string $prop The prop to set.
64
+     * @param mixed $value The value to retrieve.
65
+     */
66
+    public function set( $prop, $value ) {
67
+        $this->data[ $prop ] = $value;
68
+    }
69
+
70
+    /**
71
+     * Gets a custom data property.
72
+     * 
73
+     * @param string $prop The prop to set.
74
+     * @return mixed The value.
75
+     */
76
+    public function get( $prop ) {
77
+
78
+        if ( isset( $this->data[ $prop ] ) ) {
79
+            return $this->data[ $prop ];
80
+        }
81
+
82
+        return null;
83
+    }
84
+
85
+    /**
86
+     * Define class properties.
87
+     */
88
+    public function set_properties() {
89
+
90
+        // Sessions.
91
+        $this->set( 'session', new WPInv_Session_Handler() );
92
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
93
+        $this->form_elements = new WPInv_Payment_Form_Elements();
94
+        $this->tax           = new WPInv_EUVat();
95
+        $this->tax->init();
96
+        $GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97
+
98
+        // Init other objects.
99
+        $this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
+        $this->set( 'session', new WPInv_Session_Handler() );
101
+        $this->set( 'notes', new WPInv_Notes() );
102
+        $this->set( 'api', new WPInv_API() );
103
+        $this->set( 'post_types', new GetPaid_Post_Types() );
104
+        $this->set( 'template', new GetPaid_Template() );
105
+        $this->set( 'admin', new GetPaid_Admin() );
106
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
107
+
108
+    }
109
+
110
+        /**
111
+         * Define plugin constants.
112
+         */
113
+    public function define_constants() {
114
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
115
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
116
+        $this->version = WPINV_VERSION;
117
+    }
118
+
119
+    /**
120
+     * Hook into actions and filters.
121
+     *
122
+     * @since 1.0.19
123
+     */
124
+    protected function init_hooks() {
125
+        /* Internationalize the text strings used. */
126
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
127
+
128
+        // Init the plugin after WordPress inits.
129
+        add_action( 'init', array( $this, 'init' ), 1 );
130
+        add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
131
+        add_action( 'init', array( &$this, 'wpinv_actions' ) );
132
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ) );
133
+
134
+        if ( class_exists( 'BuddyPress' ) ) {
135
+            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
136
+        }
137
+
138
+        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
139
+        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
140
+        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
141
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
142
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
143
+
144
+        // Fires after registering actions.
145
+        do_action( 'wpinv_actions', $this );
146
+        do_action( 'getpaid_actions', $this );
147
+
148
+    }
149
+
150
+    public function plugins_loaded() {
151
+        /* Internationalize the text strings used. */
152
+        $this->load_textdomain();
153
+
154
+        do_action( 'wpinv_loaded' );
155
+
156
+        // Fix oxygen page builder conflict
157
+        if ( function_exists( 'ct_css_output' ) ) {
158
+            wpinv_oxygen_fix_conflict();
159
+        }
160
+    }
161
+
162
+    /**
163
+     * Load the translation of the plugin.
164
+     *
165
+     * @since 1.0
166
+     */
167
+    public function load_textdomain( $locale = NULL ) {
168
+        if ( empty( $locale ) ) {
169
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
170
+        }
171
+
172
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
173
+
174
+        unload_textdomain( 'invoicing' );
175
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
176
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
177
+
178
+        /**
179
+         * Define language constants.
180
+         */
181
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
182
+    }
183
+
184
+    /**
185
+     * Include required core files used in admin and on the frontend.
186
+     */
187
+    public function includes() {
188
+
189
+        // Start with the settings.
190
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
191
+
192
+        // Packages/libraries.
193
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
196
+
197
+        // Load functions.
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
206
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
207
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
208
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
212
+
213
+        // Register autoloader.
214
+        try {
215
+            spl_autoload_register( array( $this, 'autoload' ), true );
216
+        } catch ( Exception $e ) {
217
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
218
+        }
219
+
220
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
221
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
222
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
235
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
236
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
237
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
238
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
239
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
240
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
241
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
242
+
243
+        /**
244
+         * Load the tax class.
245
+         */
246
+        if ( ! class_exists( 'WPInv_EUVat' ) ) {
247
+            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
248
+        }
249
+
250
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
251
+        if ( !empty( $gateways ) ) {
252
+            foreach ( $gateways as $gateway ) {
253
+                if ( $gateway == 'manual' ) {
254
+                    continue;
255
+                }
256
+
257
+                $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
258
+
259
+                if ( file_exists( $gateway_file ) ) {
260
+                    require_once( $gateway_file );
261
+                }
262
+            }
263
+        }
264
+
265
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
266
+            GetPaid_Post_Types_Admin::init();
267
+
268
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
269
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
270
+            //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
271
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
272
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
273
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
274
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
275
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
276
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
277
+            //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
278
+            // load the user class only on the users.php page
279
+            global $pagenow;
280
+            if($pagenow=='users.php'){
281
+                new WPInv_Admin_Users();
282
+            }
283
+        }
284
+
285
+        // Register cli commands
286
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
287
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
288
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
289
+        }
290
+
291
+        // include css inliner
292
+        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
293
+            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
294
+        }
295
+
296
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
297
+    }
298
+
299
+    /**
300
+     * Class autoloader
301
+     *
302
+     * @param       string $class_name The name of the class to load.
303
+     * @access      public
304
+     * @since       1.0.19
305
+     * @return      void
306
+     */
307
+    public function autoload( $class_name ) {
308
+
309
+        // Normalize the class name...
310
+        $class_name  = strtolower( $class_name );
311
+
312
+        // ... and make sure it is our class.
313
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
314
+            return;
315
+        }
316
+
317
+        // Next, prepare the file name from the class.
318
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
319
+
320
+        // Base path of the classes.
321
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
322
+
323
+        // And an array of possible locations in order of importance.
324
+        $locations = array(
325
+            "$plugin_path/includes",
326
+            "$plugin_path/includes/data-stores",
327
+            "$plugin_path/includes/gateways",
328
+            "$plugin_path/includes/api",
329
+            "$plugin_path/includes/admin",
330
+            "$plugin_path/includes/admin/meta-boxes",
331
+        );
332
+
333
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
334
+
335
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
336
+                include trailingslashit( $location ) . $file_name;
337
+                break;
338
+            }
339
+
340
+        }
341
+
342
+    }
343
+
344
+    /**
345
+     * Inits hooks etc.
346
+     */
347
+    public function init() {
348
+
349
+        // Fires before getpaid inits.
350
+        do_action( 'before_getpaid_init', $this );
351
+
352
+        // Load default gateways.
353
+        $gateways = apply_filters(
354
+            'getpaid_default_gateways',
355
+            array(
356
+                'manual'        => 'GetPaid_Manual_Gateway',
357
+                'paypal'        => 'GetPaid_Paypal_Gateway',
358
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
359
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
360
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
361
+            )
362
+        );
363
+
364
+        foreach ( $gateways as $id => $class ) {
365
+            $this->gateways[ $id ] = new $class();
366
+        }
367
+
368
+        // Fires after getpaid inits.
369
+        do_action( 'getpaid_init', $this );
370
+
371
+    }
372
+
373
+    /**
374
+     * Checks if this is an IPN request and processes it.
375
+     */
376
+    public function maybe_process_ipn() {
377
+
378
+        // Ensure that this is an IPN request.
379
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
380
+            return;
381
+        }
382
+
383
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
384
+
385
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
386
+        do_action( "wpinv_verify_{$gateway}_ipn" );
387
+        exit;
388
+
389
+    }
390
+
391
+    public function enqueue_scripts() {
392
+        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
393
+
394
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
395
+        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
396
+        wp_enqueue_style( 'wpinv_front_style' );
397
+
398
+        // Register scripts
399
+        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
400
+        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
401
+
402
+        $localize                         = array();
403
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
404
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
405
+        $localize['currency_symbol']      = wpinv_currency_symbol();
406
+        $localize['currency_pos']         = wpinv_currency_position();
407
+        $localize['thousand_sep']         = wpinv_thousands_separator();
408
+        $localize['decimal_sep']          = wpinv_decimal_separator();
409
+        $localize['decimals']             = wpinv_decimals();
410
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
411
+        $localize['UseTaxes']             = wpinv_use_taxes();
412
+        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
413
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
414
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
415
+
416
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
417
+
418
+        wp_enqueue_script( 'jquery-blockui' );
419
+        $autofill_api = wpinv_get_option('address_autofill_api');
420
+        $autofill_active = wpinv_get_option('address_autofill_active');
421
+        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
422
+            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
423
+                wp_dequeue_script( 'google-maps-api' );
424
+            }
425
+            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
426
+            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
427
+        }
428
+
429
+        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
430
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
431
+
432
+        wp_enqueue_script( 'wpinv-front-script' );
433
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
434
+
435
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
436
+        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
437
+    }
438
+
439
+    public function wpinv_actions() {
440
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
441
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
442
+        }
443
+    }
444
+
445
+    /**
446 446
      * Fires an action after verifying that a user can fire them.
447
-	 *
448
-	 * Note: If the action is on an invoice, subscription etc, esure that the
449
-	 * current user owns the invoice/subscription.
447
+     *
448
+     * Note: If the action is on an invoice, subscription etc, esure that the
449
+     * current user owns the invoice/subscription.
450 450
      */
451 451
     public function maybe_do_authenticated_action() {
452 452
 
@@ -457,82 +457,82 @@  discard block
 block discarded – undo
457 457
 
458 458
     }
459 459
 
460
-	public function pre_get_posts( $wp_query ) {
461
-		if ( ! is_admin() && !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() ) {
462
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
463
-		}
464
-
465
-		return $wp_query;
466
-	}
467
-
468
-	public function bp_invoicing_init() {
469
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
470
-	}
471
-
472
-	/**
473
-	 * Register widgets
474
-	 *
475
-	 */
476
-	public function register_widgets() {
477
-		$widgets = apply_filters(
478
-			'getpaid_widget_classes',
479
-			array(
480
-				'WPInv_Checkout_Widget',
481
-				'WPInv_History_Widget',
482
-				'WPInv_Receipt_Widget',
483
-				'WPInv_Subscriptions_Widget',
484
-				'WPInv_Buy_Item_Widget',
485
-				'WPInv_Messages_Widget',
486
-				'WPInv_GetPaid_Widget'
487
-			)
488
-		);
489
-
490
-		foreach ( $widgets as $widget ) {
491
-			register_widget( $widget );
492
-		}
460
+    public function pre_get_posts( $wp_query ) {
461
+        if ( ! is_admin() && !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() ) {
462
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
463
+        }
464
+
465
+        return $wp_query;
466
+    }
467
+
468
+    public function bp_invoicing_init() {
469
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
470
+    }
471
+
472
+    /**
473
+     * Register widgets
474
+     *
475
+     */
476
+    public function register_widgets() {
477
+        $widgets = apply_filters(
478
+            'getpaid_widget_classes',
479
+            array(
480
+                'WPInv_Checkout_Widget',
481
+                'WPInv_History_Widget',
482
+                'WPInv_Receipt_Widget',
483
+                'WPInv_Subscriptions_Widget',
484
+                'WPInv_Buy_Item_Widget',
485
+                'WPInv_Messages_Widget',
486
+                'WPInv_GetPaid_Widget'
487
+            )
488
+        );
489
+
490
+        foreach ( $widgets as $widget ) {
491
+            register_widget( $widget );
492
+        }
493 493
 		
494
-	}
494
+    }
495 495
 
496
-	/**
497
-	 * Remove our pages from yoast sitemaps.
498
-	 *
499
-	 * @since 1.0.19
500
-	 * @param int[] $excluded_posts_ids
501
-	 */
502
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
496
+    /**
497
+     * Remove our pages from yoast sitemaps.
498
+     *
499
+     * @since 1.0.19
500
+     * @param int[] $excluded_posts_ids
501
+     */
502
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
503 503
 
504
-		// Ensure that we have an array.
505
-		if ( ! is_array( $excluded_posts_ids ) ) {
506
-			$excluded_posts_ids = array();
507
-		}
504
+        // Ensure that we have an array.
505
+        if ( ! is_array( $excluded_posts_ids ) ) {
506
+            $excluded_posts_ids = array();
507
+        }
508 508
 
509
-		// Prepare our pages.
510
-		$our_pages = array();
509
+        // Prepare our pages.
510
+        $our_pages = array();
511 511
 
512
-		// Checkout page.
513
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
512
+        // Checkout page.
513
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
514 514
 
515
-		// Success page.
516
-		$our_pages[] = wpinv_get_option( 'success_page', false );
515
+        // Success page.
516
+        $our_pages[] = wpinv_get_option( 'success_page', false );
517 517
 
518
-		// Failure page.
519
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
518
+        // Failure page.
519
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
520 520
 
521
-		// History page.
522
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
521
+        // History page.
522
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
523 523
 
524
-		// Subscriptions page.
525
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
524
+        // Subscriptions page.
525
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
526 526
 
527
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
527
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
528 528
 
529
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
530
-		return array_unique( $excluded_posts_ids );
529
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
530
+        return array_unique( $excluded_posts_ids );
531 531
 
532
-	}
532
+    }
533 533
 
534
-	public function wp_footer() {
535
-		echo '
534
+    public function wp_footer() {
535
+        echo '
536 536
 			<div class="bsui">
537 537
 				<div  id="getpaid-payment-modal" class="modal" tabindex="-1" role="dialog">
538 538
 					<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
@@ -543,6 +543,6 @@  discard block
 block discarded – undo
543 543
 				</div>
544 544
 			</div>
545 545
 		';
546
-	}
546
+    }
547 547
 
548 548
 }
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * @param string $prop The prop to set.
64 64
 	 * @param mixed $value The value to retrieve.
65 65
 	 */
66
-	public function set( $prop, $value ) {
67
-		$this->data[ $prop ] = $value;
66
+	public function set($prop, $value) {
67
+		$this->data[$prop] = $value;
68 68
 	}
69 69
 
70 70
 	/**
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
 	 * @param string $prop The prop to set.
74 74
 	 * @return mixed The value.
75 75
 	 */
76
-	public function get( $prop ) {
76
+	public function get($prop) {
77 77
 
78
-		if ( isset( $this->data[ $prop ] ) ) {
79
-			return $this->data[ $prop ];
78
+		if (isset($this->data[$prop])) {
79
+			return $this->data[$prop];
80 80
 		}
81 81
 
82 82
 		return null;
@@ -88,22 +88,22 @@  discard block
 block discarded – undo
88 88
 	public function set_properties() {
89 89
 
90 90
 		// Sessions.
91
-		$this->set( 'session', new WPInv_Session_Handler() );
92
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
91
+		$this->set('session', new WPInv_Session_Handler());
92
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
93 93
 		$this->form_elements = new WPInv_Payment_Form_Elements();
94 94
 		$this->tax           = new WPInv_EUVat();
95 95
 		$this->tax->init();
96 96
 		$GLOBALS['wpinv_euvat'] = $this->tax; // Backwards compatibility.
97 97
 
98 98
 		// Init other objects.
99
-		$this->set( 'reports', new WPInv_Reports() ); // TODO: Refactor.
100
-		$this->set( 'session', new WPInv_Session_Handler() );
101
-		$this->set( 'notes', new WPInv_Notes() );
102
-		$this->set( 'api', new WPInv_API() );
103
-		$this->set( 'post_types', new GetPaid_Post_Types() );
104
-		$this->set( 'template', new GetPaid_Template() );
105
-		$this->set( 'admin', new GetPaid_Admin() );
106
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
99
+		$this->set('reports', new WPInv_Reports()); // TODO: Refactor.
100
+		$this->set('session', new WPInv_Session_Handler());
101
+		$this->set('notes', new WPInv_Notes());
102
+		$this->set('api', new WPInv_API());
103
+		$this->set('post_types', new GetPaid_Post_Types());
104
+		$this->set('template', new GetPaid_Template());
105
+		$this->set('admin', new GetPaid_Admin());
106
+		$this->set('subscriptions', new WPInv_Subscriptions());
107 107
 
108 108
 	}
109 109
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * Define plugin constants.
112 112
 	 */
113 113
 	public function define_constants() {
114
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
115
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
114
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
115
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
116 116
 		$this->version = WPINV_VERSION;
117 117
 	}
118 118
 
@@ -123,27 +123,27 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	protected function init_hooks() {
125 125
 		/* Internationalize the text strings used. */
126
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
126
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
127 127
 
128 128
 		// Init the plugin after WordPress inits.
129
-		add_action( 'init', array( $this, 'init' ), 1 );
130
-		add_action( 'getpaid_init', array( $this, 'maybe_process_ipn' ), 5 );
131
-		add_action( 'init', array( &$this, 'wpinv_actions' ) );
132
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ) );
129
+		add_action('init', array($this, 'init'), 1);
130
+		add_action('getpaid_init', array($this, 'maybe_process_ipn'), 5);
131
+		add_action('init', array(&$this, 'wpinv_actions'));
132
+		add_action('init', array($this, 'maybe_do_authenticated_action'));
133 133
 
134
-		if ( class_exists( 'BuddyPress' ) ) {
135
-			add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
134
+		if (class_exists('BuddyPress')) {
135
+			add_action('bp_include', array(&$this, 'bp_invoicing_init'));
136 136
 		}
137 137
 
138
-		add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
139
-		add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
140
-		add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
141
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
142
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
138
+		add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
139
+		add_action('wp_footer', array(&$this, 'wp_footer'));
140
+		add_action('widgets_init', array(&$this, 'register_widgets'));
141
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
142
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
143 143
 
144 144
 		// Fires after registering actions.
145
-		do_action( 'wpinv_actions', $this );
146
-		do_action( 'getpaid_actions', $this );
145
+		do_action('wpinv_actions', $this);
146
+		do_action('getpaid_actions', $this);
147 147
 
148 148
 	}
149 149
 
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 		/* Internationalize the text strings used. */
152 152
 		$this->load_textdomain();
153 153
 
154
-		do_action( 'wpinv_loaded' );
154
+		do_action('wpinv_loaded');
155 155
 
156 156
 		// Fix oxygen page builder conflict
157
-		if ( function_exists( 'ct_css_output' ) ) {
157
+		if (function_exists('ct_css_output')) {
158 158
 			wpinv_oxygen_fix_conflict();
159 159
 		}
160 160
 	}
@@ -164,21 +164,21 @@  discard block
 block discarded – undo
164 164
 	 *
165 165
 	 * @since 1.0
166 166
 	 */
167
-	public function load_textdomain( $locale = NULL ) {
168
-		if ( empty( $locale ) ) {
169
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
167
+	public function load_textdomain($locale = NULL) {
168
+		if (empty($locale)) {
169
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
170 170
 		}
171 171
 
172
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
172
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
173 173
 
174
-		unload_textdomain( 'invoicing' );
175
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
176
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
174
+		unload_textdomain('invoicing');
175
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
176
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
177 177
 
178 178
 		/**
179 179
 		 * Define language constants.
180 180
 		 */
181
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
181
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
182 182
 	}
183 183
 
184 184
 	/**
@@ -187,113 +187,113 @@  discard block
 block discarded – undo
187 187
 	public function includes() {
188 188
 
189 189
 		// Start with the settings.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
190
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
191 191
 
192 192
 		// Packages/libraries.
193
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
193
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
196 196
 
197 197
 		// Load functions.
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
206
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
207
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
208
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
209
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
210
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
211
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
206
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
207
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
208
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
209
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
210
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
211
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
212 212
 
213 213
 		// Register autoloader.
214 214
 		try {
215
-			spl_autoload_register( array( $this, 'autoload' ), true );
216
-		} catch ( Exception $e ) {
217
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
215
+			spl_autoload_register(array($this, 'autoload'), true);
216
+		} catch (Exception $e) {
217
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
218 218
 		}
219 219
 
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
235
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
236
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
237
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
238
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
239
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
240
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
241
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
235
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
236
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
237
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
238
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
239
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
240
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
241
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
242 242
 
243 243
 		/**
244 244
 		 * Load the tax class.
245 245
 		 */
246
-		if ( ! class_exists( 'WPInv_EUVat' ) ) {
247
-			require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
246
+		if (!class_exists('WPInv_EUVat')) {
247
+			require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
248 248
 		}
249 249
 
250
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
251
-		if ( !empty( $gateways ) ) {
252
-			foreach ( $gateways as $gateway ) {
253
-				if ( $gateway == 'manual' ) {
250
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
251
+		if (!empty($gateways)) {
252
+			foreach ($gateways as $gateway) {
253
+				if ($gateway == 'manual') {
254 254
 					continue;
255 255
 				}
256 256
 
257 257
 				$gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
258 258
 
259
-				if ( file_exists( $gateway_file ) ) {
260
-					require_once( $gateway_file );
259
+				if (file_exists($gateway_file)) {
260
+					require_once($gateway_file);
261 261
 				}
262 262
 			}
263 263
 		}
264 264
 
265
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
265
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
266 266
 			GetPaid_Post_Types_Admin::init();
267 267
 
268
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
269
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
268
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
269
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
270 270
 			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
271
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
272
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
273
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
274
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
275
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
276
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
271
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
272
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
273
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
274
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
275
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
276
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
277 277
 			//require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
278 278
 			// load the user class only on the users.php page
279 279
 			global $pagenow;
280
-			if($pagenow=='users.php'){
280
+			if ($pagenow == 'users.php') {
281 281
 				new WPInv_Admin_Users();
282 282
 			}
283 283
 		}
284 284
 
285 285
 		// Register cli commands
286
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
287
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
288
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
286
+		if (defined('WP_CLI') && WP_CLI) {
287
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
288
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
289 289
 		}
290 290
 
291 291
 		// include css inliner
292
-		if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
293
-			include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
292
+		if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
293
+			include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
294 294
 		}
295 295
 
296
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
296
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
297 297
 	}
298 298
 
299 299
 	/**
@@ -304,21 +304,21 @@  discard block
 block discarded – undo
304 304
 	 * @since       1.0.19
305 305
 	 * @return      void
306 306
 	 */
307
-	public function autoload( $class_name ) {
307
+	public function autoload($class_name) {
308 308
 
309 309
 		// Normalize the class name...
310
-		$class_name  = strtolower( $class_name );
310
+		$class_name = strtolower($class_name);
311 311
 
312 312
 		// ... and make sure it is our class.
313
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
313
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
314 314
 			return;
315 315
 		}
316 316
 
317 317
 		// Next, prepare the file name from the class.
318
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
318
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
319 319
 
320 320
 		// Base path of the classes.
321
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
321
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
322 322
 
323 323
 		// And an array of possible locations in order of importance.
324 324
 		$locations = array(
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 			"$plugin_path/includes/admin/meta-boxes",
331 331
 		);
332 332
 
333
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
333
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
334 334
 
335
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
336
-				include trailingslashit( $location ) . $file_name;
335
+			if (file_exists(trailingslashit($location) . $file_name)) {
336
+				include trailingslashit($location) . $file_name;
337 337
 				break;
338 338
 			}
339 339
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	public function init() {
348 348
 
349 349
 		// Fires before getpaid inits.
350
-		do_action( 'before_getpaid_init', $this );
350
+		do_action('before_getpaid_init', $this);
351 351
 
352 352
 		// Load default gateways.
353 353
 		$gateways = apply_filters(
@@ -361,12 +361,12 @@  discard block
 block discarded – undo
361 361
 			)
362 362
 		);
363 363
 
364
-		foreach ( $gateways as $id => $class ) {
365
-			$this->gateways[ $id ] = new $class();
364
+		foreach ($gateways as $id => $class) {
365
+			$this->gateways[$id] = new $class();
366 366
 		}
367 367
 
368 368
 		// Fires after getpaid inits.
369
-		do_action( 'getpaid_init', $this );
369
+		do_action('getpaid_init', $this);
370 370
 
371 371
 	}
372 372
 
@@ -376,69 +376,69 @@  discard block
 block discarded – undo
376 376
 	public function maybe_process_ipn() {
377 377
 
378 378
 		// Ensure that this is an IPN request.
379
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
379
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
380 380
 			return;
381 381
 		}
382 382
 
383
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
383
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
384 384
 
385
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
386
-		do_action( "wpinv_verify_{$gateway}_ipn" );
385
+		do_action('wpinv_verify_payment_ipn', $gateway);
386
+		do_action("wpinv_verify_{$gateway}_ipn");
387 387
 		exit;
388 388
 
389 389
 	}
390 390
 
391 391
 	public function enqueue_scripts() {
392
-		$suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
392
+		$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
393 393
 
394
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
395
-		wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
396
-		wp_enqueue_style( 'wpinv_front_style' );
394
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
395
+		wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
396
+		wp_enqueue_style('wpinv_front_style');
397 397
 
398 398
 		// Register scripts
399
-		wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
400
-		wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
399
+		wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
400
+		wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
401 401
 
402 402
 		$localize                         = array();
403
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
404
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
403
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
404
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
405 405
 		$localize['currency_symbol']      = wpinv_currency_symbol();
406 406
 		$localize['currency_pos']         = wpinv_currency_position();
407 407
 		$localize['thousand_sep']         = wpinv_thousands_separator();
408 408
 		$localize['decimal_sep']          = wpinv_decimal_separator();
409 409
 		$localize['decimals']             = wpinv_decimals();
410
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
410
+		$localize['txtComplete']          = __('Continue', 'invoicing');
411 411
 		$localize['UseTaxes']             = wpinv_use_taxes();
412
-		$localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
413
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
414
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
412
+		$localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
413
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
414
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
415 415
 
416
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
416
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
417 417
 
418
-		wp_enqueue_script( 'jquery-blockui' );
418
+		wp_enqueue_script('jquery-blockui');
419 419
 		$autofill_api = wpinv_get_option('address_autofill_api');
420 420
 		$autofill_active = wpinv_get_option('address_autofill_active');
421
-		if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
422
-			if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
423
-				wp_dequeue_script( 'google-maps-api' );
421
+		if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
422
+			if (wp_script_is('google-maps-api', 'enqueued')) {
423
+				wp_dequeue_script('google-maps-api');
424 424
 			}
425
-			wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
426
-			wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
425
+			wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
426
+			wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
427 427
 		}
428 428
 
429
-		wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
430
-		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
429
+		wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
430
+		wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
431 431
 
432
-		wp_enqueue_script( 'wpinv-front-script' );
433
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
432
+		wp_enqueue_script('wpinv-front-script');
433
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
434 434
 
435
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
436
-		wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
435
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
436
+		wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
437 437
 	}
438 438
 
439 439
 	public function wpinv_actions() {
440
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
441
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
440
+		if (isset($_REQUEST['wpi_action'])) {
441
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
442 442
 		}
443 443
 	}
444 444
 
@@ -450,23 +450,23 @@  discard block
 block discarded – undo
450 450
      */
451 451
     public function maybe_do_authenticated_action() {
452 452
 
453
-        if ( is_user_logged_in() && isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
454
-            $key = sanitize_key( $_REQUEST['getpaid-action'] );
455
-            do_action( "getpaid_authenticated_action_$key", $_REQUEST );
453
+        if (is_user_logged_in() && isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
454
+            $key = sanitize_key($_REQUEST['getpaid-action']);
455
+            do_action("getpaid_authenticated_action_$key", $_REQUEST);
456 456
         }
457 457
 
458 458
     }
459 459
 
460
-	public function pre_get_posts( $wp_query ) {
461
-		if ( ! is_admin() && !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() ) {
462
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
460
+	public function pre_get_posts($wp_query) {
461
+		if (!is_admin() && !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()) {
462
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
463 463
 		}
464 464
 
465 465
 		return $wp_query;
466 466
 	}
467 467
 
468 468
 	public function bp_invoicing_init() {
469
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
469
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
470 470
 	}
471 471
 
472 472
 	/**
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 			)
488 488
 		);
489 489
 
490
-		foreach ( $widgets as $widget ) {
491
-			register_widget( $widget );
490
+		foreach ($widgets as $widget) {
491
+			register_widget($widget);
492 492
 		}
493 493
 		
494 494
 	}
@@ -499,10 +499,10 @@  discard block
 block discarded – undo
499 499
 	 * @since 1.0.19
500 500
 	 * @param int[] $excluded_posts_ids
501 501
 	 */
502
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
502
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
503 503
 
504 504
 		// Ensure that we have an array.
505
-		if ( ! is_array( $excluded_posts_ids ) ) {
505
+		if (!is_array($excluded_posts_ids)) {
506 506
 			$excluded_posts_ids = array();
507 507
 		}
508 508
 
@@ -510,24 +510,24 @@  discard block
 block discarded – undo
510 510
 		$our_pages = array();
511 511
 
512 512
 		// Checkout page.
513
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
513
+		$our_pages[] = wpinv_get_option('checkout_page', false);
514 514
 
515 515
 		// Success page.
516
-		$our_pages[] = wpinv_get_option( 'success_page', false );
516
+		$our_pages[] = wpinv_get_option('success_page', false);
517 517
 
518 518
 		// Failure page.
519
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
519
+		$our_pages[] = wpinv_get_option('failure_page', false);
520 520
 
521 521
 		// History page.
522
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
522
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
523 523
 
524 524
 		// Subscriptions page.
525
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
525
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
526 526
 
527
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
527
+		$our_pages   = array_map('intval', array_filter($our_pages));
528 528
 
529 529
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
530
-		return array_unique( $excluded_posts_ids );
530
+		return array_unique($excluded_posts_ids);
531 531
 
532 532
 	}
533 533
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +532 added lines, -532 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,155 +228,155 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
298
-    $args = array( 'nopaging' => true );
297
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
298
+    $args = array('nopaging' => true);
299 299
 
300
-    if ( ! empty( $status ) )
300
+    if (!empty($status))
301 301
         $args['post_status'] = $status;
302 302
 
303
-    $discounts = wpinv_get_discounts( $args );
303
+    $discounts = wpinv_get_discounts($args);
304 304
     $options   = array();
305 305
 
306
-    if ( $discounts ) {
307
-        foreach ( $discounts as $discount ) {
308
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
306
+    if ($discounts) {
307
+        foreach ($discounts as $discount) {
308
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
309 309
         }
310 310
     } else {
311
-        $options[0] = __( 'No discounts found', 'invoicing' );
311
+        $options[0] = __('No discounts found', 'invoicing');
312 312
     }
313 313
 
314
-    $output = wpinv_html_select( array(
314
+    $output = wpinv_html_select(array(
315 315
         'name'             => $name,
316 316
         'selected'         => $selected,
317 317
         'options'          => $options,
318 318
         'show_option_all'  => false,
319 319
         'show_option_none' => false,
320
-    ) );
320
+    ));
321 321
 
322 322
     return $output;
323 323
 }
324 324
 
325
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-    $current     = date( 'Y' );
327
-    $start_year  = $current - absint( $years_before );
328
-    $end_year    = $current + absint( $years_after );
329
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
325
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+    $current     = date('Y');
327
+    $start_year  = $current - absint($years_before);
328
+    $end_year    = $current + absint($years_after);
329
+    $selected    = empty($selected) ? date('Y') : $selected;
330 330
     $options     = array();
331 331
 
332
-    while ( $start_year <= $end_year ) {
333
-        $options[ absint( $start_year ) ] = $start_year;
332
+    while ($start_year <= $end_year) {
333
+        $options[absint($start_year)] = $start_year;
334 334
         $start_year++;
335 335
     }
336 336
 
337
-    $output = wpinv_html_select( array(
337
+    $output = wpinv_html_select(array(
338 338
         'name'             => $name,
339 339
         'selected'         => $selected,
340 340
         'options'          => $options,
341 341
         'show_option_all'  => false,
342 342
         'show_option_none' => false
343
-    ) );
343
+    ));
344 344
 
345 345
     return $output;
346 346
 }
347 347
 
348
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
348
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
349 349
 
350 350
     $options = array(
351
-        '1'  => __( 'January', 'invoicing' ),
352
-        '2'  => __( 'February', 'invoicing' ),
353
-        '3'  => __( 'March', 'invoicing' ),
354
-        '4'  => __( 'April', 'invoicing' ),
355
-        '5'  => __( 'May', 'invoicing' ),
356
-        '6'  => __( 'June', 'invoicing' ),
357
-        '7'  => __( 'July', 'invoicing' ),
358
-        '8'  => __( 'August', 'invoicing' ),
359
-        '9'  => __( 'September', 'invoicing' ),
360
-        '10' => __( 'October', 'invoicing' ),
361
-        '11' => __( 'November', 'invoicing' ),
362
-        '12' => __( 'December', 'invoicing' ),
351
+        '1'  => __('January', 'invoicing'),
352
+        '2'  => __('February', 'invoicing'),
353
+        '3'  => __('March', 'invoicing'),
354
+        '4'  => __('April', 'invoicing'),
355
+        '5'  => __('May', 'invoicing'),
356
+        '6'  => __('June', 'invoicing'),
357
+        '7'  => __('July', 'invoicing'),
358
+        '8'  => __('August', 'invoicing'),
359
+        '9'  => __('September', 'invoicing'),
360
+        '10' => __('October', 'invoicing'),
361
+        '11' => __('November', 'invoicing'),
362
+        '12' => __('December', 'invoicing'),
363 363
     );
364 364
 
365 365
     // If no month is selected, default to the current month
366
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
366
+    $selected = empty($selected) ? date('n') : $selected;
367 367
 
368
-    $output = wpinv_html_select( array(
368
+    $output = wpinv_html_select(array(
369 369
         'name'             => $name,
370 370
         'selected'         => $selected,
371 371
         'options'          => $options,
372 372
         'show_option_all'  => false,
373 373
         'show_option_none' => false
374
-    ) );
374
+    ));
375 375
 
376 376
     return $output;
377 377
 }
378 378
 
379
-function wpinv_html_select( $args = array() ) {
379
+function wpinv_html_select($args = array()) {
380 380
     $defaults = array(
381 381
         'options'          => array(),
382 382
         'name'             => null,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         'selected'         => 0,
386 386
         'placeholder'      => null,
387 387
         'multiple'         => false,
388
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
389
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
388
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
389
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
390 390
         'data'             => array(),
391 391
         'onchange'         => null,
392 392
         'required'         => false,
@@ -394,74 +394,74 @@  discard block
 block discarded – undo
394 394
         'readonly'         => false,
395 395
     );
396 396
 
397
-    $args = wp_parse_args( $args, $defaults );
397
+    $args = wp_parse_args($args, $defaults);
398 398
 
399 399
     $data_elements = '';
400
-    foreach ( $args['data'] as $key => $value ) {
401
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
400
+    foreach ($args['data'] as $key => $value) {
401
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
402 402
     }
403 403
 
404
-    if( $args['multiple'] ) {
404
+    if ($args['multiple']) {
405 405
         $multiple = ' MULTIPLE';
406 406
     } else {
407 407
         $multiple = '';
408 408
     }
409 409
 
410
-    if( $args['placeholder'] ) {
410
+    if ($args['placeholder']) {
411 411
         $placeholder = $args['placeholder'];
412 412
     } else {
413 413
         $placeholder = '';
414 414
     }
415 415
     
416 416
     $options = '';
417
-    if( !empty( $args['onchange'] ) ) {
418
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
417
+    if (!empty($args['onchange'])) {
418
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
419 419
     }
420 420
     
421
-    if( !empty( $args['required'] ) ) {
421
+    if (!empty($args['required'])) {
422 422
         $options .= ' required="required"';
423 423
     }
424 424
     
425
-    if( !empty( $args['disabled'] ) ) {
425
+    if (!empty($args['disabled'])) {
426 426
         $options .= ' disabled';
427 427
     }
428 428
     
429
-    if( !empty( $args['readonly'] ) ) {
429
+    if (!empty($args['readonly'])) {
430 430
         $options .= ' readonly';
431 431
     }
432 432
 
433
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
434
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
433
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
434
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
435 435
 
436
-    if ( $args['show_option_all'] ) {
437
-        if( $args['multiple'] ) {
438
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
436
+    if ($args['show_option_all']) {
437
+        if ($args['multiple']) {
438
+            $selected = selected(true, in_array(0, $args['selected']), false);
439 439
         } else {
440
-            $selected = selected( $args['selected'], 0, false );
440
+            $selected = selected($args['selected'], 0, false);
441 441
         }
442
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
442
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
443 443
     }
444 444
 
445
-    if ( !empty( $args['options'] ) ) {
445
+    if (!empty($args['options'])) {
446 446
 
447
-        if ( $args['show_option_none'] ) {
448
-            if( $args['multiple'] ) {
449
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
447
+        if ($args['show_option_none']) {
448
+            if ($args['multiple']) {
449
+                $selected = selected(true, in_array("", $args['selected']), false);
450 450
             } else {
451
-                $selected = selected( $args['selected'] === "", true, false );
451
+                $selected = selected($args['selected'] === "", true, false);
452 452
             }
453
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
453
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
454 454
         }
455 455
 
456
-        foreach( $args['options'] as $key => $option ) {
456
+        foreach ($args['options'] as $key => $option) {
457 457
 
458
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
459
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
458
+            if ($args['multiple'] && is_array($args['selected'])) {
459
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
460 460
             } else {
461
-                $selected = selected( $args['selected'], $key, false );
461
+                $selected = selected($args['selected'], $key, false);
462 462
             }
463 463
 
464
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
464
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
465 465
         }
466 466
     }
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     return $output;
471 471
 }
472 472
 
473
-function wpinv_item_dropdown( $args = array() ) {
473
+function wpinv_item_dropdown($args = array()) {
474 474
     $defaults = array(
475 475
         'name'              => 'wpi_item',
476 476
         'id'                => 'wpi_item',
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
         'multiple'          => false,
479 479
         'selected'          => 0,
480 480
         'number'            => 100,
481
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
482
-        'data'              => array( 'search-type' => 'item' ),
481
+        'placeholder'       => __('Choose a item', 'invoicing'),
482
+        'data'              => array('search-type' => 'item'),
483 483
         'show_option_all'   => false,
484 484
         'show_option_none'  => false,
485 485
         'show_recurring'    => false,
486 486
     );
487 487
 
488
-    $args = wp_parse_args( $args, $defaults );
488
+    $args = wp_parse_args($args, $defaults);
489 489
 
490 490
     $item_args = array(
491 491
         'post_type'      => 'wpi_item',
@@ -494,44 +494,44 @@  discard block
 block discarded – undo
494 494
         'posts_per_page' => $args['number']
495 495
     );
496 496
 
497
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
497
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
498 498
 
499
-    $items      = get_posts( $item_args );
499
+    $items      = get_posts($item_args);
500 500
     $options    = array();
501
-    if ( $items ) {
502
-        foreach ( $items as $item ) {
503
-            $title = esc_html( $item->post_title );
501
+    if ($items) {
502
+        foreach ($items as $item) {
503
+            $title = esc_html($item->post_title);
504 504
             
505
-            if ( !empty( $args['show_recurring'] ) ) {
506
-                $title .= wpinv_get_item_suffix( $item->ID, false );
505
+            if (!empty($args['show_recurring'])) {
506
+                $title .= wpinv_get_item_suffix($item->ID, false);
507 507
             }
508 508
             
509
-            $options[ absint( $item->ID ) ] = $title;
509
+            $options[absint($item->ID)] = $title;
510 510
         }
511 511
     }
512 512
 
513 513
     // This ensures that any selected items are included in the drop down
514
-    if( is_array( $args['selected'] ) ) {
515
-        foreach( $args['selected'] as $item ) {
516
-            if( ! in_array( $item, $options ) ) {
517
-                $title = get_the_title( $item );
518
-                if ( !empty( $args['show_recurring'] ) ) {
519
-                    $title .= wpinv_get_item_suffix( $item, false );
514
+    if (is_array($args['selected'])) {
515
+        foreach ($args['selected'] as $item) {
516
+            if (!in_array($item, $options)) {
517
+                $title = get_the_title($item);
518
+                if (!empty($args['show_recurring'])) {
519
+                    $title .= wpinv_get_item_suffix($item, false);
520 520
                 }
521 521
                 $options[$item] = $title;
522 522
             }
523 523
         }
524
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
525
-        if ( ! in_array( $args['selected'], $options ) ) {
526
-            $title = get_the_title( $args['selected'] );
527
-            if ( !empty( $args['show_recurring'] ) ) {
528
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
524
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
525
+        if (!in_array($args['selected'], $options)) {
526
+            $title = get_the_title($args['selected']);
527
+            if (!empty($args['show_recurring'])) {
528
+                $title .= wpinv_get_item_suffix($args['selected'], false);
529 529
             }
530
-            $options[$args['selected']] = get_the_title( $args['selected'] );
530
+            $options[$args['selected']] = get_the_title($args['selected']);
531 531
         }
532 532
     }
533 533
 
534
-    $output = wpinv_html_select( array(
534
+    $output = wpinv_html_select(array(
535 535
         'name'             => $args['name'],
536 536
         'selected'         => $args['selected'],
537 537
         'id'               => $args['id'],
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         'show_option_all'  => $args['show_option_all'],
543 543
         'show_option_none' => $args['show_option_none'],
544 544
         'data'             => $args['data'],
545
-    ) );
545
+    ));
546 546
 
547 547
     return $output;
548 548
 }
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
     );
563 563
 
564 564
     $options = array();
565
-    if ( $items ) {
566
-        foreach ( $items as $item ) {
567
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
565
+    if ($items) {
566
+        foreach ($items as $item) {
567
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
568 568
         }
569 569
     }
570 570
 
571 571
     return $options;
572 572
 }
573 573
 
574
-function wpinv_html_checkbox( $args = array() ) {
574
+function wpinv_html_checkbox($args = array()) {
575 575
     $defaults = array(
576 576
         'name'     => null,
577 577
         'current'  => null,
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
         )
583 583
     );
584 584
 
585
-    $args = wp_parse_args( $args, $defaults );
585
+    $args = wp_parse_args($args, $defaults);
586 586
 
587
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
587
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
588 588
     $options = '';
589
-    if ( ! empty( $args['options']['disabled'] ) ) {
589
+    if (!empty($args['options']['disabled'])) {
590 590
         $options .= ' disabled="disabled"';
591
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
591
+    } elseif (!empty($args['options']['readonly'])) {
592 592
         $options .= ' readonly';
593 593
     }
594 594
 
595
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
595
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
596 596
 
597 597
     return $output;
598 598
 }
@@ -600,30 +600,30 @@  discard block
 block discarded – undo
600 600
 /**
601 601
  * Displays a hidden field.
602 602
  */
603
-function getpaid_hidden_field( $name, $value ) {
604
-    $name  = sanitize_text_field( $name );
605
-    $value = esc_attr( $value );
603
+function getpaid_hidden_field($name, $value) {
604
+    $name  = sanitize_text_field($name);
605
+    $value = esc_attr($value);
606 606
 
607 607
     echo "<input type='hidden' name='$name' value='$value' />";
608 608
 }
609 609
 
610
-function wpinv_html_text( $args = array() ) {
610
+function wpinv_html_text($args = array()) {
611 611
     // Backwards compatibility
612
-    if ( func_num_args() > 1 ) {
612
+    if (func_num_args() > 1) {
613 613
         $args = func_get_args();
614 614
 
615 615
         $name  = $args[0];
616
-        $value = isset( $args[1] ) ? $args[1] : '';
617
-        $label = isset( $args[2] ) ? $args[2] : '';
618
-        $desc  = isset( $args[3] ) ? $args[3] : '';
616
+        $value = isset($args[1]) ? $args[1] : '';
617
+        $label = isset($args[2]) ? $args[2] : '';
618
+        $desc  = isset($args[3]) ? $args[3] : '';
619 619
     }
620 620
 
621 621
     $defaults = array(
622 622
         'id'           => '',
623
-        'name'         => isset( $name )  ? $name  : 'text',
624
-        'value'        => isset( $value ) ? $value : null,
625
-        'label'        => isset( $label ) ? $label : null,
626
-        'desc'         => isset( $desc )  ? $desc  : null,
623
+        'name'         => isset($name) ? $name : 'text',
624
+        'value'        => isset($value) ? $value : null,
625
+        'label'        => isset($label) ? $label : null,
626
+        'desc'         => isset($desc) ? $desc : null,
627 627
         'placeholder'  => '',
628 628
         'class'        => 'regular-text',
629 629
         'disabled'     => false,
@@ -633,51 +633,51 @@  discard block
 block discarded – undo
633 633
         'data'         => false
634 634
     );
635 635
 
636
-    $args = wp_parse_args( $args, $defaults );
636
+    $args = wp_parse_args($args, $defaults);
637 637
 
638
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
638
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
639 639
     $options = '';
640
-    if( $args['required'] ) {
640
+    if ($args['required']) {
641 641
         $options .= ' required="required"';
642 642
     }
643
-    if( $args['readonly'] ) {
643
+    if ($args['readonly']) {
644 644
         $options .= ' readonly';
645 645
     }
646
-    if( $args['readonly'] ) {
646
+    if ($args['readonly']) {
647 647
         $options .= ' readonly';
648 648
     }
649 649
 
650 650
     $data = '';
651
-    if ( !empty( $args['data'] ) ) {
652
-        foreach ( $args['data'] as $key => $value ) {
653
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
651
+    if (!empty($args['data'])) {
652
+        foreach ($args['data'] as $key => $value) {
653
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
654 654
         }
655 655
     }
656 656
 
657
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
658
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
659
-    if ( ! empty( $args['desc'] ) ) {
660
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
657
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
658
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
659
+    if (!empty($args['desc'])) {
660
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
661 661
     }
662 662
 
663
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
663
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
664 664
 
665 665
     $output .= '</span>';
666 666
 
667 667
     return $output;
668 668
 }
669 669
 
670
-function wpinv_html_date_field( $args = array() ) {
671
-    if( empty( $args['class'] ) ) {
670
+function wpinv_html_date_field($args = array()) {
671
+    if (empty($args['class'])) {
672 672
         $args['class'] = 'wpiDatepicker';
673
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
673
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
674 674
         $args['class'] .= ' wpiDatepicker';
675 675
     }
676 676
 
677
-    return wpinv_html_text( $args );
677
+    return wpinv_html_text($args);
678 678
 }
679 679
 
680
-function wpinv_html_textarea( $args = array() ) {
680
+function wpinv_html_textarea($args = array()) {
681 681
     $defaults = array(
682 682
         'name'        => 'textarea',
683 683
         'value'       => null,
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
         'placeholder' => '',
689 689
     );
690 690
 
691
-    $args = wp_parse_args( $args, $defaults );
691
+    $args = wp_parse_args($args, $defaults);
692 692
 
693
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
693
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
694 694
     $disabled = '';
695
-    if( $args['disabled'] ) {
695
+    if ($args['disabled']) {
696 696
         $disabled = ' disabled="disabled"';
697 697
     }
698 698
 
699
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
700
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
701
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
699
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
700
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
701
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
702 702
 
703
-    if ( ! empty( $args['desc'] ) ) {
704
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
703
+    if (!empty($args['desc'])) {
704
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
705 705
     }
706 706
     $output .= '</span>';
707 707
 
708 708
     return $output;
709 709
 }
710 710
 
711
-function wpinv_html_ajax_user_search( $args = array() ) {
711
+function wpinv_html_ajax_user_search($args = array()) {
712 712
     $defaults = array(
713 713
         'name'        => 'user_id',
714 714
         'value'       => null,
715
-        'placeholder' => __( 'Enter username', 'invoicing' ),
715
+        'placeholder' => __('Enter username', 'invoicing'),
716 716
         'label'       => null,
717 717
         'desc'        => null,
718 718
         'class'       => '',
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
         'data'        => false
722 722
     );
723 723
 
724
-    $args = wp_parse_args( $args, $defaults );
724
+    $args = wp_parse_args($args, $defaults);
725 725
 
726 726
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
727 727
 
728 728
     $output  = '<span class="wpinv_user_search_wrap">';
729
-        $output .= wpinv_html_text( $args );
730
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
729
+        $output .= wpinv_html_text($args);
730
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
731 731
     $output .= '</span>';
732 732
 
733 733
     return $output;
@@ -743,20 +743,20 @@  discard block
 block discarded – undo
743 743
  * 
744 744
  * @param string $template the template that is currently being used.
745 745
  */
746
-function wpinv_template( $template ) {
746
+function wpinv_template($template) {
747 747
     global $post;
748 748
 
749
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
749
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
750 750
 
751 751
         // If the user can view this invoice, display it.
752
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
752
+        if (wpinv_user_can_view_invoice($post->ID)) {
753 753
 
754
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
754
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
755 755
 
756 756
         // Else display an error message.
757 757
         } else {
758 758
 
759
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
759
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
760 760
 
761 761
         }
762 762
 
@@ -764,46 +764,46 @@  discard block
 block discarded – undo
764 764
 
765 765
     return $template;
766 766
 }
767
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
767
+add_filter('template_include', 'wpinv_template', 10, 1);
768 768
 
769 769
 function wpinv_get_business_address() {
770 770
     $business_address   = wpinv_store_address();
771
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
771
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
772 772
     
773 773
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
774 774
     
775
-    return apply_filters( 'wpinv_get_business_address', $business_address );
775
+    return apply_filters('wpinv_get_business_address', $business_address);
776 776
 }
777 777
 
778 778
 /**
779 779
  * Displays the company address.
780 780
  */
781 781
 function wpinv_display_from_address() {
782
-    wpinv_get_template( 'invoice/company-address.php' );
782
+    wpinv_get_template('invoice/company-address.php');
783 783
 }
784
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
784
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
785 785
 
786
-function wpinv_watermark( $id = 0 ) {
787
-    $output = wpinv_get_watermark( $id );
788
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
786
+function wpinv_watermark($id = 0) {
787
+    $output = wpinv_get_watermark($id);
788
+    return apply_filters('wpinv_get_watermark', $output, $id);
789 789
 }
790 790
 
791
-function wpinv_get_watermark( $id ) {
792
-    if ( !$id > 0 ) {
791
+function wpinv_get_watermark($id) {
792
+    if (!$id > 0) {
793 793
         return NULL;
794 794
     }
795 795
 
796
-    $invoice = wpinv_get_invoice( $id );
796
+    $invoice = wpinv_get_invoice($id);
797 797
     
798
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
799
-        if ( $invoice->is_paid() ) {
800
-            return __( 'Paid', 'invoicing' );
798
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
799
+        if ($invoice->is_paid()) {
800
+            return __('Paid', 'invoicing');
801 801
         }
802
-        if ( $invoice->is_refunded() ) {
803
-            return __( 'Refunded', 'invoicing' );
802
+        if ($invoice->is_refunded()) {
803
+            return __('Refunded', 'invoicing');
804 804
         }
805
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
806
-            return __( 'Cancelled', 'invoicing' );
805
+        if ($invoice->has_status(array('wpi-cancelled'))) {
806
+            return __('Cancelled', 'invoicing');
807 807
         }
808 808
     }
809 809
     
@@ -813,140 +813,140 @@  discard block
 block discarded – undo
813 813
 /**
814 814
  * @deprecated
815 815
  */
816
-function wpinv_display_invoice_details( $invoice ) {
817
-    return getpaid_invoice_meta( $invoice );
816
+function wpinv_display_invoice_details($invoice) {
817
+    return getpaid_invoice_meta($invoice);
818 818
 }
819 819
 
820 820
 /**
821 821
  * Displays invoice meta.
822 822
  */
823
-function getpaid_invoice_meta( $invoice ) {
823
+function getpaid_invoice_meta($invoice) {
824 824
 
825
-    $invoice = new WPInv_Invoice( $invoice );
825
+    $invoice = new WPInv_Invoice($invoice);
826 826
 
827 827
     // Ensure that we have an invoice.
828
-    if ( 0 == $invoice->get_id() ) {
828
+    if (0 == $invoice->get_id()) {
829 829
         return;
830 830
     }
831 831
 
832 832
     // Load the invoice meta.
833
-    $meta    = array(
833
+    $meta = array(
834 834
 
835 835
         'number' => array(
836 836
             'label' => sprintf(
837
-                __( '%s Number', 'invoicing' ),
838
-                ucfirst( $invoice->get_type() )
837
+                __('%s Number', 'invoicing'),
838
+                ucfirst($invoice->get_type())
839 839
             ),
840
-            'value' => sanitize_text_field( $invoice->get_number() ),
840
+            'value' => sanitize_text_field($invoice->get_number()),
841 841
         ),
842 842
 
843 843
         'status' => array(
844 844
             'label' => sprintf(
845
-                __( '%s Status', 'invoicing' ),
846
-                ucfirst( $invoice->get_type() )
845
+                __('%s Status', 'invoicing'),
846
+                ucfirst($invoice->get_type())
847 847
             ),
848 848
             'value' => $invoice->get_status_label_html(),
849 849
         ),
850 850
 
851 851
         'date' => array(
852 852
             'label' => sprintf(
853
-                __( '%s Date', 'invoicing' ),
854
-                ucfirst( $invoice->get_type() )
853
+                __('%s Date', 'invoicing'),
854
+                ucfirst($invoice->get_type())
855 855
             ),
856
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
856
+            'value' => getpaid_format_date($invoice->get_created_date()),
857 857
         ),
858 858
 
859 859
         'date_paid' => array(
860
-            'label' => __( 'Paid On', 'invoicing' ),
861
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
860
+            'label' => __('Paid On', 'invoicing'),
861
+            'value' => getpaid_format_date($invoice->get_completed_date()),
862 862
         ),
863 863
 
864 864
         'gateway'   => array(
865
-            'label' => __( 'Payment Method', 'invoicing' ),
866
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
865
+            'label' => __('Payment Method', 'invoicing'),
866
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
867 867
         ),
868 868
 
869 869
         'transaction_id' => array(
870
-            'label' => __( 'Transaction ID', 'invoicing' ),
871
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
870
+            'label' => __('Transaction ID', 'invoicing'),
871
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
872 872
         ),
873 873
 
874 874
         'due_date'  => array(
875
-            'label' => __( 'Due Date', 'invoicing' ),
876
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
875
+            'label' => __('Due Date', 'invoicing'),
876
+            'value' => getpaid_format_date($invoice->get_due_date()),
877 877
         ),
878 878
 
879 879
         'vat_number' => array(
880 880
             'label' => sprintf(
881
-                __( '%s Number', 'invoicing' ),
881
+                __('%s Number', 'invoicing'),
882 882
                 getpaid_tax()->get_vat_name()
883 883
             ),
884
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
884
+            'value' => sanitize_text_field($invoice->get_vat_number()),
885 885
         ),
886 886
 
887 887
     );
888 888
 
889 889
     // If it is not paid, remove the date of payment.
890
-    if ( ! $invoice->is_paid() ) {
891
-        unset( $meta[ 'date_paid' ] );
892
-        unset( $meta[ 'transaction_id' ] );
890
+    if (!$invoice->is_paid()) {
891
+        unset($meta['date_paid']);
892
+        unset($meta['transaction_id']);
893 893
     }
894 894
 
895
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
896
-        unset( $meta[ 'gateway' ] );
895
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
896
+        unset($meta['gateway']);
897 897
     }
898 898
 
899 899
     // Only display the due date if due dates are enabled.
900
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
901
-        unset( $meta[ 'due_date' ] );
900
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
901
+        unset($meta['due_date']);
902 902
     }
903 903
 
904 904
     // Only display the vat number if taxes are enabled.
905
-    if ( ! wpinv_use_taxes() ) {
906
-        unset( $meta[ 'vat_number' ] );
905
+    if (!wpinv_use_taxes()) {
906
+        unset($meta['vat_number']);
907 907
     }
908 908
 
909
-    if ( $invoice->is_recurring() ) {
909
+    if ($invoice->is_recurring()) {
910 910
 
911 911
         // Link to the parent invoice.
912
-        if ( $invoice->is_renewal() ) {
912
+        if ($invoice->is_renewal()) {
913 913
 
914
-            $meta[ 'parent' ] = array(
914
+            $meta['parent'] = array(
915 915
 
916 916
                 'label' => sprintf(
917
-                    __( 'Parent %s', 'invoicing' ),
918
-                    ucfirst( $invoice->get_type() )
917
+                    __('Parent %s', 'invoicing'),
918
+                    ucfirst($invoice->get_type())
919 919
                 ),
920 920
 
921
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
921
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
922 922
 
923 923
             );
924 924
 
925 925
         }
926 926
 
927
-        $subscription = wpinv_get_subscription( $invoice );
927
+        $subscription = wpinv_get_subscription($invoice);
928 928
 
929
-        if ( ! empty ( $subscription ) ) {
929
+        if (!empty ($subscription)) {
930 930
 
931 931
             // Display the renewal date.
932
-            if ( $subscription->is_active() && 'cancelled' != $subscription->status ) {
932
+            if ($subscription->is_active() && 'cancelled' != $subscription->status) {
933 933
 
934
-                $meta[ 'renewal_date' ] = array(
934
+                $meta['renewal_date'] = array(
935 935
 
936
-                    'label' => __( 'Renews On', 'invoicing' ),
937
-                    'value' => getpaid_format_date( $subscription->expiration ),
936
+                    'label' => __('Renews On', 'invoicing'),
937
+                    'value' => getpaid_format_date($subscription->expiration),
938 938
         
939 939
                 );
940 940
 
941 941
             }
942 942
 
943
-            if ( $invoice->is_parent() ) {
943
+            if ($invoice->is_parent()) {
944 944
 
945 945
                 // Display the recurring amount.
946
-                $meta[ 'recurring_total' ] = array(
946
+                $meta['recurring_total'] = array(
947 947
 
948
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
949
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ),
948
+                    'label' => __('Recurring Amount', 'invoicing'),
949
+                    'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()),
950 950
         
951 951
                 );
952 952
 
@@ -956,20 +956,20 @@  discard block
 block discarded – undo
956 956
     }
957 957
 
958 958
     // Add the invoice total to the meta.
959
-    $meta[ 'invoice_total' ] = array(
959
+    $meta['invoice_total'] = array(
960 960
 
961
-        'label' => __( 'Total Amount', 'invoicing' ),
962
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
961
+        'label' => __('Total Amount', 'invoicing'),
962
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
963 963
 
964 964
     );
965 965
 
966 966
     // Provide a way for third party plugins to filter the meta.
967
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
967
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
968 968
 
969
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
969
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
970 970
 
971 971
 }
972
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
972
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
973 973
 
974 974
 /**
975 975
  * Retrieves the address markup to use on Invoices.
@@ -981,29 +981,29 @@  discard block
 block discarded – undo
981 981
  * @param  string $separator How to separate address lines.
982 982
  * @return string
983 983
  */
984
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
984
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
985 985
 
986 986
     // Retrieve the address markup...
987
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
988
-    $format = wpinv_get_full_address_format( $country );
987
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
988
+    $format = wpinv_get_full_address_format($country);
989 989
 
990 990
     // ... and the replacements.
991
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
991
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
992 992
 
993
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
993
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
994 994
     
995 995
 	// Remove unavailable tags.
996
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
996
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
997 997
 
998 998
     // Clean up white space.
999
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
1000
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
999
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
1000
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
1001 1001
     
1002 1002
     // Break newlines apart and remove empty lines/trim commas and white space.
1003
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
1003
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
1004 1004
 
1005 1005
     // Add html breaks.
1006
-	$formatted_address = implode( $separator, $formatted_address );
1006
+	$formatted_address = implode($separator, $formatted_address);
1007 1007
 
1008 1008
 	// We're done!
1009 1009
 	return $formatted_address;
@@ -1015,88 +1015,88 @@  discard block
 block discarded – undo
1015 1015
  * 
1016 1016
  * @param WPInv_Invoice $invoice
1017 1017
  */
1018
-function wpinv_display_to_address( $invoice = 0 ) {
1019
-    if ( ! empty( $invoice ) ) {
1020
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
1018
+function wpinv_display_to_address($invoice = 0) {
1019
+    if (!empty($invoice)) {
1020
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
1021 1021
     }
1022 1022
 }
1023
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
1023
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
1024 1024
 
1025 1025
 
1026 1026
 /**
1027 1027
  * Displays invoice line items.
1028 1028
  */
1029
-function wpinv_display_line_items( $invoice_id = 0 ) {
1029
+function wpinv_display_line_items($invoice_id = 0) {
1030 1030
 
1031 1031
     // Prepare the invoice.
1032
-    $invoice = new WPInv_Invoice( $invoice_id );
1032
+    $invoice = new WPInv_Invoice($invoice_id);
1033 1033
 
1034 1034
     // Abort if there is no invoice.
1035
-    if ( 0 == $invoice->get_id() ) {
1035
+    if (0 == $invoice->get_id()) {
1036 1036
         return;
1037 1037
     }
1038 1038
 
1039 1039
     // Line item columns.
1040
-    $columns = getpaid_invoice_item_columns( $invoice );
1041
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
1040
+    $columns = getpaid_invoice_item_columns($invoice);
1041
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
1042 1042
 
1043
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
1043
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
1044 1044
 }
1045
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
1045
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
1046 1046
 
1047 1047
 /**
1048 1048
  * Displays invoice notices on invoices.
1049 1049
  */
1050 1050
 function wpinv_display_invoice_notice() {
1051 1051
 
1052
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
1053
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
1052
+    $label  = wpinv_get_option('vat_invoice_notice_label');
1053
+    $notice = wpinv_get_option('vat_invoice_notice');
1054 1054
 
1055
-    if ( empty( $label ) && empty( $notice ) ) {
1055
+    if (empty($label) && empty($notice)) {
1056 1056
         return;
1057 1057
     }
1058 1058
 
1059 1059
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
1060 1060
 
1061
-    if ( ! empty( $label ) ) {
1062
-        $label = sanitize_text_field( $label );
1061
+    if (!empty($label)) {
1062
+        $label = sanitize_text_field($label);
1063 1063
         echo "<h5>$label</h5>";
1064 1064
     }
1065 1065
 
1066
-    if ( ! empty( $notice ) ) {
1067
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
1066
+    if (!empty($notice)) {
1067
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
1068 1068
     }
1069 1069
 
1070 1070
     echo '</div>';
1071 1071
 }
1072
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
1072
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
1073 1073
 
1074 1074
 /**
1075 1075
  * @param WPInv_Invoice $invoice
1076 1076
  */
1077
-function wpinv_display_invoice_notes( $invoice ) {
1077
+function wpinv_display_invoice_notes($invoice) {
1078 1078
 
1079 1079
     // Retrieve the notes.
1080
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
1080
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
1081 1081
 
1082 1082
     // Abort if we have non.
1083
-    if ( empty( $notes ) ) {
1083
+    if (empty($notes)) {
1084 1084
         return;
1085 1085
     }
1086 1086
 
1087 1087
     // Echo the note.
1088 1088
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
1089
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
1089
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
1090 1090
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
1091 1091
 
1092
-    foreach( $notes as $note ) {
1093
-        wpinv_get_invoice_note_line_item( $note );
1092
+    foreach ($notes as $note) {
1093
+        wpinv_get_invoice_note_line_item($note);
1094 1094
     }
1095 1095
 
1096 1096
     echo '</ul>';
1097 1097
     echo '</div>';
1098 1098
 }
1099
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
1099
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
1100 1100
 
1101 1101
 /**
1102 1102
  * Loads scripts on our invoice templates.
@@ -1104,32 +1104,32 @@  discard block
 block discarded – undo
1104 1104
 function wpinv_display_style() {
1105 1105
 
1106 1106
     // Make sure that all scripts have been loaded.
1107
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
1108
-        do_action( 'wp_enqueue_scripts' );
1107
+    if (!did_action('wp_enqueue_scripts')) {
1108
+        do_action('wp_enqueue_scripts');
1109 1109
     }
1110 1110
 
1111 1111
     // Register the invoices style.
1112
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
1112
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
1113 1113
 
1114 1114
     // Load required styles
1115
-    wp_print_styles( 'open-sans' );
1116
-    wp_print_styles( 'wpinv-single-style' );
1117
-    wp_print_styles( 'ayecode-ui' );
1115
+    wp_print_styles('open-sans');
1116
+    wp_print_styles('wpinv-single-style');
1117
+    wp_print_styles('ayecode-ui');
1118 1118
 
1119 1119
     // Maybe load custom css.
1120
-    $custom_css = wpinv_get_option( 'template_custom_css' );
1120
+    $custom_css = wpinv_get_option('template_custom_css');
1121 1121
 
1122
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
1123
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1124
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1122
+    if (isset($custom_css) && !empty($custom_css)) {
1123
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1124
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1125 1125
         echo '<style type="text/css">';
1126 1126
         echo $custom_css;
1127 1127
         echo '</style>';
1128 1128
     }
1129 1129
 
1130 1130
 }
1131
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1132
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1131
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1132
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1133 1133
 
1134 1134
 
1135 1135
 /**
@@ -1141,41 +1141,41 @@  discard block
 block discarded – undo
1141 1141
     // Retrieve the current invoice.
1142 1142
     $invoice_id = getpaid_get_current_invoice_id();
1143 1143
 
1144
-    if ( empty( $invoice_id ) ) {
1144
+    if (empty($invoice_id)) {
1145 1145
 
1146 1146
         return aui()->alert(
1147 1147
             array(
1148 1148
                 'type'    => 'warning',
1149
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1149
+                'content' => __('Invalid invoice', 'invoicing'),
1150 1150
             )
1151 1151
         );
1152 1152
 
1153 1153
     }
1154 1154
 
1155 1155
     // Can the user view this invoice?
1156
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1156
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1157 1157
 
1158 1158
         return aui()->alert(
1159 1159
             array(
1160 1160
                 'type'    => 'warning',
1161
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1161
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1162 1162
             )
1163 1163
         );
1164 1164
 
1165 1165
     }
1166 1166
 
1167 1167
     // Ensure that it is not yet paid for.
1168
-    $invoice = new WPInv_Invoice( $invoice_id );
1168
+    $invoice = new WPInv_Invoice($invoice_id);
1169 1169
 
1170 1170
     // Maybe mark it as viewed.
1171
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1171
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1172 1172
 
1173
-    if ( $invoice->is_paid() ) {
1173
+    if ($invoice->is_paid()) {
1174 1174
 
1175 1175
         return aui()->alert(
1176 1176
             array(
1177 1177
                 'type'    => 'success',
1178
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1178
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1179 1179
             )
1180 1180
         );
1181 1181
 
@@ -1185,14 +1185,14 @@  discard block
 block discarded – undo
1185 1185
     $wpi_checkout_id = $invoice_id;
1186 1186
 
1187 1187
     // We'll display this invoice via the default form.
1188
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1188
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1189 1189
 
1190
-    if ( 0 == $form->get_id() ) {
1190
+    if (0 == $form->get_id()) {
1191 1191
 
1192 1192
         return aui()->alert(
1193 1193
             array(
1194 1194
                 'type'    => 'warning',
1195
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1195
+                'content' => __('Error loading the payment form', 'invoicing'),
1196 1196
             )
1197 1197
         );
1198 1198
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 
1201 1201
     // Set the invoice.
1202 1202
     $form->invoice = $invoice;
1203
-    $form->set_items( $invoice->get_items() );
1203
+    $form->set_items($invoice->get_items());
1204 1204
 
1205 1205
     // Generate the html.
1206 1206
     return $form->get_html();
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 }
1209 1209
 
1210 1210
 function wpinv_empty_cart_message() {
1211
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1211
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1225,38 +1225,38 @@  discard block
 block discarded – undo
1225 1225
         )
1226 1226
     );
1227 1227
 }
1228
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1228
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1229 1229
 
1230
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1231
-    $invoice = wpinv_get_invoice( $invoice_id );
1230
+function wpinv_receipt_billing_address($invoice_id = 0) {
1231
+    $invoice = wpinv_get_invoice($invoice_id);
1232 1232
 
1233
-    if ( empty( $invoice ) ) {
1233
+    if (empty($invoice)) {
1234 1234
         return NULL;
1235 1235
     }
1236 1236
 
1237 1237
     $billing_details = $invoice->get_user_info();
1238
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1238
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1239 1239
 
1240 1240
     ob_start();
1241 1241
     ?>
1242 1242
     <table class="table table-bordered table-sm wpi-billing-details">
1243 1243
         <tbody>
1244 1244
             <tr class="wpi-receipt-name">
1245
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1246
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1245
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1246
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1247 1247
             </tr>
1248 1248
             <tr class="wpi-receipt-email">
1249
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1250
-                <td><?php echo $billing_details['email'] ;?></td>
1249
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1250
+                <td><?php echo $billing_details['email']; ?></td>
1251 1251
             </tr>
1252 1252
             <tr class="wpi-receipt-address">
1253
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1254
-                <td><?php echo $address_row ;?></td>
1253
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1254
+                <td><?php echo $address_row; ?></td>
1255 1255
             </tr>
1256
-            <?php if ( $billing_details['phone'] ) { ?>
1256
+            <?php if ($billing_details['phone']) { ?>
1257 1257
             <tr class="wpi-receipt-phone">
1258
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1259
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1258
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1259
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1260 1260
             </tr>
1261 1261
             <?php } ?>
1262 1262
         </tbody>
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     <?php
1265 1265
     $output = ob_get_clean();
1266 1266
     
1267
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1267
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1268 1268
 
1269 1269
     echo $output;
1270 1270
 }
@@ -1272,56 +1272,56 @@  discard block
 block discarded – undo
1272 1272
 /**
1273 1273
  * Filters the receipt page.
1274 1274
  */
1275
-function wpinv_filter_success_page_content( $content ) {
1275
+function wpinv_filter_success_page_content($content) {
1276 1276
 
1277 1277
     // Ensure this is our page.
1278
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1278
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1279 1279
 
1280
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1281
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1280
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1281
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1282 1282
 
1283 1283
     }
1284 1284
 
1285 1285
     return $content;
1286 1286
 }
1287
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1287
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1288 1288
 
1289
-function wpinv_invoice_link( $invoice_id ) {
1290
-    $invoice = wpinv_get_invoice( $invoice_id );
1289
+function wpinv_invoice_link($invoice_id) {
1290
+    $invoice = wpinv_get_invoice($invoice_id);
1291 1291
 
1292
-    if ( empty( $invoice ) ) {
1292
+    if (empty($invoice)) {
1293 1293
         return NULL;
1294 1294
     }
1295 1295
 
1296
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1296
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1297 1297
 
1298
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1298
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1299 1299
 }
1300 1300
 
1301
-function wpinv_invoice_subscription_details( $invoice ) {
1302
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1303
-        $subscription = wpinv_get_subscription( $invoice, true );
1301
+function wpinv_invoice_subscription_details($invoice) {
1302
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1303
+        $subscription = wpinv_get_subscription($invoice, true);
1304 1304
 
1305
-        if ( empty( $subscription ) ) {
1305
+        if (empty($subscription)) {
1306 1306
             return;
1307 1307
         }
1308 1308
 
1309 1309
         $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
1310
-        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency() ) . ' / ' . $frequency;
1311
-        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency() );
1310
+        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()) . ' / ' . $frequency;
1311
+        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency());
1312 1312
 
1313 1313
         $payments = $subscription->get_child_payments();
1314 1314
         ?>
1315 1315
         <div class="wpinv-subscriptions-details">
1316
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1316
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1317 1317
             <table class="table">
1318 1318
                 <thead>
1319 1319
                     <tr>
1320
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1321
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1322
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1323
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1324
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1320
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1321
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1322
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1323
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1324
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1325 1325
                     </tr>
1326 1326
                 </thead>
1327 1327
                 <tbody>
@@ -1329,35 +1329,35 @@  discard block
 block discarded – undo
1329 1329
                         <td><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?></td>
1330 1330
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?></td>
1331 1331
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?></td>
1332
-                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->bill_times); ?></td>
1332
+                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $subscription->bill_times); ?></td>
1333 1333
                         <td class="text-center wpi-sub-status"><?php echo $subscription->get_status_label(); ?></td>
1334 1334
                     </tr>
1335 1335
                 </tbody>
1336 1336
             </table>
1337 1337
         </div>
1338
-        <?php if ( !empty( $payments ) ) { ?>
1338
+        <?php if (!empty($payments)) { ?>
1339 1339
         <div class="wpinv-renewal-payments">
1340
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1340
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1341 1341
             <table class="table">
1342 1342
                 <thead>
1343 1343
                     <tr>
1344 1344
                         <th>#</th>
1345
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1346
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1347
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1345
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1346
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1347
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1348 1348
                     </tr>
1349 1349
                 </thead>
1350 1350
                 <tbody>
1351 1351
                     <?php
1352 1352
                         $i = 1;
1353
-                        foreach ( $payments as $payment ) {
1353
+                        foreach ($payments as $payment) {
1354 1354
                             $invoice_id = $payment->ID;
1355 1355
                     ?>
1356 1356
                     <tr>
1357
-                        <th scope="row"><?php echo $i;?></th>
1358
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1357
+                        <th scope="row"><?php echo $i; ?></th>
1358
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1359 1359
                         <td><?php echo$invoice->get_date_created(); ?></td>
1360
-                        <td class="text-right"><?php echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); ?></td>
1360
+                        <td class="text-right"><?php echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); ?></td>
1361 1361
                     </tr>
1362 1362
                     <?php $i++; } ?>
1363 1363
                 </tbody>
@@ -1367,64 +1367,64 @@  discard block
 block discarded – undo
1367 1367
         <?php
1368 1368
     }
1369 1369
 }
1370
-add_action( 'getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20 );
1370
+add_action('getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20);
1371 1371
 
1372
-function wpinv_cart_total_label( $label, $invoice ) {
1373
-    if ( empty( $invoice ) ) {
1372
+function wpinv_cart_total_label($label, $invoice) {
1373
+    if (empty($invoice)) {
1374 1374
         return $label;
1375 1375
     }
1376 1376
 
1377 1377
     $prefix_label = '';
1378
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
1379
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
1380
-    } else if ( $invoice->is_renewal() ) {
1381
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1378
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
1379
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
1380
+    } else if ($invoice->is_renewal()) {
1381
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
1382 1382
     }
1383 1383
 
1384
-    if ( $prefix_label != '' ) {
1385
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1384
+    if ($prefix_label != '') {
1385
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1386 1386
     }
1387 1387
 
1388 1388
     return $label;
1389 1389
 }
1390
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1391
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1392
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1390
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1391
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1392
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1393 1393
 
1394
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1395
-    if ( empty( $note ) ) {
1394
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1395
+    if (empty($note)) {
1396 1396
         return NULL;
1397 1397
     }
1398 1398
 
1399
-    if ( is_int( $note ) ) {
1400
-        $note = get_comment( $note );
1399
+    if (is_int($note)) {
1400
+        $note = get_comment($note);
1401 1401
     }
1402 1402
 
1403
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1403
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1404 1404
         return NULL;
1405 1405
     }
1406 1406
 
1407
-    $note_classes   = array( 'note' );
1408
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1407
+    $note_classes   = array('note');
1408
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1409 1409
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1410
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1411
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1410
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1411
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1412 1412
 
1413 1413
     ob_start();
1414 1414
     ?>
1415
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1415
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1416 1416
         <div class="note_content bg-light border position-relative p-4">
1417 1417
 
1418
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1418
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1419 1419
 
1420
-            <?php if ( ! is_admin() ) : ?>
1420
+            <?php if (!is_admin()) : ?>
1421 1421
                 <em class="meta position-absolute form-text">
1422 1422
                     <?php
1423 1423
                         printf(
1424
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1424
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1425 1425
                             $note->comment_author,
1426
-                            date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ),
1427
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1426
+                            date_i18n(get_option('date_format'), strtotime($note->comment_date)),
1427
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1428 1428
                         );
1429 1429
                     ?>
1430 1430
                 </em>
@@ -1432,12 +1432,12 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
         </div>
1434 1434
 
1435
-        <?php if ( is_admin() ) : ?>
1435
+        <?php if (is_admin()) : ?>
1436 1436
 
1437 1437
             <p class="meta px-4 py-2">
1438
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
1439
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1440
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1438
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
1439
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1440
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1441 1441
                 <?php } ?>
1442 1442
             </p>
1443 1443
 
@@ -1446,9 +1446,9 @@  discard block
 block discarded – undo
1446 1446
     </li>
1447 1447
     <?php
1448 1448
     $note_content = ob_get_clean();
1449
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1449
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1450 1450
 
1451
-    if ( $echo ) {
1451
+    if ($echo) {
1452 1452
         echo $note_content;
1453 1453
     } else {
1454 1454
         return $note_content;
@@ -1458,36 +1458,36 @@  discard block
 block discarded – undo
1458 1458
 function wpinv_invalid_invoice_content() {
1459 1459
     global $post;
1460 1460
 
1461
-    $invoice = wpinv_get_invoice( $post->ID );
1461
+    $invoice = wpinv_get_invoice($post->ID);
1462 1462
 
1463
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1464
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1465
-        if ( is_user_logged_in() ) {
1466
-            if ( wpinv_require_login_to_checkout() ) {
1467
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1468
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1463
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1464
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1465
+        if (is_user_logged_in()) {
1466
+            if (wpinv_require_login_to_checkout()) {
1467
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1468
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1469 1469
                 }
1470 1470
             }
1471 1471
         } else {
1472
-            if ( wpinv_require_login_to_checkout() ) {
1473
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1474
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1472
+            if (wpinv_require_login_to_checkout()) {
1473
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1474
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1475 1475
                 }
1476 1476
             }
1477 1477
         }
1478 1478
     } else {
1479
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1479
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1480 1480
     }
1481 1481
     ?>
1482 1482
     <div class="row wpinv-row-invalid">
1483 1483
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1484
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1484
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1485 1485
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1486 1486
         </div>
1487 1487
     </div>
1488 1488
     <?php
1489 1489
 }
1490
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1490
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1491 1491
 
1492 1492
 /**
1493 1493
  * Function to get privacy policy text.
@@ -1496,21 +1496,21 @@  discard block
 block discarded – undo
1496 1496
  * @return string
1497 1497
  */
1498 1498
 function wpinv_get_policy_text() {
1499
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1499
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1500 1500
 
1501
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1501
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1502 1502
 
1503
-    if(!$privacy_page_id){
1504
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1503
+    if (!$privacy_page_id) {
1504
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1505 1505
     }
1506 1506
 
1507
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1507
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1508 1508
 
1509 1509
     $find_replace = array(
1510 1510
         '[wpinv_privacy_policy]' => $privacy_link,
1511 1511
     );
1512 1512
 
1513
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1513
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1514 1514
 
1515 1515
     return wp_kses_post(wpautop($privacy_text));
1516 1516
 }
@@ -1518,21 +1518,21 @@  discard block
 block discarded – undo
1518 1518
 function wpinv_oxygen_fix_conflict() {
1519 1519
     global $ct_ignore_post_types;
1520 1520
 
1521
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1521
+    if (!is_array($ct_ignore_post_types)) {
1522 1522
         $ct_ignore_post_types = array();
1523 1523
     }
1524 1524
 
1525
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1525
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1526 1526
 
1527
-    foreach ( $post_types as $post_type ) {
1527
+    foreach ($post_types as $post_type) {
1528 1528
         $ct_ignore_post_types[] = $post_type;
1529 1529
 
1530 1530
         // Ignore post type
1531
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1531
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1532 1532
     }
1533 1533
 
1534
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1535
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1534
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1535
+    add_filter('template_include', 'wpinv_template', 999, 1);
1536 1536
 }
1537 1537
 
1538 1538
 /**
@@ -1540,10 +1540,10 @@  discard block
 block discarded – undo
1540 1540
  * 
1541 1541
  * @param GetPaid_Payment_Form $form
1542 1542
  */
1543
-function getpaid_display_payment_form( $form ) {
1543
+function getpaid_display_payment_form($form) {
1544 1544
 
1545
-    if ( is_numeric( $form ) ) {
1546
-        $form = new GetPaid_Payment_Form( $form );
1545
+    if (is_numeric($form)) {
1546
+        $form = new GetPaid_Payment_Form($form);
1547 1547
     }
1548 1548
 
1549 1549
     $form->display();
@@ -1553,16 +1553,16 @@  discard block
 block discarded – undo
1553 1553
 /**
1554 1554
  * Helper function to display a item payment form on the frontend.
1555 1555
  */
1556
-function getpaid_display_item_payment_form( $items ) {
1556
+function getpaid_display_item_payment_form($items) {
1557 1557
 
1558
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1559
-    $form->set_items( $items );
1558
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1559
+    $form->set_items($items);
1560 1560
 
1561
-    if ( 0 == count( $form->get_items() ) ) {
1561
+    if (0 == count($form->get_items())) {
1562 1562
         echo aui()->alert(
1563 1563
 			array(
1564 1564
 				'type'    => 'warning',
1565
-				'content' => __( 'No published items found', 'invoicing' ),
1565
+				'content' => __('No published items found', 'invoicing'),
1566 1566
 			)
1567 1567
         );
1568 1568
         return;
@@ -1574,75 +1574,75 @@  discard block
 block discarded – undo
1574 1574
 /**
1575 1575
  * Helper function to display an invoice payment form on the frontend.
1576 1576
  */
1577
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1577
+function getpaid_display_invoice_payment_form($invoice_id) {
1578 1578
     global $invoicing;
1579 1579
 
1580
-    $invoice = wpinv_get_invoice( $invoice_id );
1580
+    $invoice = wpinv_get_invoice($invoice_id);
1581 1581
 
1582
-    if ( empty( $invoice ) ) {
1582
+    if (empty($invoice)) {
1583 1583
 		return aui()->alert(
1584 1584
 			array(
1585 1585
 				'type'    => 'warning',
1586
-				'content' => __( 'Invoice not found', 'invoicing' ),
1586
+				'content' => __('Invoice not found', 'invoicing'),
1587 1587
 			)
1588 1588
 		);
1589 1589
     }
1590 1590
 
1591
-    if ( $invoice->is_paid() ) {
1591
+    if ($invoice->is_paid()) {
1592 1592
 		return aui()->alert(
1593 1593
 			array(
1594 1594
 				'type'    => 'warning',
1595
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1595
+				'content' => __('Invoice has already been paid', 'invoicing'),
1596 1596
 			)
1597 1597
 		);
1598 1598
     }
1599 1599
 
1600 1600
     // Get the form elements and items.
1601
-    $form     = wpinv_get_default_payment_form();
1602
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1603
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1601
+    $form = wpinv_get_default_payment_form();
1602
+	$elements = $invoicing->form_elements->get_form_elements($form);
1603
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1604 1604
 
1605 1605
 	ob_start();
1606 1606
 	echo "<form class='wpinv_payment_form'>";
1607
-	do_action( 'wpinv_payment_form_top' );
1607
+	do_action('wpinv_payment_form_top');
1608 1608
     echo "<input type='hidden' name='form_id' value='$form'/>";
1609 1609
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
1610
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1611
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1610
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1611
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1612 1612
 
1613
-	foreach ( $elements as $element ) {
1614
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1615
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1613
+	foreach ($elements as $element) {
1614
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1615
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1616 1616
 	}
1617 1617
 
1618 1618
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1619
-	do_action( 'wpinv_payment_form_bottom' );
1619
+	do_action('wpinv_payment_form_bottom');
1620 1620
 	echo '</form>';
1621 1621
 
1622 1622
 	$content = ob_get_clean();
1623
-	return str_replace( 'sr-only', '', $content );
1623
+	return str_replace('sr-only', '', $content);
1624 1624
 }
1625 1625
 
1626 1626
 /**
1627 1627
  * Helper function to convert item string to array.
1628 1628
  */
1629
-function getpaid_convert_items_to_array( $items ) {
1630
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1629
+function getpaid_convert_items_to_array($items) {
1630
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1631 1631
     $prepared = array();
1632 1632
 
1633
-    foreach ( $items as $item ) {
1634
-        $data = array_map( 'trim', explode( '|', $item ) );
1633
+    foreach ($items as $item) {
1634
+        $data = array_map('trim', explode('|', $item));
1635 1635
 
1636
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1636
+        if (empty($data[0]) || !is_numeric($data[0])) {
1637 1637
             continue;
1638 1638
         }
1639 1639
 
1640 1640
         $quantity = 1;
1641
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1641
+        if (isset($data[1]) && is_numeric($data[1])) {
1642 1642
             $quantity = (int) $data[1];
1643 1643
         }
1644 1644
 
1645
-        $prepared[ $data[0] ] = $quantity;
1645
+        $prepared[$data[0]] = $quantity;
1646 1646
 
1647 1647
     }
1648 1648
 
@@ -1652,13 +1652,13 @@  discard block
 block discarded – undo
1652 1652
 /**
1653 1653
  * Helper function to convert item array to string.
1654 1654
  */
1655
-function getpaid_convert_items_to_string( $items ) {
1655
+function getpaid_convert_items_to_string($items) {
1656 1656
     $prepared = array();
1657 1657
 
1658
-    foreach ( $items as $item => $quantity ) {
1658
+    foreach ($items as $item => $quantity) {
1659 1659
         $prepared[] = "$item|$quantity";
1660 1660
     }
1661
-    return implode( ',', $prepared );
1661
+    return implode(',', $prepared);
1662 1662
 }
1663 1663
 
1664 1664
 /**
@@ -1666,22 +1666,22 @@  discard block
 block discarded – undo
1666 1666
  * 
1667 1667
  * Provide a label and one of $form, $items or $invoice.
1668 1668
  */
1669
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1670
-    $label = sanitize_text_field( $label );
1669
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1670
+    $label = sanitize_text_field($label);
1671 1671
     $nonce = wp_create_nonce('getpaid_ajax_form');
1672 1672
 
1673
-    if ( ! empty( $form ) ) {
1674
-        $form  = esc_attr( $form );
1673
+    if (!empty($form)) {
1674
+        $form = esc_attr($form);
1675 1675
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1676 1676
     }
1677 1677
 	
1678
-	if ( ! empty( $items ) ) {
1679
-        $items  = esc_attr( $items );
1678
+	if (!empty($items)) {
1679
+        $items = esc_attr($items);
1680 1680
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1681 1681
     }
1682 1682
     
1683
-    if ( ! empty( $invoice ) ) {
1684
-        $invoice  = esc_attr( $invoice );
1683
+    if (!empty($invoice)) {
1684
+        $invoice = esc_attr($invoice);
1685 1685
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1686 1686
     }
1687 1687
 
@@ -1692,17 +1692,17 @@  discard block
 block discarded – undo
1692 1692
  *
1693 1693
  * @param WPInv_Invoice $invoice
1694 1694
  */
1695
-function getpaid_the_invoice_description( $invoice ) {
1695
+function getpaid_the_invoice_description($invoice) {
1696 1696
     $description = $invoice->get_description();
1697 1697
 
1698
-    if ( empty( $description ) ) {
1698
+    if (empty($description)) {
1699 1699
         return;
1700 1700
     }
1701 1701
 
1702
-    $description = wp_kses_post( $description );
1702
+    $description = wp_kses_post($description);
1703 1703
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1704 1704
 }
1705
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1705
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1706 1706
 
1707 1707
 /**
1708 1708
  * Render element on a form.
@@ -1710,41 +1710,41 @@  discard block
 block discarded – undo
1710 1710
  * @param array $element
1711 1711
  * @param GetPaid_Payment_Form $form
1712 1712
  */
1713
-function getpaid_payment_form_element( $element, $form ) {
1713
+function getpaid_payment_form_element($element, $form) {
1714 1714
 
1715 1715
     // Set up the args.
1716
-    $element_type    = trim( $element['type'] );
1716
+    $element_type    = trim($element['type']);
1717 1717
     $element['form'] = $form;
1718
-    extract( $element );
1718
+    extract($element);
1719 1719
 
1720 1720
     // Try to locate the appropriate template.
1721
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1721
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1722 1722
     
1723 1723
     // Abort if this is not our element.
1724
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1724
+    if (empty($located) || !file_exists($located)) {
1725 1725
         return;
1726 1726
     }
1727 1727
 
1728 1728
     // Generate the class and id of the element.
1729
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1730
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1729
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1730
+    $id            = isset($id) ? $id : uniqid('gp');
1731 1731
 
1732 1732
     // Echo the opening wrapper.
1733 1733
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1734 1734
 
1735 1735
     // Fires before displaying a given element type's content.
1736
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1736
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1737 1737
 
1738 1738
     // Include the template for the element.
1739 1739
     include $located;
1740 1740
 
1741 1741
     // Fires after displaying a given element type's content.
1742
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1742
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1743 1743
 
1744 1744
     // Echo the closing wrapper.
1745 1745
     echo '</div>';
1746 1746
 }
1747
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1747
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1748 1748
 
1749 1749
 /**
1750 1750
  * Shows a list of gateways that support recurring payments.
@@ -1752,17 +1752,17 @@  discard block
 block discarded – undo
1752 1752
 function wpinv_get_recurring_gateways_text() {
1753 1753
     $gateways = array();
1754 1754
 
1755
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1756
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1757
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1755
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1756
+        if (wpinv_gateway_support_subscription($key)) {
1757
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1758 1758
         }
1759 1759
     }
1760 1760
 
1761
-    if ( empty( $gateways ) ) {
1762
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1761
+    if (empty($gateways)) {
1762
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1763 1763
     }
1764 1764
 
1765
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1765
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1766 1766
 
1767 1767
 }
1768 1768
 
@@ -1772,5 +1772,5 @@  discard block
 block discarded – undo
1772 1772
  * @return GetPaid_Template
1773 1773
  */
1774 1774
 function getpaid_template() {
1775
-    return getpaid()->get( 'template' );
1775
+    return getpaid()->get('template');
1776 1776
 }
Please login to merge, or discard this patch.
templates/invoice/line-items.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,21 +7,21 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14
-<?php do_action( 'getpaid_invoice_before_line_items', $invoice ); ?>
14
+<?php do_action('getpaid_invoice_before_line_items', $invoice); ?>
15 15
 
16
-    <h2 class="mt-5 mb-1 h4"><?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), ucfirst( $invoice->get_type() )); ?></h2>
16
+    <h2 class="mt-5 mb-1 h4"><?php echo sprintf(esc_html__('%s Items', 'invoicing'), ucfirst($invoice->get_type())); ?></h2>
17 17
     <div class="getpaid-invoice-items mb-4 border">
18 18
 
19 19
 
20
-        <div class="getpaid-invoice-items-header <?php echo sanitize_html_class( $invoice->get_template() ); ?>">
20
+        <div class="getpaid-invoice-items-header <?php echo sanitize_html_class($invoice->get_template()); ?>">
21 21
             <div class="form-row">
22
-                <?php foreach ( $columns as $key => $label ) : ?>
23
-                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr( $key ); ?>">
24
-                        <?php echo sanitize_text_field( $label ); ?>
22
+                <?php foreach ($columns as $key => $label) : ?>
23
+                    <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr($key); ?>">
24
+                        <?php echo sanitize_text_field($label); ?>
25 25
                     </div>
26 26
                 <?php endforeach; ?>
27 27
             </div>
@@ -31,15 +31,15 @@  discard block
 block discarded – undo
31 31
         <?php
32 32
 
33 33
             // Display the item totals.
34
-            foreach ( $invoice->get_items() as $item ) {
35
-                wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) );
34
+            foreach ($invoice->get_items() as $item) {
35
+                wpinv_get_template('invoice/line-item.php', compact('invoice', 'item', 'columns'));
36 36
             }
37 37
 
38 38
             // Display the cart totals.
39
-            wpinv_get_template( 'invoice/line-totals.php', compact( 'invoice' ) );
39
+            wpinv_get_template('invoice/line-totals.php', compact('invoice'));
40 40
 
41 41
         ?>
42 42
 
43 43
     </div>
44 44
 
45
-<?php do_action( 'getpaid_invoice_after_line_items', $invoice ); ?>
45
+<?php do_action('getpaid_invoice_after_line_items', $invoice); ?>
Please login to merge, or discard this patch.
templates/invoice/invoice-type.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 <div class="p-3">
14 14
     <h2 class="h1 text-dark">
15
-        <?php echo apply_filters( 'getpaid_invoice_type_label', ucfirst( $invoice->get_type() ), $invoice ); ?>
15
+        <?php echo apply_filters('getpaid_invoice_type_label', ucfirst($invoice->get_type()), $invoice); ?>
16 16
     </h2>
17 17
 </div>
18 18
 
Please login to merge, or discard this patch.
templates/invoice/invoice-logo.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13
-<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
13
+<a target="_blank" class="logo-link text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
14 14
 
15
-    <?php if ( $logo = wpinv_get_business_logo() ) { ?>
16
-        <img class="logo" style="max-width:100%;" src="<?php echo esc_url( $logo ); ?>">
15
+    <?php if ($logo = wpinv_get_business_logo()) { ?>
16
+        <img class="logo" style="max-width:100%;" src="<?php echo esc_url($logo); ?>">
17 17
     <?php } else { ?>
18
-        <h1 class="pt-2"><?php echo esc_html( wpinv_get_business_name() ); ?></h1>
18
+        <h1 class="pt-2"><?php echo esc_html(wpinv_get_business_name()); ?></h1>
19 19
     <?php } ?>
20 20
 
21 21
 </a>
Please login to merge, or discard this patch.
templates/invoice-receipt.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Fetch the invoice.
13
-$invoice = new WPInv_Invoice( $invoice );
13
+$invoice = new WPInv_Invoice($invoice);
14 14
 
15 15
 // @deprecated
16
-do_action( 'wpinv_success_content_before', $invoice );
17
-do_action( 'wpinv_before_receipt', $invoice );
16
+do_action('wpinv_success_content_before', $invoice);
17
+do_action('wpinv_before_receipt', $invoice);
18 18
 
19 19
 
20 20
 // Prepare header text.
21
-if ( $invoice->is_paid() ) {
21
+if ($invoice->is_paid()) {
22 22
 
23 23
     $alert = aui()->alert(
24 24
         array(
25 25
             'type'    => 'success',
26
-            'content' => __( 'Thank you for your payment!', 'invoicing' ),
26
+            'content' => __('Thank you for your payment!', 'invoicing'),
27 27
         )
28 28
     );
29 29
 
30
-} else if ( $invoice->is_refunded() ) {
30
+} else if ($invoice->is_refunded()) {
31 31
 
32 32
     $alert = aui()->alert(
33 33
         array(
34 34
             'type'    => 'info',
35
-            'content' => __( 'This invoice was refunded.', 'invoicing' ),
35
+            'content' => __('This invoice was refunded.', 'invoicing'),
36 36
         )
37 37
     );
38 38
 
39
-} else if ( $invoice->is_held() ) {
39
+} else if ($invoice->is_held()) {
40 40
 
41 41
     $alert = aui()->alert(
42 42
         array(
43 43
             'type'    => 'info',
44
-            'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ),
44
+            'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'),
45 45
         )
46 46
     );
47 47
 
48
-} else if ( $invoice->needs_payment() ) {
48
+} else if ($invoice->needs_payment()) {
49 49
 
50
-    if ( $invoice->is_due() ) {
50
+    if ($invoice->is_due()) {
51 51
 
52 52
         $alert = aui()->alert(
53 53
             array(
54 54
                 'type'    => 'danger',
55 55
                 'content' => sprintf(
56
-                    __( 'This invoice was due on %.', 'invoicing' ),
57
-                    date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_due_date() ) )
56
+                    __('This invoice was due on %.', 'invoicing'),
57
+                    date_i18n(get_option('date_format'), strtotime($invoice->get_due_date()))
58 58
                 ),
59 59
             )
60 60
         );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $alert = aui()->alert(
65 65
             array(
66 66
                 'type'    => 'warning',
67
-                'content' => __( 'This invoice needs payment.', 'invoicing' ),
67
+                'content' => __('This invoice needs payment.', 'invoicing'),
68 68
             )
69 69
         );
70 70
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 
80 80
         'pay' => array(
81 81
             'url'   => $invoice->get_checkout_payment_url(),
82
-            'name'  => __( 'Pay For Invoice', 'invoicing' ),
82
+            'name'  => __('Pay For Invoice', 'invoicing'),
83 83
             'class' => 'btn-success',
84 84
         ),
85 85
 
86 86
         'view' => array(
87 87
             'url'   => $invoice->get_view_url(),
88
-            'name'  => __( 'View Invoice', 'invoicing' ),
88
+            'name'  => __('View Invoice', 'invoicing'),
89 89
             'class' => 'btn-primary',
90 90
         ),
91 91
 
92 92
         'history' => array(
93 93
             'url'   => wpinv_get_history_page_uri(),
94
-            'name'  => __( 'Invoice History', 'invoicing' ),
94
+            'name'  => __('Invoice History', 'invoicing'),
95 95
             'class' => 'btn-warning',
96 96
         ),
97 97
 
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
 );
102 102
 
103
-if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) {
104
-    unset( $actions['pay'] );
103
+if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) {
104
+    unset($actions['pay']);
105 105
 }
106 106
 
107
-if ( ! is_user_logged_in() && isset( $actions['history'] ) ) {
108
-    unset( $actions['history'] );
107
+if (!is_user_logged_in() && isset($actions['history'])) {
108
+    unset($actions['history']);
109 109
 }
110 110
 
111 111
 ?>
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 
115 115
         <?php
116 116
         
117
-            do_action( 'wpinv_receipt_start', $invoice );
117
+            do_action('wpinv_receipt_start', $invoice);
118 118
 
119
-            if ( ! empty( $actions ) ) {
119
+            if (!empty($actions)) {
120 120
 
121 121
                 echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">';
122 122
 
123
-                foreach ( $actions as $key => $action ) {
123
+                foreach ($actions as $key => $action) {
124 124
 
125
-                    $key    = sanitize_html_class( $key );
126
-                    $class  = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] );
127
-                    $url    = empty( $action['url'] ) ? '#' : esc_url( $action['url'] );
128
-                    $attrs  = empty( $action['attrs'] ) ? '' : $action['attrs'];
129
-                    $anchor = sanitize_text_field( $action['name'] );
125
+                    $key    = sanitize_html_class($key);
126
+                    $class  = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']);
127
+                    $url    = empty($action['url']) ? '#' : esc_url($action['url']);
128
+                    $attrs  = empty($action['attrs']) ? '' : $action['attrs'];
129
+                    $anchor = sanitize_text_field($action['name']);
130 130
 
131 131
                     echo "<a href='$url' class='btn btn-sm ml-1 $class $key' $attrs>$anchor</a>";
132 132
                 }
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
         <div class="wpinv-receipt-details">
143 143
 
144 144
             <h4 class="wpinv-details-t mb-3 mt-3">
145
-                <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?>
145
+                <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?>
146 146
             </h4>
147 147
 
148
-            <?php getpaid_invoice_meta( $invoice ); ?>
148
+            <?php getpaid_invoice_meta($invoice); ?>
149 149
 
150 150
         </div>
151 151
 
152 152
 
153
-        <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
153
+        <?php do_action('wpinv_receipt_end', $invoice); ?>
154 154
 
155 155
     </div>
156 156
 
157 157
 <?php
158 158
 
159 159
 // @deprecated
160
-do_action( 'wpinv_success_content_after', $invoice );
161
-do_action( 'wpinv_after_receipt', $invoice );
160
+do_action('wpinv_success_content_after', $invoice);
161
+do_action('wpinv_after_receipt', $invoice);
Please login to merge, or discard this patch.