Passed
Push — master ( 776437...797927 )
by Stiofan
04:32
created
includes/wpinv-template-functions.php 1 patch
Spacing   +687 added lines, -687 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array)$template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,143 +208,143 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234 234
 
235
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
235
+	if (!wpinv_is_checkout() && !is_page($pages)) {
236 236
 		return;
237 237
 	}
238 238
 
239 239
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
240 240
 }
241
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
241
+add_action('wp_head', 'wpinv_checkout_meta_tags');
242 242
 
243
-function wpinv_add_body_classes( $class ) {
243
+function wpinv_add_body_classes($class) {
244 244
 	$classes = (array)$class;
245 245
 
246
-	if( wpinv_is_checkout() ) {
246
+	if (wpinv_is_checkout()) {
247 247
 		$classes[] = 'wpinv-checkout';
248 248
 		$classes[] = 'wpinv-page';
249 249
 	}
250 250
 
251
-	if( wpinv_is_success_page() ) {
251
+	if (wpinv_is_success_page()) {
252 252
 		$classes[] = 'wpinv-success';
253 253
 		$classes[] = 'wpinv-page';
254 254
 	}
255 255
 
256
-	if( wpinv_is_failed_transaction_page() ) {
256
+	if (wpinv_is_failed_transaction_page()) {
257 257
 		$classes[] = 'wpinv-failed-transaction';
258 258
 		$classes[] = 'wpinv-page';
259 259
 	}
260 260
 
261
-	if( wpinv_is_invoice_history_page() ) {
261
+	if (wpinv_is_invoice_history_page()) {
262 262
 		$classes[] = 'wpinv-history';
263 263
 		$classes[] = 'wpinv-page';
264 264
 	}
265 265
 
266
-	if( wpinv_is_test_mode() ) {
266
+	if (wpinv_is_test_mode()) {
267 267
 		$classes[] = 'wpinv-test-mode';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	return array_unique( $classes );
271
+	return array_unique($classes);
272 272
 }
273
-add_filter( 'body_class', 'wpinv_add_body_classes' );
273
+add_filter('body_class', 'wpinv_add_body_classes');
274 274
 
275
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
276
-    $args = array( 'nopaging' => true );
275
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
276
+    $args = array('nopaging' => true);
277 277
 
278
-    if ( ! empty( $status ) )
278
+    if (!empty($status))
279 279
         $args['post_status'] = $status;
280 280
 
281
-    $discounts = wpinv_get_discounts( $args );
281
+    $discounts = wpinv_get_discounts($args);
282 282
     $options   = array();
283 283
 
284
-    if ( $discounts ) {
285
-        foreach ( $discounts as $discount ) {
286
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
284
+    if ($discounts) {
285
+        foreach ($discounts as $discount) {
286
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
287 287
         }
288 288
     } else {
289
-        $options[0] = __( 'No discounts found', 'invoicing' );
289
+        $options[0] = __('No discounts found', 'invoicing');
290 290
     }
291 291
 
292
-    $output = wpinv_html_select( array(
292
+    $output = wpinv_html_select(array(
293 293
         'name'             => $name,
294 294
         'selected'         => $selected,
295 295
         'options'          => $options,
296 296
         'show_option_all'  => false,
297 297
         'show_option_none' => false,
298
-    ) );
298
+    ));
299 299
 
300 300
     return $output;
301 301
 }
302 302
 
303
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
304
-    $current     = date( 'Y' );
305
-    $start_year  = $current - absint( $years_before );
306
-    $end_year    = $current + absint( $years_after );
307
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
303
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
304
+    $current     = date('Y');
305
+    $start_year  = $current - absint($years_before);
306
+    $end_year    = $current + absint($years_after);
307
+    $selected    = empty($selected) ? date('Y') : $selected;
308 308
     $options     = array();
309 309
 
310
-    while ( $start_year <= $end_year ) {
311
-        $options[ absint( $start_year ) ] = $start_year;
310
+    while ($start_year <= $end_year) {
311
+        $options[absint($start_year)] = $start_year;
312 312
         $start_year++;
313 313
     }
314 314
 
315
-    $output = wpinv_html_select( array(
315
+    $output = wpinv_html_select(array(
316 316
         'name'             => $name,
317 317
         'selected'         => $selected,
318 318
         'options'          => $options,
319 319
         'show_option_all'  => false,
320 320
         'show_option_none' => false
321
-    ) );
321
+    ));
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
326
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
327 327
     $month   = 1;
328 328
     $options = array();
329
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
329
+    $selected = empty($selected) ? date('n') : $selected;
330 330
 
331
-    while ( $month <= 12 ) {
332
-        $options[ absint( $month ) ] = wpinv_month_num_to_name( $month );
331
+    while ($month <= 12) {
332
+        $options[absint($month)] = wpinv_month_num_to_name($month);
333 333
         $month++;
334 334
     }
335 335
 
336
-    $output = wpinv_html_select( array(
336
+    $output = wpinv_html_select(array(
337 337
         'name'             => $name,
338 338
         'selected'         => $selected,
339 339
         'options'          => $options,
340 340
         'show_option_all'  => false,
341 341
         'show_option_none' => false
342
-    ) );
342
+    ));
343 343
 
344 344
     return $output;
345 345
 }
346 346
 
347
-function wpinv_html_select( $args = array() ) {
347
+function wpinv_html_select($args = array()) {
348 348
     $defaults = array(
349 349
         'options'          => array(),
350 350
         'name'             => null,
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
         'chosen'           => false,
355 355
         'placeholder'      => null,
356 356
         'multiple'         => false,
357
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
358
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
357
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
358
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
359 359
         'data'             => array(),
360 360
         'onchange'         => null,
361 361
         'required'         => false,
@@ -363,78 +363,78 @@  discard block
 block discarded – undo
363 363
         'readonly'         => false,
364 364
     );
365 365
 
366
-    $args = wp_parse_args( $args, $defaults );
366
+    $args = wp_parse_args($args, $defaults);
367 367
 
368 368
     $data_elements = '';
369
-    foreach ( $args['data'] as $key => $value ) {
370
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
369
+    foreach ($args['data'] as $key => $value) {
370
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
371 371
     }
372 372
 
373
-    if( $args['multiple'] ) {
373
+    if ($args['multiple']) {
374 374
         $multiple = ' MULTIPLE';
375 375
     } else {
376 376
         $multiple = '';
377 377
     }
378 378
 
379
-    if( $args['chosen'] ) {
379
+    if ($args['chosen']) {
380 380
         $args['class'] .= ' wpinv-select-chosen';
381 381
     }
382 382
 
383
-    if( $args['placeholder'] ) {
383
+    if ($args['placeholder']) {
384 384
         $placeholder = $args['placeholder'];
385 385
     } else {
386 386
         $placeholder = '';
387 387
     }
388 388
     
389 389
     $options = '';
390
-    if( !empty( $args['onchange'] ) ) {
391
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
390
+    if (!empty($args['onchange'])) {
391
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
392 392
     }
393 393
     
394
-    if( !empty( $args['required'] ) ) {
394
+    if (!empty($args['required'])) {
395 395
         $options .= ' required="required"';
396 396
     }
397 397
     
398
-    if( !empty( $args['disabled'] ) ) {
398
+    if (!empty($args['disabled'])) {
399 399
         $options .= ' disabled';
400 400
     }
401 401
     
402
-    if( !empty( $args['readonly'] ) ) {
402
+    if (!empty($args['readonly'])) {
403 403
         $options .= ' readonly';
404 404
     }
405 405
 
406
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
407
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
406
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
407
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
408 408
 
409
-    if ( $args['show_option_all'] ) {
410
-        if( $args['multiple'] ) {
411
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
409
+    if ($args['show_option_all']) {
410
+        if ($args['multiple']) {
411
+            $selected = selected(true, in_array(0, $args['selected']), false);
412 412
         } else {
413
-            $selected = selected( $args['selected'], 0, false );
413
+            $selected = selected($args['selected'], 0, false);
414 414
         }
415
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
415
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
416 416
     }
417 417
 
418
-    if ( !empty( $args['options'] ) ) {
418
+    if (!empty($args['options'])) {
419 419
 
420
-        if ( $args['show_option_none'] ) {
421
-            if( $args['multiple'] ) {
422
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
420
+        if ($args['show_option_none']) {
421
+            if ($args['multiple']) {
422
+                $selected = selected(true, in_array("", $args['selected']), false);
423 423
             } else {
424
-                $selected = selected( $args['selected'] === "", true, false );
424
+                $selected = selected($args['selected'] === "", true, false);
425 425
             }
426
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
426
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
427 427
         }
428 428
 
429
-        foreach( $args['options'] as $key => $option ) {
429
+        foreach ($args['options'] as $key => $option) {
430 430
 
431
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
432
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
431
+            if ($args['multiple'] && is_array($args['selected'])) {
432
+                $selected = selected(true, (bool)in_array($key, $args['selected']), false);
433 433
             } else {
434
-                $selected = selected( $args['selected'], $key, false );
434
+                $selected = selected($args['selected'], $key, false);
435 435
             }
436 436
 
437
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
437
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
438 438
         }
439 439
     }
440 440
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     return $output;
444 444
 }
445 445
 
446
-function wpinv_item_dropdown( $args = array() ) {
446
+function wpinv_item_dropdown($args = array()) {
447 447
     $defaults = array(
448 448
         'name'              => 'wpi_item',
449 449
         'id'                => 'wpi_item',
@@ -452,14 +452,14 @@  discard block
 block discarded – undo
452 452
         'selected'          => 0,
453 453
         'chosen'            => false,
454 454
         'number'            => 100,
455
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
456
-        'data'              => array( 'search-type' => 'item' ),
455
+        'placeholder'       => __('Choose a item', 'invoicing'),
456
+        'data'              => array('search-type' => 'item'),
457 457
         'show_option_all'   => false,
458 458
         'show_option_none'  => false,
459 459
         'show_recurring'    => false,
460 460
     );
461 461
 
462
-    $args = wp_parse_args( $args, $defaults );
462
+    $args = wp_parse_args($args, $defaults);
463 463
 
464 464
     $item_args = array(
465 465
         'post_type'      => 'wpi_item',
@@ -468,44 +468,44 @@  discard block
 block discarded – undo
468 468
         'posts_per_page' => $args['number']
469 469
     );
470 470
     
471
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
471
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
472 472
 
473
-    $items      = get_posts( $item_args );
473
+    $items      = get_posts($item_args);
474 474
     $options    = array();
475
-    if ( $items ) {
476
-        foreach ( $items as $item ) {
477
-            $title = esc_html( $item->post_title );
475
+    if ($items) {
476
+        foreach ($items as $item) {
477
+            $title = esc_html($item->post_title);
478 478
             
479
-            if ( !empty( $args['show_recurring'] ) ) {
480
-                $title .= wpinv_get_item_suffix( $item->ID, false );
479
+            if (!empty($args['show_recurring'])) {
480
+                $title .= wpinv_get_item_suffix($item->ID, false);
481 481
             }
482 482
             
483
-            $options[ absint( $item->ID ) ] = $title;
483
+            $options[absint($item->ID)] = $title;
484 484
         }
485 485
     }
486 486
 
487 487
     // This ensures that any selected items are included in the drop down
488
-    if( is_array( $args['selected'] ) ) {
489
-        foreach( $args['selected'] as $item ) {
490
-            if( ! in_array( $item, $options ) ) {
491
-                $title = get_the_title( $item );
492
-                if ( !empty( $args['show_recurring'] ) ) {
493
-                    $title .= wpinv_get_item_suffix( $item, false );
488
+    if (is_array($args['selected'])) {
489
+        foreach ($args['selected'] as $item) {
490
+            if (!in_array($item, $options)) {
491
+                $title = get_the_title($item);
492
+                if (!empty($args['show_recurring'])) {
493
+                    $title .= wpinv_get_item_suffix($item, false);
494 494
                 }
495 495
                 $options[$item] = $title;
496 496
             }
497 497
         }
498
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
499
-        if ( ! in_array( $args['selected'], $options ) ) {
500
-            $title = get_the_title( $args['selected'] );
501
-            if ( !empty( $args['show_recurring'] ) ) {
502
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
498
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
499
+        if (!in_array($args['selected'], $options)) {
500
+            $title = get_the_title($args['selected']);
501
+            if (!empty($args['show_recurring'])) {
502
+                $title .= wpinv_get_item_suffix($args['selected'], false);
503 503
             }
504
-            $options[$args['selected']] = get_the_title( $args['selected'] );
504
+            $options[$args['selected']] = get_the_title($args['selected']);
505 505
         }
506 506
     }
507 507
 
508
-    $output = wpinv_html_select( array(
508
+    $output = wpinv_html_select(array(
509 509
         'name'             => $args['name'],
510 510
         'selected'         => $args['selected'],
511 511
         'id'               => $args['id'],
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
         'show_option_all'  => $args['show_option_all'],
518 518
         'show_option_none' => $args['show_option_none'],
519 519
         'data'             => $args['data'],
520
-    ) );
520
+    ));
521 521
 
522 522
     return $output;
523 523
 }
524 524
 
525
-function wpinv_html_checkbox( $args = array() ) {
525
+function wpinv_html_checkbox($args = array()) {
526 526
     $defaults = array(
527 527
         'name'     => null,
528 528
         'current'  => null,
@@ -533,38 +533,38 @@  discard block
 block discarded – undo
533 533
         )
534 534
     );
535 535
 
536
-    $args = wp_parse_args( $args, $defaults );
536
+    $args = wp_parse_args($args, $defaults);
537 537
 
538
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
538
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
539 539
     $options = '';
540
-    if ( ! empty( $args['options']['disabled'] ) ) {
540
+    if (!empty($args['options']['disabled'])) {
541 541
         $options .= ' disabled="disabled"';
542
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
542
+    } elseif (!empty($args['options']['readonly'])) {
543 543
         $options .= ' readonly';
544 544
     }
545 545
 
546
-    $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 ) . ' />';
546
+    $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) . ' />';
547 547
 
548 548
     return $output;
549 549
 }
550 550
 
551
-function wpinv_html_text( $args = array() ) {
551
+function wpinv_html_text($args = array()) {
552 552
     // Backwards compatibility
553
-    if ( func_num_args() > 1 ) {
553
+    if (func_num_args() > 1) {
554 554
         $args = func_get_args();
555 555
 
556 556
         $name  = $args[0];
557
-        $value = isset( $args[1] ) ? $args[1] : '';
558
-        $label = isset( $args[2] ) ? $args[2] : '';
559
-        $desc  = isset( $args[3] ) ? $args[3] : '';
557
+        $value = isset($args[1]) ? $args[1] : '';
558
+        $label = isset($args[2]) ? $args[2] : '';
559
+        $desc  = isset($args[3]) ? $args[3] : '';
560 560
     }
561 561
 
562 562
     $defaults = array(
563 563
         'id'           => '',
564
-        'name'         => isset( $name )  ? $name  : 'text',
565
-        'value'        => isset( $value ) ? $value : null,
566
-        'label'        => isset( $label ) ? $label : null,
567
-        'desc'         => isset( $desc )  ? $desc  : null,
564
+        'name'         => isset($name) ? $name : 'text',
565
+        'value'        => isset($value) ? $value : null,
566
+        'label'        => isset($label) ? $label : null,
567
+        'desc'         => isset($desc) ? $desc : null,
568 568
         'placeholder'  => '',
569 569
         'class'        => 'regular-text',
570 570
         'disabled'     => false,
@@ -574,51 +574,51 @@  discard block
 block discarded – undo
574 574
         'data'         => false
575 575
     );
576 576
 
577
-    $args = wp_parse_args( $args, $defaults );
577
+    $args = wp_parse_args($args, $defaults);
578 578
 
579
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
579
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
580 580
     $options = '';
581
-    if( $args['required'] ) {
581
+    if ($args['required']) {
582 582
         $options .= ' required="required"';
583 583
     }
584
-    if( $args['readonly'] ) {
584
+    if ($args['readonly']) {
585 585
         $options .= ' readonly';
586 586
     }
587
-    if( $args['readonly'] ) {
587
+    if ($args['readonly']) {
588 588
         $options .= ' readonly';
589 589
     }
590 590
 
591 591
     $data = '';
592
-    if ( !empty( $args['data'] ) ) {
593
-        foreach ( $args['data'] as $key => $value ) {
594
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
592
+    if (!empty($args['data'])) {
593
+        foreach ($args['data'] as $key => $value) {
594
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
595 595
         }
596 596
     }
597 597
 
598
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
599
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
600
-    if ( ! empty( $args['desc'] ) ) {
601
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
598
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
599
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
600
+    if (!empty($args['desc'])) {
601
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
602 602
     }
603 603
 
604
-    $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 ) . '/>';
604
+    $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) . '/>';
605 605
 
606 606
     $output .= '</span>';
607 607
 
608 608
     return $output;
609 609
 }
610 610
 
611
-function wpinv_html_date_field( $args = array() ) {
612
-    if( empty( $args['class'] ) ) {
611
+function wpinv_html_date_field($args = array()) {
612
+    if (empty($args['class'])) {
613 613
         $args['class'] = 'wpiDatepicker';
614
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
614
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
615 615
         $args['class'] .= ' wpiDatepicker';
616 616
     }
617 617
 
618
-    return wpinv_html_text( $args );
618
+    return wpinv_html_text($args);
619 619
 }
620 620
 
621
-function wpinv_html_textarea( $args = array() ) {
621
+function wpinv_html_textarea($args = array()) {
622 622
     $defaults = array(
623 623
         'name'        => 'textarea',
624 624
         'value'       => null,
@@ -628,31 +628,31 @@  discard block
 block discarded – undo
628 628
         'disabled'    => false
629 629
     );
630 630
 
631
-    $args = wp_parse_args( $args, $defaults );
631
+    $args = wp_parse_args($args, $defaults);
632 632
 
633
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
633
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
634 634
     $disabled = '';
635
-    if( $args['disabled'] ) {
635
+    if ($args['disabled']) {
636 636
         $disabled = ' disabled="disabled"';
637 637
     }
638 638
 
639
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
640
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
641
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
639
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
640
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
641
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
642 642
 
643
-    if ( ! empty( $args['desc'] ) ) {
644
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
643
+    if (!empty($args['desc'])) {
644
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
645 645
     }
646 646
     $output .= '</span>';
647 647
 
648 648
     return $output;
649 649
 }
650 650
 
651
-function wpinv_html_ajax_user_search( $args = array() ) {
651
+function wpinv_html_ajax_user_search($args = array()) {
652 652
     $defaults = array(
653 653
         'name'        => 'user_id',
654 654
         'value'       => null,
655
-        'placeholder' => __( 'Enter username', 'invoicing' ),
655
+        'placeholder' => __('Enter username', 'invoicing'),
656 656
         'label'       => null,
657 657
         'desc'        => null,
658 658
         'class'       => '',
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
         'data'        => false
662 662
     );
663 663
 
664
-    $args = wp_parse_args( $args, $defaults );
664
+    $args = wp_parse_args($args, $defaults);
665 665
 
666 666
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
667 667
 
668 668
     $output  = '<span class="wpinv_user_search_wrap">';
669
-        $output .= wpinv_html_text( $args );
670
-        $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>';
669
+        $output .= wpinv_html_text($args);
670
+        $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>';
671 671
     $output .= '</span>';
672 672
 
673 673
     return $output;
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 function wpinv_ip_geolocation() {
677 677
     global $wpinv_euvat;
678 678
     
679
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
679
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
680 680
     $content    = '';
681 681
     $iso        = '';
682 682
     $country    = '';
@@ -687,69 +687,69 @@  discard block
 block discarded – undo
687 687
     $credit     = '';
688 688
     $address    = '';
689 689
     
690
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
690
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
691 691
         try {
692 692
             $iso        = $geoip2_city->country->isoCode;
693 693
             $country    = $geoip2_city->country->name;
694
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
694
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
695 695
             $city       = $geoip2_city->city->name;
696 696
             $longitude  = $geoip2_city->location->longitude;
697 697
             $latitude   = $geoip2_city->location->latitude;
698
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
699
-        } catch( Exception $e ) { }
698
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
699
+        } catch (Exception $e) { }
700 700
     }
701 701
     
702
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
702
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
703 703
         try {
704
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
704
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
705 705
             
706
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
706
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
707 707
                 $iso        = $load_xml->geoplugin_countryCode;
708 708
                 $country    = $load_xml->geoplugin_countryName;
709
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
710
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
709
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
710
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
711 711
                 $longitude  = $load_xml->geoplugin_longitude;
712 712
                 $latitude   = $load_xml->geoplugin_latitude;
713 713
                 $credit     = $load_xml->geoplugin_credit;
714
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
714
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
715 715
             }
716
-        } catch( Exception $e ) { }
716
+        } catch (Exception $e) { }
717 717
     }
718 718
     
719
-    if ( $iso && $longitude && $latitude ) {
720
-        if ( $city ) {
719
+    if ($iso && $longitude && $latitude) {
720
+        if ($city) {
721 721
             $address .= $city . ', ';
722 722
         }
723 723
         
724
-        if ( $region ) {
724
+        if ($region) {
725 725
             $address .= $region . ', ';
726 726
         }
727 727
         
728 728
         $address .= $country . ' (' . $iso . ')';
729
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
730
-        $content .= '<p>'. $credit . '</p>';
729
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
730
+        $content .= '<p>' . $credit . '</p>';
731 731
     } else {
732
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
732
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
733 733
     }
734 734
     ?>
735 735
 <!DOCTYPE html>
736
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
736
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
737 737
 <body>
738
-    <?php if ( $latitude && $latitude ) { ?>
738
+    <?php if ($latitude && $latitude) { ?>
739 739
     <div id="map"></div>
740 740
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
741 741
         <script type="text/javascript">
742 742
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
743 743
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
744 744
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
745
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
745
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
746 746
 
747 747
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
748 748
 
749 749
         var marker = new L.Marker(latlng);
750 750
         map.addLayer(marker);
751 751
 
752
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
752
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
753 753
     </script>
754 754
     <?php } ?>
755 755
     <div style="height:100px"><?php echo $content; ?></div>
@@ -757,18 +757,18 @@  discard block
 block discarded – undo
757 757
 <?php
758 758
     exit;
759 759
 }
760
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
761
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
760
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
761
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
762 762
 
763 763
 // Set up the template for the invoice.
764
-function wpinv_template( $template ) {
764
+function wpinv_template($template) {
765 765
     global $post, $wp_query;
766 766
     
767
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
768
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
769
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
767
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
768
+        if (wpinv_user_can_view_invoice($post->ID)) {
769
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
770 770
         } else {
771
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
771
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
772 772
         }
773 773
     }
774 774
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 
778 778
 function wpinv_get_business_address() {
779 779
     $business_address   = wpinv_store_address();
780
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
780
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
781 781
     
782 782
     /*
783 783
     $default_country    = wpinv_get_default_country();
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     
802 802
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
803 803
     
804
-    return apply_filters( 'wpinv_get_business_address', $business_address );
804
+    return apply_filters('wpinv_get_business_address', $business_address);
805 805
 }
806 806
 
807 807
 function wpinv_display_from_address() {
@@ -811,187 +811,187 @@  discard block
 block discarded – undo
811 811
     if (empty($from_name)) {
812 812
         $from_name = wpinv_get_business_name();
813 813
     }
814
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
814
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
815 815
     <div class="wrapper col-xs-10">
816
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
817
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
818
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
816
+        <div class="name"><?php echo esc_html($from_name); ?></div>
817
+        <?php if ($address = wpinv_get_business_address()) { ?>
818
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
819 819
         <?php } ?>
820
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
821
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
820
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
821
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
822 822
         <?php } ?>
823 823
     </div>
824 824
     <?php
825 825
 }
826 826
 
827
-function wpinv_watermark( $id = 0 ) {
828
-    $output = wpinv_get_watermark( $id );
827
+function wpinv_watermark($id = 0) {
828
+    $output = wpinv_get_watermark($id);
829 829
     
830
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
830
+    return apply_filters('wpinv_get_watermark', $output, $id);
831 831
 }
832 832
 
833
-function wpinv_get_watermark( $id ) {
834
-    if ( !$id > 0 ) {
833
+function wpinv_get_watermark($id) {
834
+    if (!$id > 0) {
835 835
         return NULL;
836 836
     }
837
-    $invoice = wpinv_get_invoice( $id );
837
+    $invoice = wpinv_get_invoice($id);
838 838
     
839
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
840
-        if ( $invoice->is_paid() ) {
841
-            return __( 'Paid', 'invoicing' );
839
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
840
+        if ($invoice->is_paid()) {
841
+            return __('Paid', 'invoicing');
842 842
         }
843
-        if ( $invoice->is_refunded() ) {
844
-            return __( 'Refunded', 'invoicing' );
843
+        if ($invoice->is_refunded()) {
844
+            return __('Refunded', 'invoicing');
845 845
         }
846
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
847
-            return __( 'Cancelled', 'invoicing' );
846
+        if ($invoice->has_status(array('wpi-cancelled'))) {
847
+            return __('Cancelled', 'invoicing');
848 848
         }
849 849
     }
850 850
     
851 851
     return NULL;
852 852
 }
853 853
 
854
-function wpinv_display_invoice_details( $invoice ) {
854
+function wpinv_display_invoice_details($invoice) {
855 855
     global $wpinv_euvat;
856 856
     
857 857
     $invoice_id = $invoice->ID;
858 858
     $vat_name   = $wpinv_euvat->get_vat_name();
859 859
     $use_taxes  = wpinv_use_taxes();
860 860
     
861
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
861
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
862 862
     ?>
863 863
     <table class="table table-bordered table-sm">
864
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
864
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
865 865
             <tr class="wpi-row-number">
866
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
867
-                <td><?php echo esc_html( $invoice_number ); ?></td>
866
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
867
+                <td><?php echo esc_html($invoice_number); ?></td>
868 868
             </tr>
869 869
         <?php } ?>
870 870
         <tr class="wpi-row-status">
871
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
872
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
871
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
872
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
873 873
         </tr>
874
-        <?php if ( $invoice->is_renewal() ) { ?>
874
+        <?php if ($invoice->is_renewal()) { ?>
875 875
         <tr class="wpi-row-parent">
876
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
877
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
876
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
877
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
878 878
         </tr>
879 879
         <?php } ?>
880
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
880
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
881 881
             <tr class="wpi-row-gateway">
882
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
882
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
883 883
                 <td><?php echo $gateway_name; ?></td>
884 884
             </tr>
885 885
         <?php } ?>
886
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
886
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
887 887
             <tr class="wpi-row-date">
888
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
888
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
889 889
                 <td><?php echo $invoice_date; ?></td>
890 890
             </tr>
891 891
         <?php } ?>
892
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
892
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
893 893
             <tr class="wpi-row-date">
894
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
894
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
895 895
                 <td><?php echo $due_date; ?></td>
896 896
             </tr>
897 897
         <?php } ?>
898
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
898
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
899 899
             <tr class="wpi-row-ovatno">
900
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
900
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
901 901
                 <td><?php echo $owner_vat_number; ?></td>
902 902
             </tr>
903 903
         <?php } ?>
904
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
904
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
905 905
             <tr class="wpi-row-uvatno">
906
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
906
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
907 907
                 <td><?php echo $user_vat_number; ?></td>
908 908
             </tr>
909 909
         <?php } ?>
910 910
         <tr class="table-active tr-total wpi-row-total">
911
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
912
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
911
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
912
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
913 913
         </tr>
914 914
     </table>
915 915
 <?php
916 916
 }
917 917
 
918
-function wpinv_display_to_address( $invoice_id = 0 ) {
919
-    $invoice = wpinv_get_invoice( $invoice_id );
918
+function wpinv_display_to_address($invoice_id = 0) {
919
+    $invoice = wpinv_get_invoice($invoice_id);
920 920
     
921
-    if ( empty( $invoice ) ) {
921
+    if (empty($invoice)) {
922 922
         return NULL;
923 923
     }
924 924
     
925 925
     $billing_details = $invoice->get_user_info();
926
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
926
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
927 927
     $output .= '<div class="wrapper col-xs-10">';
928 928
     
929 929
     ob_start();
930
-    do_action( 'wpinv_display_to_address_top', $invoice );
930
+    do_action('wpinv_display_to_address_top', $invoice);
931 931
     $output .= ob_get_clean();
932 932
     
933
-    $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>';
934
-    if ( $company = $billing_details['company'] ) {
935
-        $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>';
933
+    $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>';
934
+    if ($company = $billing_details['company']) {
935
+        $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>';
936 936
     }
937 937
     $address_row = '';
938
-    if ( $address = $billing_details['address'] ) {
939
-        $address_row .= wpautop( wp_kses_post( $address ) );
938
+    if ($address = $billing_details['address']) {
939
+        $address_row .= wpautop(wp_kses_post($address));
940 940
     }
941 941
     
942 942
     $address_fields = array();
943
-    if ( !empty( $billing_details['city'] ) ) {
943
+    if (!empty($billing_details['city'])) {
944 944
         $address_fields[] = $billing_details['city'];
945 945
     }
946 946
     
947
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
948
-    if ( !empty( $billing_details['state'] ) ) {
949
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
947
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
948
+    if (!empty($billing_details['state'])) {
949
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
950 950
     }
951 951
     
952
-    if ( !empty( $billing_country ) ) {
953
-        $address_fields[] = wpinv_country_name( $billing_country );
952
+    if (!empty($billing_country)) {
953
+        $address_fields[] = wpinv_country_name($billing_country);
954 954
     }
955 955
     
956
-    if ( !empty( $address_fields ) ) {
957
-        $address_fields = implode( ", ", $address_fields );
956
+    if (!empty($address_fields)) {
957
+        $address_fields = implode(", ", $address_fields);
958 958
         
959
-        if ( !empty( $billing_details['zip'] ) ) {
959
+        if (!empty($billing_details['zip'])) {
960 960
             $address_fields .= ' ' . $billing_details['zip'];
961 961
         }
962 962
         
963
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
963
+        $address_row .= wpautop(wp_kses_post($address_fields));
964 964
     }
965 965
     
966
-    if ( $address_row ) {
966
+    if ($address_row) {
967 967
         $output .= '<div class="address">' . $address_row . '</div>';
968 968
     }
969 969
     
970
-    if ( $phone = $invoice->get_phone() ) {
971
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
970
+    if ($phone = $invoice->get_phone()) {
971
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
972 972
     }
973
-    if ( $email = $invoice->get_email() ) {
974
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
973
+    if ($email = $invoice->get_email()) {
974
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
975 975
     }
976 976
     
977 977
     ob_start();
978
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
978
+    do_action('wpinv_display_to_address_bottom', $invoice);
979 979
     $output .= ob_get_clean();
980 980
     
981 981
     $output .= '</div>';
982
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
982
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
983 983
 
984 984
     echo $output;
985 985
 }
986 986
 
987
-function wpinv_display_line_items( $invoice_id = 0 ) {
987
+function wpinv_display_line_items($invoice_id = 0) {
988 988
     global $wpinv_euvat, $ajax_cart_details;
989
-    $invoice            = wpinv_get_invoice( $invoice_id );
989
+    $invoice            = wpinv_get_invoice($invoice_id);
990 990
     $quantities_enabled = wpinv_item_quantities_enabled();
991 991
     $use_taxes          = wpinv_use_taxes();
992 992
     $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
993
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
994
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
993
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
994
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
995 995
     
996 996
     $cart_details       = $invoice->get_cart_details();
997 997
     $ajax_cart_details  = $cart_details;
@@ -1000,64 +1000,64 @@  discard block
 block discarded – undo
1000 1000
     <table class="table table-sm table-bordered table-responsive">
1001 1001
         <thead>
1002 1002
             <tr>
1003
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1004
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1003
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1004
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1005 1005
                 <?php if ($quantities_enabled) { ?>
1006
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1006
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1007 1007
                 <?php } ?>
1008 1008
                 <?php if ($use_taxes && !$zero_tax) { ?>
1009 1009
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1010 1010
                 <?php } ?>
1011
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1011
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1012 1012
             </tr>
1013 1013
         </thead>
1014 1014
         <tbody>
1015 1015
         <?php 
1016
-            if ( !empty( $cart_details ) ) {
1017
-                do_action( 'wpinv_display_line_items_start', $invoice );
1016
+            if (!empty($cart_details)) {
1017
+                do_action('wpinv_display_line_items_start', $invoice);
1018 1018
                 
1019 1019
                 $count = 0;
1020 1020
                 $cols  = 3;
1021
-                foreach ( $cart_details as $key => $cart_item ) {
1022
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1023
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1024
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1025
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1021
+                foreach ($cart_details as $key => $cart_item) {
1022
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1023
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1024
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1025
+                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1026 1026
                     
1027
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1027
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1028 1028
                     $summary    = '';
1029 1029
                     $cols       = 3;
1030
-                    if ( !empty($item) ) {
1030
+                    if (!empty($item)) {
1031 1031
                         $item_name  = $item->get_name();
1032 1032
                         $summary    = $item->get_summary();
1033 1033
                     }
1034
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1034
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1035 1035
                     
1036
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1036
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1037 1037
                     
1038 1038
                     $item_tax       = '';
1039 1039
                     $tax_rate       = '';
1040
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1041
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1042
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1043
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1040
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1041
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1042
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1043
+                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1044 1044
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1045 1045
                     }
1046 1046
                     
1047 1047
                     $line_item_tax = $item_tax . $tax_rate;
1048 1048
                     
1049
-                    if ( $line_item_tax === '' ) {
1049
+                    if ($line_item_tax === '') {
1050 1050
                         $line_item_tax = 0; // Zero tax
1051 1051
                     }
1052 1052
                     
1053
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1054
-                        $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1055
-                        if ( $summary !== '' ) {
1056
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1053
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1054
+                        $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1055
+                        if ($summary !== '') {
1056
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1057 1057
                         }
1058 1058
                         $line_item .= '</td>';
1059 1059
                         
1060
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1060
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1061 1061
                         if ($quantities_enabled) {
1062 1062
                             $cols++;
1063 1063
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1066,55 +1066,55 @@  discard block
 block discarded – undo
1066 1066
                             $cols++;
1067 1067
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1068 1068
                         }
1069
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1069
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1070 1070
                     $line_item .= '</tr>';
1071 1071
                     
1072
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1072
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1073 1073
 
1074 1074
                     $count++;
1075 1075
                 }
1076 1076
                 
1077
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1077
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1078 1078
                 ?>
1079 1079
                 <tr class="row-sub-total row_odd">
1080
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1081
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1080
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1081
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1082 1082
                 </tr>
1083 1083
                 <?php
1084
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1084
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1085 1085
                 
1086
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1087
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1086
+                if (wpinv_discount($invoice_id, false) > 0) {
1087
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1088 1088
                     ?>
1089 1089
                         <tr class="row-discount">
1090
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1091
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1090
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1091
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1092 1092
                         </tr>
1093 1093
                     <?php
1094
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1094
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1095 1095
                 }
1096 1096
                 
1097
-                if ( $use_taxes ) {
1098
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1097
+                if ($use_taxes) {
1098
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1099 1099
                     ?>
1100 1100
                     <tr class="row-tax">
1101
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1102
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1101
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1102
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1103 1103
                     </tr>
1104 1104
                     <?php
1105
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1105
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1106 1106
                 }
1107 1107
                 
1108
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1108
+                do_action('wpinv_display_before_total', $invoice, $cols);
1109 1109
                 ?>
1110 1110
                 <tr class="table-active row-total">
1111
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1112
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1111
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1112
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1113 1113
                 </tr>
1114 1114
                 <?php
1115
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1115
+                do_action('wpinv_display_after_total', $invoice, $cols);
1116 1116
                 
1117
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1117
+                do_action('wpinv_display_line_end', $invoice, $cols);
1118 1118
             }
1119 1119
         ?>
1120 1120
         </tbody>
@@ -1123,35 +1123,35 @@  discard block
 block discarded – undo
1123 1123
     echo ob_get_clean();
1124 1124
 }
1125 1125
 
1126
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {    
1126
+function wpinv_display_invoice_totals($invoice_id = 0) {    
1127 1127
     $use_taxes = wpinv_use_taxes();
1128 1128
     
1129
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1129
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1130 1130
     ?>
1131 1131
     <table class="table table-sm table-bordered table-responsive">
1132 1132
         <tbody>
1133
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1133
+            <?php do_action('wpinv_before_display_totals'); ?>
1134 1134
             <tr class="row-sub-total">
1135
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1136
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1135
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1136
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1137 1137
             </tr>
1138
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1139
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1138
+            <?php do_action('wpinv_after_display_totals'); ?>
1139
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1140 1140
                 <tr class="row-discount">
1141
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1142
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1141
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1142
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1143 1143
                 </tr>
1144
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1144
+            <?php do_action('wpinv_after_display_discount'); ?>
1145 1145
             <?php } ?>
1146
-            <?php if ( $use_taxes ) { ?>
1146
+            <?php if ($use_taxes) { ?>
1147 1147
             <tr class="row-tax">
1148
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1149
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1148
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1149
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1150 1150
             </tr>
1151
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1151
+            <?php do_action('wpinv_after_display_tax'); ?>
1152 1152
             <?php } ?>
1153
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1154
-                <?php foreach ( $fees as $fee ) { ?>
1153
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1154
+                <?php foreach ($fees as $fee) { ?>
1155 1155
                     <tr class="row-fee">
1156 1156
                         <td class="rate"><?php echo $fee['label']; ?></td>
1157 1157
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1159,73 +1159,73 @@  discard block
 block discarded – undo
1159 1159
                 <?php } ?>
1160 1160
             <?php } ?>
1161 1161
             <tr class="table-active row-total">
1162
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1163
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1162
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1163
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1164 1164
             </tr>
1165
-            <?php do_action( 'wpinv_after_totals' ); ?>
1165
+            <?php do_action('wpinv_after_totals'); ?>
1166 1166
         </tbody>
1167 1167
 
1168 1168
     </table>
1169 1169
 
1170
-    <?php do_action( 'wpinv_after_totals_table' );
1170
+    <?php do_action('wpinv_after_totals_table');
1171 1171
 }
1172 1172
 
1173
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1174
-    $invoice = wpinv_get_invoice( $invoice_id );
1173
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1174
+    $invoice = wpinv_get_invoice($invoice_id);
1175 1175
     
1176 1176
     ob_start();
1177
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1178
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1177
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1178
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1179 1179
         ?>
1180 1180
         <div class="wpi-payment-info">
1181
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1182
-            <?php if ( $gateway_title ) { ?>
1183
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1181
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1182
+            <?php if ($gateway_title) { ?>
1183
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1184 1184
             <?php } ?>
1185 1185
         </div>
1186 1186
         <?php
1187 1187
     }
1188
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1188
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1189 1189
     $outout = ob_get_clean();
1190 1190
     
1191
-    if ( $echo ) {
1191
+    if ($echo) {
1192 1192
         echo $outout;
1193 1193
     } else {
1194 1194
         return $outout;
1195 1195
     }
1196 1196
 }
1197 1197
 
1198
-function wpinv_display_style( $invoice ) {
1199
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1198
+function wpinv_display_style($invoice) {
1199
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1200 1200
     
1201
-    wp_print_styles( 'open-sans' );
1202
-    wp_print_styles( 'wpinv-single-style' );
1201
+    wp_print_styles('open-sans');
1202
+    wp_print_styles('wpinv-single-style');
1203 1203
 }
1204
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1205
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1204
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1205
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1206 1206
 
1207 1207
 function wpinv_checkout_billing_details() {  
1208 1208
     $invoice_id = (int)wpinv_get_invoice_cart_id();
1209 1209
     if (empty($invoice_id)) {
1210
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1210
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1211 1211
         return null;
1212 1212
     }
1213 1213
     
1214
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1214
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1215 1215
     if (empty($invoice)) {
1216
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1216
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1217 1217
         return null;
1218 1218
     }
1219 1219
     $user_id        = $invoice->get_user_id();
1220 1220
     $user_info      = $invoice->get_user_info();
1221
-    $address_info   = wpinv_get_user_address( $user_id );
1221
+    $address_info   = wpinv_get_user_address($user_id);
1222 1222
     
1223
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1223
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1224 1224
         $user_info['first_name'] = $user_info['first_name'];
1225 1225
         $user_info['last_name'] = $user_info['last_name'];
1226 1226
     }
1227 1227
     
1228
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1228
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1229 1229
         $user_info['country']   = $address_info['country'];
1230 1230
         $user_info['state']     = $address_info['state'];
1231 1231
         $user_info['city']      = $address_info['city'];
@@ -1241,98 +1241,98 @@  discard block
 block discarded – undo
1241 1241
         'address'
1242 1242
     );
1243 1243
     
1244
-    foreach ( $address_fields as $field ) {
1245
-        if ( empty( $user_info[$field] ) ) {
1244
+    foreach ($address_fields as $field) {
1245
+        if (empty($user_info[$field])) {
1246 1246
             $user_info[$field] = $address_info[$field];
1247 1247
         }
1248 1248
     }
1249 1249
     
1250
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1250
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1251 1251
 }
1252 1252
 
1253 1253
 function wpinv_admin_get_line_items($invoice = array()) {
1254 1254
     $item_quantities    = wpinv_item_quantities_enabled();
1255 1255
     $use_taxes          = wpinv_use_taxes();
1256 1256
     
1257
-    if ( empty( $invoice ) ) {
1257
+    if (empty($invoice)) {
1258 1258
         return NULL;
1259 1259
     }
1260 1260
     
1261 1261
     $cart_items = $invoice->get_cart_details();
1262
-    if ( empty( $cart_items ) ) {
1262
+    if (empty($cart_items)) {
1263 1263
         return NULL;
1264 1264
     }
1265 1265
     ob_start();
1266 1266
     
1267
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1267
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1268 1268
     
1269 1269
     $count = 0;
1270
-    foreach ( $cart_items as $key => $cart_item ) {
1270
+    foreach ($cart_items as $key => $cart_item) {
1271 1271
         $item_id    = $cart_item['id'];
1272
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1272
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1273 1273
         
1274 1274
         if (empty($wpi_item)) {
1275 1275
             continue;
1276 1276
         }
1277 1277
         
1278
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1279
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1280
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1278
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1279
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1280
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1281 1281
         $can_remove     = true;
1282 1282
         
1283
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1283
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1284 1284
         
1285 1285
         $item_tax       = '';
1286 1286
         $tax_rate       = '';
1287
-        if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1288
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1289
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1290
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1287
+        if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1288
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1289
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1290
+            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1291 1291
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1292 1292
         }
1293 1293
         $line_item_tax = $item_tax . $tax_rate;
1294 1294
         
1295
-        if ( $line_item_tax === '' ) {
1295
+        if ($line_item_tax === '') {
1296 1296
             $line_item_tax = 0; // Zero tax
1297 1297
         }
1298 1298
 
1299
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1299
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1300 1300
             $line_item .= '<td class="id">' . $item_id . '</td>';
1301
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1302
-            if ( $summary !== '' ) {
1303
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1301
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1302
+            if ($summary !== '') {
1303
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1304 1304
             }
1305 1305
             $line_item .= '</td>';
1306 1306
             $line_item .= '<td class="price">' . $item_price . '</td>';
1307 1307
             
1308
-            if ( $item_quantities ) {
1309
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1308
+            if ($item_quantities) {
1309
+                if (count($cart_items) == 1 && $quantity <= 1) {
1310 1310
                     $can_remove = false;
1311 1311
                 }
1312 1312
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1313 1313
             } else {
1314
-                if ( count( $cart_items ) == 1 ) {
1314
+                if (count($cart_items) == 1) {
1315 1315
                     $can_remove = false;
1316 1316
                 }
1317 1317
             }
1318 1318
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1319 1319
             
1320
-            if ( $use_taxes ) {
1320
+            if ($use_taxes) {
1321 1321
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1322 1322
             }
1323 1323
             $line_item .= '<td class="action">';
1324
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) {
1324
+            if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) {
1325 1325
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1326 1326
             }
1327 1327
             $line_item .= '</td>';
1328 1328
         $line_item .= '</tr>';
1329 1329
         
1330
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1330
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1331 1331
         
1332 1332
         $count++;
1333 1333
     } 
1334 1334
     
1335
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1335
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1336 1336
     
1337 1337
     return ob_get_clean();
1338 1338
 }
@@ -1343,35 +1343,35 @@  discard block
 block discarded – undo
1343 1343
     // Set current invoice id.
1344 1344
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1345 1345
     
1346
-    $form_action  = esc_url( wpinv_get_checkout_uri() );
1346
+    $form_action = esc_url(wpinv_get_checkout_uri());
1347 1347
 
1348 1348
     ob_start();
1349 1349
         echo '<div id="wpinv_checkout_wrap">';
1350 1350
         
1351
-        if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) {
1351
+        if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) {
1352 1352
             ?>
1353 1353
             <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive">
1354
-                <?php do_action( 'wpinv_before_checkout_form' ); ?>
1354
+                <?php do_action('wpinv_before_checkout_form'); ?>
1355 1355
                 <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST">
1356 1356
                     <?php
1357
-                    do_action( 'wpinv_checkout_form_top' );
1358
-                    do_action( 'wpinv_checkout_billing_info' );
1359
-                    do_action( 'wpinv_checkout_cart' );
1360
-                    do_action( 'wpinv_payment_mode_select'  );
1361
-                    do_action( 'wpinv_checkout_form_bottom' )
1357
+                    do_action('wpinv_checkout_form_top');
1358
+                    do_action('wpinv_checkout_billing_info');
1359
+                    do_action('wpinv_checkout_cart');
1360
+                    do_action('wpinv_payment_mode_select');
1361
+                    do_action('wpinv_checkout_form_bottom')
1362 1362
                     ?>
1363 1363
                 </form>
1364
-                <?php do_action( 'wpinv_after_purchase_form' ); ?>
1364
+                <?php do_action('wpinv_after_purchase_form'); ?>
1365 1365
             </div><!--end #wpinv_checkout_form_wrap-->
1366 1366
         <?php
1367 1367
         } else {
1368
-            do_action( 'wpinv_cart_empty' );
1368
+            do_action('wpinv_cart_empty');
1369 1369
         }
1370 1370
         echo '</div><!--end #wpinv_checkout_wrap-->';
1371 1371
     return ob_get_clean();
1372 1372
 }
1373 1373
 
1374
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1374
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1375 1375
     global $ajax_cart_details;
1376 1376
     $ajax_cart_details = $cart_details;
1377 1377
     /*
@@ -1386,25 +1386,25 @@  discard block
 block discarded – undo
1386 1386
     }
1387 1387
     */
1388 1388
     ob_start();
1389
-    do_action( 'wpinv_before_checkout_cart' );
1389
+    do_action('wpinv_before_checkout_cart');
1390 1390
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1391 1391
         echo '<div id="wpinv_checkout_cart_wrap">';
1392
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1392
+            wpinv_get_template_part('wpinv-checkout-cart');
1393 1393
         echo '</div>';
1394 1394
     echo '</div>';
1395
-    do_action( 'wpinv_after_checkout_cart' );
1395
+    do_action('wpinv_after_checkout_cart');
1396 1396
     $content = ob_get_clean();
1397 1397
     
1398
-    if ( $echo ) {
1398
+    if ($echo) {
1399 1399
         echo $content;
1400 1400
     } else {
1401 1401
         return $content;
1402 1402
     }
1403 1403
 }
1404
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1404
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1405 1405
 
1406 1406
 function wpinv_empty_cart_message() {
1407
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1407
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1408 1408
 }
1409 1409
 
1410 1410
 /**
@@ -1416,91 +1416,91 @@  discard block
 block discarded – undo
1416 1416
 function wpinv_empty_checkout_cart() {
1417 1417
 	echo wpinv_empty_cart_message();
1418 1418
 }
1419
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1419
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1420 1420
 
1421 1421
 function wpinv_save_cart_button() {
1422
-    if ( wpinv_is_cart_saving_disabled() )
1422
+    if (wpinv_is_cart_saving_disabled())
1423 1423
         return;
1424 1424
 ?>
1425
-    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a>
1425
+    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a>
1426 1426
 <?php
1427 1427
 }
1428 1428
 
1429 1429
 function wpinv_update_cart_button() {
1430
-    if ( !wpinv_item_quantities_enabled() )
1430
+    if (!wpinv_item_quantities_enabled())
1431 1431
         return;
1432 1432
 ?>
1433
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1433
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1434 1434
     <input type="hidden" name="wpi_action" value="update_cart"/>
1435 1435
 <?php
1436 1436
 }
1437 1437
 
1438 1438
 function wpinv_checkout_cart_columns() {
1439 1439
     $default = 3;
1440
-    if ( wpinv_item_quantities_enabled() ) {
1440
+    if (wpinv_item_quantities_enabled()) {
1441 1441
         $default++;
1442 1442
     }
1443 1443
     
1444
-    if ( wpinv_use_taxes() ) {
1444
+    if (wpinv_use_taxes()) {
1445 1445
         $default++;
1446 1446
     }
1447 1447
 
1448
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1448
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1449 1449
 }
1450 1450
 
1451 1451
 function wpinv_display_cart_messages() {
1452 1452
     global $wpi_session;
1453 1453
 
1454
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1454
+    $messages = $wpi_session->get('wpinv_cart_messages');
1455 1455
 
1456
-    if ( $messages ) {
1457
-        foreach ( $messages as $message_id => $message ) {
1456
+    if ($messages) {
1457
+        foreach ($messages as $message_id => $message) {
1458 1458
             // Try and detect what type of message this is
1459
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1459
+            if (strpos(strtolower($message), 'error')) {
1460 1460
                 $type = 'error';
1461
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1461
+            } elseif (strpos(strtolower($message), 'success')) {
1462 1462
                 $type = 'success';
1463 1463
             } else {
1464 1464
                 $type = 'info';
1465 1465
             }
1466 1466
 
1467
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1467
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1468 1468
 
1469
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1469
+            echo '<div class="' . implode(' ', $classes) . '">';
1470 1470
                 // Loop message codes and display messages
1471 1471
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1472 1472
             echo '</div>';
1473 1473
         }
1474 1474
 
1475 1475
         // Remove all of the cart saving messages
1476
-        $wpi_session->set( 'wpinv_cart_messages', null );
1476
+        $wpi_session->set('wpinv_cart_messages', null);
1477 1477
     }
1478 1478
 }
1479
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1479
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1480 1480
 
1481 1481
 function wpinv_discount_field() {
1482
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1482
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1483 1483
         return; // Only show before a payment method has been selected if ajax is disabled
1484 1484
     }
1485 1485
 
1486
-    if ( !wpinv_is_checkout() ) {
1486
+    if (!wpinv_is_checkout()) {
1487 1487
         return;
1488 1488
     }
1489 1489
 
1490
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1490
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1491 1491
     ?>
1492 1492
     <div id="wpinv-discount-field" class="panel panel-default">
1493 1493
         <div class="panel-body">
1494 1494
             <p>
1495
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1496
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1495
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1496
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1497 1497
             </p>
1498 1498
             <div class="form-group row">
1499 1499
                 <div class="col-sm-4">
1500
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1500
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1501 1501
                 </div>
1502 1502
                 <div class="col-sm-3">
1503
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1503
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1504 1504
                 </div>
1505 1505
                 <div style="clear:both"></div>
1506 1506
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1513,10 +1513,10 @@  discard block
 block discarded – undo
1513 1513
 <?php
1514 1514
     }
1515 1515
 }
1516
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1516
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1517 1517
 
1518 1518
 function wpinv_agree_to_terms_js() {
1519
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1519
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1520 1520
 ?>
1521 1521
 <script type="text/javascript">
1522 1522
     jQuery(document).ready(function($){
@@ -1531,126 +1531,126 @@  discard block
 block discarded – undo
1531 1531
 <?php
1532 1532
     }
1533 1533
 }
1534
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1534
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1535 1535
 
1536 1536
 function wpinv_payment_mode_select() {
1537
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1538
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1537
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1538
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1539 1539
     $page_URL = wpinv_get_current_page_url();
1540
-    $invoice = wpinv_get_invoice( 0, true );
1540
+    $invoice = wpinv_get_invoice(0, true);
1541 1541
     
1542 1542
     do_action('wpinv_payment_mode_top');
1543 1543
     $invoice_id = (int)$invoice->ID;
1544
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1544
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1545 1545
     ?>
1546
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;" data-free="1"' : '' ); ?>>
1547
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1546
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;" data-free="1"' : ''); ?>>
1547
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1548 1548
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1549
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1549
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1550 1550
                 <div class="panel-body list-group wpi-payment_methods">
1551 1551
                     <?php
1552
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1552
+                    do_action('wpinv_payment_mode_before_gateways');
1553 1553
                     
1554
-                    if(!empty($gateways)){
1555
-	                    foreach ( $gateways as $gateway_id => $gateway ) {
1556
-		                    $checked = checked( $gateway_id, $chosen_gateway, false );
1557
-		                    $button_label = wpinv_get_gateway_button_label( $gateway_id );
1558
-		                    $description = wpinv_get_gateway_description( $gateway_id );
1554
+                    if (!empty($gateways)) {
1555
+	                    foreach ($gateways as $gateway_id => $gateway) {
1556
+		                    $checked = checked($gateway_id, $chosen_gateway, false);
1557
+		                    $button_label = wpinv_get_gateway_button_label($gateway_id);
1558
+		                    $description = wpinv_get_gateway_description($gateway_id);
1559 1559
 		                    ?>
1560 1560
 		                    <div class="list-group-item">
1561 1561
 			                    <div class="radio">
1562
-				                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label>
1562
+				                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway['checkout_label']); ?></label>
1563 1563
 			                    </div>
1564
-			                    <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1565
-				                    <?php if ( !empty( $description ) ) { ?>
1566
-					                    <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div>
1564
+			                    <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1565
+				                    <?php if (!empty($description)) { ?>
1566
+					                    <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div>
1567 1567
 				                    <?php } ?>
1568
-				                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1568
+				                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1569 1569
 			                    </div>
1570 1570
 		                    </div>
1571 1571
 		                    <?php
1572 1572
 	                    }
1573
-                    }else{
1574
-	                    echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>';
1573
+                    } else {
1574
+	                    echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1575 1575
                     }
1576 1576
 
1577
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1577
+                    do_action('wpinv_payment_mode_after_gateways');
1578 1578
                     ?>
1579 1579
                 </div>
1580 1580
             </div>
1581
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1581
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1582 1582
     </div>
1583 1583
     <?php
1584 1584
     do_action('wpinv_payment_mode_bottom');
1585 1585
 }
1586
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1586
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1587 1587
 
1588 1588
 function wpinv_checkout_billing_info() {    
1589
-    if ( wpinv_is_checkout() ) {
1589
+    if (wpinv_is_checkout()) {
1590 1590
         $logged_in          = is_user_logged_in();
1591 1591
         $billing_details    = wpinv_checkout_billing_details();
1592
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1592
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1593 1593
         ?>
1594 1594
         <div id="wpinv-fields" class="clearfix">
1595 1595
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1596
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1596
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1597 1597
                 <div id="wpinv-fields-box" class="panel-body">
1598
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1598
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1599 1599
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1600
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1600
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1601 1601
                         <?php
1602
-                        echo wpinv_html_text( array(
1602
+                        echo wpinv_html_text(array(
1603 1603
                                 'id'            => 'wpinv_first_name',
1604 1604
                                 'name'          => 'wpinv_first_name',
1605 1605
                                 'value'         => $billing_details['first_name'],
1606 1606
                                 'class'         => 'wpi-input form-control',
1607
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1608
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1609
-                            ) );
1607
+                                'placeholder'   => __('First name', 'invoicing'),
1608
+                                'required'      => (bool)wpinv_get_option('fname_mandatory'),
1609
+                            ));
1610 1610
                         ?>
1611 1611
                     </p>
1612 1612
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1613
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1613
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1614 1614
                         <?php
1615
-                        echo wpinv_html_text( array(
1615
+                        echo wpinv_html_text(array(
1616 1616
                                 'id'            => 'wpinv_last_name',
1617 1617
                                 'name'          => 'wpinv_last_name',
1618 1618
                                 'value'         => $billing_details['last_name'],
1619 1619
                                 'class'         => 'wpi-input form-control',
1620
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1621
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1622
-                            ) );
1620
+                                'placeholder'   => __('Last name', 'invoicing'),
1621
+                                'required'      => (bool)wpinv_get_option('lname_mandatory'),
1622
+                            ));
1623 1623
                         ?>
1624 1624
                     </p>
1625 1625
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1626
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1626
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1627 1627
                         <?php
1628
-                        echo wpinv_html_text( array(
1628
+                        echo wpinv_html_text(array(
1629 1629
                                 'id'            => 'wpinv_address',
1630 1630
                                 'name'          => 'wpinv_address',
1631 1631
                                 'value'         => $billing_details['address'],
1632 1632
                                 'class'         => 'wpi-input form-control',
1633
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1634
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1635
-                            ) );
1633
+                                'placeholder'   => __('Address', 'invoicing'),
1634
+                                'required'      => (bool)wpinv_get_option('address_mandatory'),
1635
+                            ));
1636 1636
                         ?>
1637 1637
                     </p>
1638 1638
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1639
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1639
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1640 1640
                         <?php
1641
-                        echo wpinv_html_text( array(
1641
+                        echo wpinv_html_text(array(
1642 1642
                                 'id'            => 'wpinv_city',
1643 1643
                                 'name'          => 'wpinv_city',
1644 1644
                                 'value'         => $billing_details['city'],
1645 1645
                                 'class'         => 'wpi-input form-control',
1646
-                                'placeholder'   => __( 'City', 'invoicing' ),
1647
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1648
-                            ) );
1646
+                                'placeholder'   => __('City', 'invoicing'),
1647
+                                'required'      => (bool)wpinv_get_option('city_mandatory'),
1648
+                            ));
1649 1649
                         ?>
1650 1650
                     </p>
1651 1651
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1652
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1653
-                        <?php echo wpinv_html_select( array(
1652
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1653
+                        <?php echo wpinv_html_select(array(
1654 1654
                             'options'          => wpinv_get_country_list(),
1655 1655
                             'name'             => 'wpinv_country',
1656 1656
                             'id'               => 'wpinv_country',
@@ -1658,16 +1658,16 @@  discard block
 block discarded – undo
1658 1658
                             'show_option_all'  => false,
1659 1659
                             'show_option_none' => false,
1660 1660
                             'class'            => 'wpi-input form-control',
1661
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1662
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1663
-                        ) ); ?>
1661
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1662
+                            'required'         => (bool)wpinv_get_option('country_mandatory'),
1663
+                        )); ?>
1664 1664
                     </p>
1665 1665
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1666
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1666
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1667 1667
                         <?php
1668
-                        $states = wpinv_get_country_states( $selected_country );
1669
-                        if( !empty( $states ) ) {
1670
-                            echo wpinv_html_select( array(
1668
+                        $states = wpinv_get_country_states($selected_country);
1669
+                        if (!empty($states)) {
1670
+                            echo wpinv_html_select(array(
1671 1671
                                 'options'          => $states,
1672 1672
                                 'name'             => 'wpinv_state',
1673 1673
                                 'id'               => 'wpinv_state',
@@ -1675,61 +1675,61 @@  discard block
 block discarded – undo
1675 1675
                                 'show_option_all'  => false,
1676 1676
                                 'show_option_none' => false,
1677 1677
                                 'class'            => 'wpi-input form-control',
1678
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1679
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1680
-                            ) );
1678
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1679
+                                'required'         => (bool)wpinv_get_option('state_mandatory'),
1680
+                            ));
1681 1681
                         } else {
1682
-                            echo wpinv_html_text( array(
1682
+                            echo wpinv_html_text(array(
1683 1683
                                 'name'          => 'wpinv_state',
1684 1684
                                 'value'         => $billing_details['state'],
1685 1685
                                 'id'            => 'wpinv_state',
1686 1686
                                 'class'         => 'wpi-input form-control',
1687
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1688
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1689
-                            ) );
1687
+                                'placeholder'   => __('State / Province', 'invoicing'),
1688
+                                'required'      => (bool)wpinv_get_option('state_mandatory'),
1689
+                            ));
1690 1690
                         }
1691 1691
                         ?>
1692 1692
                     </p>
1693 1693
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1694
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1694
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1695 1695
                         <?php
1696
-                        echo wpinv_html_text( array(
1696
+                        echo wpinv_html_text(array(
1697 1697
                                 'name'          => 'wpinv_zip',
1698 1698
                                 'value'         => $billing_details['zip'],
1699 1699
                                 'id'            => 'wpinv_zip',
1700 1700
                                 'class'         => 'wpi-input form-control',
1701
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1702
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1703
-                            ) );
1701
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1702
+                                'required'      => (bool)wpinv_get_option('zip_mandatory'),
1703
+                            ));
1704 1704
                         ?>
1705 1705
                     </p>
1706 1706
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1707
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1707
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1708 1708
                         <?php
1709
-                        echo wpinv_html_text( array(
1709
+                        echo wpinv_html_text(array(
1710 1710
                                 'id'            => 'wpinv_phone',
1711 1711
                                 'name'          => 'wpinv_phone',
1712 1712
                                 'value'         => $billing_details['phone'],
1713 1713
                                 'class'         => 'wpi-input form-control',
1714
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1715
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1716
-                            ) );
1714
+                                'placeholder'   => __('Phone', 'invoicing'),
1715
+                                'required'      => (bool)wpinv_get_option('phone_mandatory'),
1716
+                            ));
1717 1717
                         ?>
1718 1718
                     </p>
1719
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1719
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1720 1720
                     <div class="clearfix"></div>
1721 1721
                 </div>
1722 1722
             </div>
1723
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1723
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1724 1724
         </div>
1725 1725
         <?php
1726 1726
     }
1727 1727
 }
1728
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1728
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1729 1729
 
1730 1730
 function wpinv_checkout_hidden_fields() {
1731 1731
 ?>
1732
-    <?php if ( is_user_logged_in() ) { ?>
1732
+    <?php if (is_user_logged_in()) { ?>
1733 1733
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1734 1734
     <?php } ?>
1735 1735
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1739,9 +1739,9 @@  discard block
 block discarded – undo
1739 1739
 function wpinv_checkout_button_purchase() {
1740 1740
     ob_start();
1741 1741
 ?>
1742
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1742
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1743 1743
 <?php
1744
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1744
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1745 1745
 }
1746 1746
 
1747 1747
 function wpinv_checkout_total() {
@@ -1750,96 +1750,96 @@  discard block
 block discarded – undo
1750 1750
 <div id="wpinv_checkout_total" class="panel panel-info">
1751 1751
     <div class="panel-body">
1752 1752
     <?php
1753
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1753
+    do_action('wpinv_purchase_form_before_checkout_total');
1754 1754
     ?>
1755
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1755
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1756 1756
     <?php
1757
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1757
+    do_action('wpinv_purchase_form_after_checkout_total');
1758 1758
     ?>
1759 1759
     </div>
1760 1760
 </div>
1761 1761
 <?php
1762 1762
 }
1763
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1763
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1764 1764
 
1765 1765
 function wpinv_checkout_submit() {
1766 1766
 ?>
1767 1767
 <div id="wpinv_purchase_submit" class="panel panel-success">
1768 1768
     <div class="panel-body text-center">
1769 1769
     <?php
1770
-    do_action( 'wpinv_purchase_form_before_submit' );
1770
+    do_action('wpinv_purchase_form_before_submit');
1771 1771
     wpinv_checkout_hidden_fields();
1772 1772
     echo wpinv_checkout_button_purchase();
1773
-    do_action( 'wpinv_purchase_form_after_submit' );
1773
+    do_action('wpinv_purchase_form_after_submit');
1774 1774
     ?>
1775 1775
     </div>
1776 1776
 </div>
1777 1777
 <?php
1778 1778
 }
1779
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1779
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1780 1780
 
1781
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1782
-    $invoice = wpinv_get_invoice( $invoice_id );
1781
+function wpinv_receipt_billing_address($invoice_id = 0) {
1782
+    $invoice = wpinv_get_invoice($invoice_id);
1783 1783
     
1784
-    if ( empty( $invoice ) ) {
1784
+    if (empty($invoice)) {
1785 1785
         return NULL;
1786 1786
     }
1787 1787
     
1788 1788
     $billing_details = $invoice->get_user_info();
1789 1789
     $address_row = '';
1790
-    if ( $address = $billing_details['address'] ) {
1791
-        $address_row .= wpautop( wp_kses_post( $address ) );
1790
+    if ($address = $billing_details['address']) {
1791
+        $address_row .= wpautop(wp_kses_post($address));
1792 1792
     }
1793 1793
     
1794 1794
     $address_fields = array();
1795
-    if ( !empty( $billing_details['city'] ) ) {
1795
+    if (!empty($billing_details['city'])) {
1796 1796
         $address_fields[] = $billing_details['city'];
1797 1797
     }
1798 1798
     
1799
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
1800
-    if ( !empty( $billing_details['state'] ) ) {
1801
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
1799
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
1800
+    if (!empty($billing_details['state'])) {
1801
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
1802 1802
     }
1803 1803
     
1804
-    if ( !empty( $billing_country ) ) {
1805
-        $address_fields[] = wpinv_country_name( $billing_country );
1804
+    if (!empty($billing_country)) {
1805
+        $address_fields[] = wpinv_country_name($billing_country);
1806 1806
     }
1807 1807
     
1808
-    if ( !empty( $address_fields ) ) {
1809
-        $address_fields = implode( ", ", $address_fields );
1808
+    if (!empty($address_fields)) {
1809
+        $address_fields = implode(", ", $address_fields);
1810 1810
         
1811
-        if ( !empty( $billing_details['zip'] ) ) {
1811
+        if (!empty($billing_details['zip'])) {
1812 1812
             $address_fields .= ' ' . $billing_details['zip'];
1813 1813
         }
1814 1814
         
1815
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
1815
+        $address_row .= wpautop(wp_kses_post($address_fields));
1816 1816
     }
1817 1817
     ob_start();
1818 1818
     ?>
1819 1819
     <table class="table table-bordered table-sm wpi-billing-details">
1820 1820
         <tbody>
1821 1821
             <tr class="wpi-receipt-name">
1822
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1823
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1822
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1823
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1824 1824
             </tr>
1825 1825
             <tr class="wpi-receipt-email">
1826
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1827
-                <td><?php echo $billing_details['email'] ;?></td>
1826
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1827
+                <td><?php echo $billing_details['email']; ?></td>
1828 1828
             </tr>
1829
-            <?php if ( $billing_details['company'] ) { ?>
1829
+            <?php if ($billing_details['company']) { ?>
1830 1830
             <tr class="wpi-receipt-company">
1831
-                <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th>
1832
-                <td><?php echo esc_html( $billing_details['company'] ) ;?></td>
1831
+                <th class="text-left"><?php _e('Company', 'invoicing'); ?></th>
1832
+                <td><?php echo esc_html($billing_details['company']); ?></td>
1833 1833
             </tr>
1834 1834
             <?php } ?>
1835 1835
             <tr class="wpi-receipt-address">
1836
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1837
-                <td><?php echo $address_row ;?></td>
1836
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1837
+                <td><?php echo $address_row; ?></td>
1838 1838
             </tr>
1839
-            <?php if ( $billing_details['phone'] ) { ?>
1839
+            <?php if ($billing_details['phone']) { ?>
1840 1840
             <tr class="wpi-receipt-phone">
1841
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1842
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1841
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1842
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1843 1843
             </tr>
1844 1844
             <?php } ?>
1845 1845
         </tbody>
@@ -1847,103 +1847,103 @@  discard block
 block discarded – undo
1847 1847
     <?php
1848 1848
     $output = ob_get_clean();
1849 1849
     
1850
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1850
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1851 1851
 
1852 1852
     echo $output;
1853 1853
 }
1854 1854
 
1855
-function wpinv_filter_success_page_content( $content ) {
1856
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1857
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1858
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1855
+function wpinv_filter_success_page_content($content) {
1856
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1857
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1858
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1859 1859
         }
1860 1860
     }
1861 1861
 
1862 1862
     return $content;
1863 1863
 }
1864
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1864
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1865 1865
 
1866
-function wpinv_receipt_actions( $invoice ) {
1867
-    if ( !empty( $invoice ) ) {
1866
+function wpinv_receipt_actions($invoice) {
1867
+    if (!empty($invoice)) {
1868 1868
         $actions = array();
1869 1869
 
1870
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1871
-            $actions['print']   = array(
1872
-                'url'  => $invoice->get_view_url( true ),
1873
-                'name' => __( 'Print Invoice', 'invoicing' ),
1870
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1871
+            $actions['print'] = array(
1872
+                'url'  => $invoice->get_view_url(true),
1873
+                'name' => __('Print Invoice', 'invoicing'),
1874 1874
                 'class' => 'btn-primary',
1875 1875
             );
1876 1876
         }
1877 1877
 
1878
-        if ( is_user_logged_in() ) {
1878
+        if (is_user_logged_in()) {
1879 1879
             $actions['history'] = array(
1880 1880
                 'url'  => wpinv_get_history_page_uri(),
1881
-                'name' => __( 'Invoice History', 'invoicing' ),
1881
+                'name' => __('Invoice History', 'invoicing'),
1882 1882
                 'class' => 'btn-warning',
1883 1883
             );
1884 1884
         }
1885 1885
 
1886
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1886
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1887 1887
         
1888
-        if ( !empty( $actions ) ) {
1888
+        if (!empty($actions)) {
1889 1889
         ?>
1890 1890
         <div class="wpinv-receipt-actions text-right">
1891
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1892
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1891
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1892
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1893 1893
             <?php } ?>
1894 1894
         </div>
1895 1895
         <?php
1896 1896
         }
1897 1897
     }
1898 1898
 }
1899
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1899
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1900 1900
 
1901
-function wpinv_invoice_link( $invoice_id ) {
1902
-    $invoice = wpinv_get_invoice( $invoice_id );
1901
+function wpinv_invoice_link($invoice_id) {
1902
+    $invoice = wpinv_get_invoice($invoice_id);
1903 1903
     
1904
-    if ( empty( $invoice ) ) {
1904
+    if (empty($invoice)) {
1905 1905
         return NULL;
1906 1906
     }
1907 1907
     
1908
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1908
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1909 1909
     
1910
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1910
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1911 1911
 }
1912 1912
 
1913
-function wpinv_invoice_subscription_details( $invoice ) {
1914
-    if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) {
1913
+function wpinv_invoice_subscription_details($invoice) {
1914
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1915 1915
         $total_payments = (int)$invoice->get_total_payments();
1916 1916
         $payments       = $invoice->get_child_payments();
1917 1917
         
1918 1918
         $subscription   = $invoice->get_subscription_data();
1919 1919
         
1920
-        if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) {
1920
+        if (!(!empty($subscription) && !empty($subscription['item_id']))) {
1921 1921
             return;
1922 1922
         }
1923 1923
         
1924
-        $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
1925
-        $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
1924
+        $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
1925
+        $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
1926 1926
         
1927 1927
         $subscription_status = $invoice->get_subscription_status();
1928 1928
         
1929 1929
         $status_desc = '';
1930
-        if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) {
1931
-            $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date );
1932
-        } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) {
1933
-            $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date );
1930
+        if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) {
1931
+            $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date);
1932
+        } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) {
1933
+            $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date);
1934 1934
         }
1935 1935
         $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : '';
1936 1936
         ?>
1937 1937
         <div class="wpinv-subscriptions-details">
1938
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1938
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1939 1939
             <table class="table">
1940 1940
                 <thead>
1941 1941
                     <tr>
1942
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1943
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1944
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1945
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1946
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1942
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1943
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1944
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1945
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1946
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1947 1947
                     </tr>
1948 1948
                 </thead>
1949 1949
                 <tbody>
@@ -1952,32 +1952,32 @@  discard block
 block discarded – undo
1952 1952
                         <td><?php echo $invoice->get_subscription_start(); ?></td>
1953 1953
                         <td><?php echo $invoice->get_subscription_end(); ?></td>
1954 1954
                         <td class="text-center"><?php echo $times_billed; ?></td>
1955
-                        <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?>
1955
+                        <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?>
1956 1956
                         <?php echo $status_desc; ?>
1957 1957
                         </td>
1958 1958
                     </tr>
1959 1959
                 </tbody>
1960 1960
             </table>
1961 1961
         </div>
1962
-        <?php if ( !empty( $payments ) ) { ?>
1962
+        <?php if (!empty($payments)) { ?>
1963 1963
         <div class="wpinv-renewal-payments">
1964
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1964
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1965 1965
             <table class="table">
1966 1966
                 <thead>
1967 1967
                     <tr>
1968 1968
                         <th>#</th>
1969
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1970
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1971
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1969
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1970
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1971
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1972 1972
                     </tr>
1973 1973
                 </thead>
1974 1974
                 <tbody>
1975
-                    <?php foreach ( $payments as $key => $invoice_id ) { ?>
1975
+                    <?php foreach ($payments as $key => $invoice_id) { ?>
1976 1976
                     <tr>
1977
-                        <th scope="row"><?php echo ( $key + 1 );?></th>
1978
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1979
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
1980
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
1977
+                        <th scope="row"><?php echo ($key + 1); ?></th>
1978
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1979
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
1980
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
1981 1981
                     </tr>
1982 1982
                     <?php } ?>
1983 1983
                     <tr><td colspan="4" style="padding:0"></td></tr>
@@ -1989,52 +1989,52 @@  discard block
 block discarded – undo
1989 1989
     }
1990 1990
 }
1991 1991
 
1992
-function wpinv_cart_total_label( $label, $invoice ) {
1993
-    if ( empty( $invoice ) ) {
1992
+function wpinv_cart_total_label($label, $invoice) {
1993
+    if (empty($invoice)) {
1994 1994
         return $label;
1995 1995
     }
1996 1996
     
1997 1997
     $prefix_label = '';
1998
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {        
1999
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2000
-    } else if ( $invoice->is_renewal() ) {
2001
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1998
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {        
1999
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2000
+    } else if ($invoice->is_renewal()) {
2001
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2002 2002
     }
2003 2003
     
2004
-    if ( $prefix_label != '' ) {
2005
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2004
+    if ($prefix_label != '') {
2005
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2006 2006
     }
2007 2007
     
2008 2008
     return $label;
2009 2009
 }
2010
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2011
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2012
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2010
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2011
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2012
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2013 2013
 
2014
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2014
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2015 2015
 
2016
-function wpinv_invoice_print_description( $invoice ) {
2017
-    if ( empty( $invoice ) ) {
2016
+function wpinv_invoice_print_description($invoice) {
2017
+    if (empty($invoice)) {
2018 2018
         return NULL;
2019 2019
     }
2020
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2020
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2021 2021
         ?>
2022 2022
         <div class="row wpinv-lower">
2023 2023
             <div class="col-sm-12 wpinv-description">
2024
-                <?php echo wpautop( $description ); ?>
2024
+                <?php echo wpautop($description); ?>
2025 2025
             </div>
2026 2026
         </div>
2027 2027
         <?php
2028 2028
     }
2029 2029
 }
2030
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2030
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2031 2031
 
2032
-function wpinv_invoice_print_payment_info( $invoice ) {
2033
-    if ( empty( $invoice ) ) {
2032
+function wpinv_invoice_print_payment_info($invoice) {
2033
+    if (empty($invoice)) {
2034 2034
         return NULL;
2035 2035
     }
2036 2036
     
2037
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2037
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2038 2038
         ?>
2039 2039
         <div class="row wpinv-payments">
2040 2040
             <div class="col-sm-12">
@@ -2046,43 +2046,43 @@  discard block
 block discarded – undo
2046 2046
 }
2047 2047
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2048 2048
 
2049
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2050
-    if ( empty( $note ) ) {
2049
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2050
+    if (empty($note)) {
2051 2051
         return NULL;
2052 2052
     }
2053 2053
     
2054
-    if ( is_int( $note ) ) {
2055
-        $note = get_comment( $note );
2054
+    if (is_int($note)) {
2055
+        $note = get_comment($note);
2056 2056
     }
2057 2057
     
2058
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2058
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2059 2059
         return NULL;
2060 2060
     }
2061 2061
     
2062
-    $note_classes   = array( 'note' );
2063
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2064
-    $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : '';
2065
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2066
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2062
+    $note_classes   = array('note');
2063
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2064
+    $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : '';
2065
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2066
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2067 2067
     
2068 2068
     ob_start();
2069 2069
     ?>
2070
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2070
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2071 2071
         <div class="note_content">
2072
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2072
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2073 2073
         </div>
2074 2074
         <p class="meta">
2075
-            <abbr class="exact-date" title="<?php echo $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;
2076
-            <?php if($note->comment_author !== 'System') {?>
2077
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2075
+            <abbr class="exact-date" title="<?php echo $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;
2076
+            <?php if ($note->comment_author !== 'System') {?>
2077
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2078 2078
             <?php } ?>
2079 2079
         </p>
2080 2080
     </li>
2081 2081
     <?php
2082 2082
     $note_content = ob_get_clean();
2083
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2083
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2084 2084
     
2085
-    if ( $echo ) {
2085
+    if ($echo) {
2086 2086
         echo $note_content;
2087 2087
     } else {
2088 2088
         return $note_content;
@@ -2092,33 +2092,33 @@  discard block
 block discarded – undo
2092 2092
 function wpinv_invalid_invoice_content() {
2093 2093
     global $post;
2094 2094
 
2095
-    $invoice = wpinv_get_invoice( $post->ID );
2095
+    $invoice = wpinv_get_invoice($post->ID);
2096 2096
 
2097
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' );
2098
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2099
-        if ( is_user_logged_in() ) {
2100
-            if ( wpinv_require_login_to_checkout() ) {
2101
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2102
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2097
+    $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing');
2098
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2099
+        if (is_user_logged_in()) {
2100
+            if (wpinv_require_login_to_checkout()) {
2101
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2102
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2103 2103
                 }
2104 2104
             }
2105 2105
         } else {
2106
-            if ( wpinv_require_login_to_checkout() ) {
2107
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2108
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2106
+            if (wpinv_require_login_to_checkout()) {
2107
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2108
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2109 2109
                 }
2110 2110
             }
2111 2111
         }
2112 2112
     } else {
2113
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2113
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2114 2114
     }
2115 2115
     ?>
2116 2116
     <div class="row wpinv-row-invalid">
2117 2117
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2118
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2118
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2119 2119
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2120 2120
         </div>
2121 2121
     </div>
2122 2122
     <?php
2123 2123
 }
2124
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2125 2124
\ No newline at end of file
2125
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2126 2126
\ No newline at end of file
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,19 +10,19 @@
 block discarded – undo
10 10
 */
11 11
 
12 12
 // MUST have WordPress.
13
-if ( !defined( 'WPINC' ) ) {
14
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
13
+if (!defined('WPINC')) {
14
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
15 15
 }
16 16
 
17
-if ( !defined( 'WPINV_VERSION' ) ) {
18
-    define( 'WPINV_VERSION', '1.0.2' );
17
+if (!defined('WPINV_VERSION')) {
18
+    define('WPINV_VERSION', '1.0.2');
19 19
 }
20 20
 
21
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+    define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
25
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
26 26
 
27 27
 function wpinv_run() {
28 28
     global $invoicing;
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -28,79 +28,79 @@  discard block
 block discarded – undo
28 28
         'wpinv_fully_refunded',
29 29
         'wpinv_partially_refunded',
30 30
         'wpinv_new_invoice_note'
31
-    ) );
31
+    ));
32 32
 
33
-    foreach ( $email_actions as $action ) {
34
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
33
+    foreach ($email_actions as $action) {
34
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
35 35
     }
36 36
 }
37
-add_action( 'init', 'wpinv_init_transactional_emails' );
37
+add_action('init', 'wpinv_init_transactional_emails');
38 38
 
39 39
 // New invoice email
40
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
41
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
40
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
41
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
42
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
46 46
 
47 47
 // Cancelled invoice email
48
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
49
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
48
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
49
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
50 50
 
51 51
 // Failed invoice email
52
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
53
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
52
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
53
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
54 54
 
55 55
 // On hold invoice email
56
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
57
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
56
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
57
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
58 58
 
59 59
 // Processing invoice email
60
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
60
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
61 61
 
62 62
 // Paid invoice email
63
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
63
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
64 64
 
65 65
 // Refunded invoice email
66
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
67
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
66
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
67
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
68 68
 
69 69
 // Invoice note
70
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
70
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
71 71
 
72
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
73
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
74
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
75
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
76
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
77
-add_action( 'wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4 );
72
+add_action('wpinv_email_header', 'wpinv_email_header');
73
+add_action('wpinv_email_footer', 'wpinv_email_footer');
74
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
75
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
76
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
77
+add_action('wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4);
78 78
 
79 79
 function wpinv_send_transactional_email() {
80 80
     $args       = func_get_args();
81 81
     $function   = current_filter() . '_notification';
82
-    do_action_ref_array( $function, $args );
82
+    do_action_ref_array($function, $args);
83 83
 }
84 84
     
85
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
85
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
86 86
     global $wpinv_email_search, $wpinv_email_replace;
87 87
     
88 88
     $email_type = 'new_invoice';
89
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
89
+    if (!wpinv_email_is_enabled($email_type)) {
90 90
         return false;
91 91
     }
92 92
     
93
-    $invoice = wpinv_get_invoice( $invoice_id );
94
-    if ( empty( $invoice ) ) {
93
+    $invoice = wpinv_get_invoice($invoice_id);
94
+    if (empty($invoice)) {
95 95
         return false;
96 96
     }
97 97
 
98
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
98
+    if (!("wpi_invoice" === $invoice->post_type)) {
99 99
         return false;
100 100
     }
101 101
     
102
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
103
-    if ( !is_email( $recipient ) ) {
102
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
103
+    if (!is_email($recipient)) {
104 104
         return false;
105 105
     }
106 106
         
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
     $wpinv_email_search     = $search;
118 118
     $wpinv_email_replace    = $replace;
119 119
     
120
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
121
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
122
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
123
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
120
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
121
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
122
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
123
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
124 124
     
125
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
125
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
126 126
             'invoice'       => $invoice,
127 127
             'email_type'    => $email_type,
128 128
             'email_heading' => $email_heading,
129 129
             'sent_to_admin' => true,
130 130
             'plain_text'    => false,
131
-        ) );
131
+        ));
132 132
     
133
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
133
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
134 134
 }
135 135
 
136
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
136
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
137 137
     global $wpinv_email_search, $wpinv_email_replace;
138 138
     
139 139
     $email_type = 'cancelled_invoice';
140
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
140
+    if (!wpinv_email_is_enabled($email_type)) {
141 141
         return false;
142 142
     }
143 143
     
144
-    $invoice = wpinv_get_invoice( $invoice_id );
145
-    if ( empty( $invoice ) ) {
144
+    $invoice = wpinv_get_invoice($invoice_id);
145
+    if (empty($invoice)) {
146 146
         return false;
147 147
     }
148 148
 
149
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
149
+    if (!("wpi_invoice" === $invoice->post_type)) {
150 150
         return false;
151 151
     }
152 152
     
153
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
154
-    if ( !is_email( $recipient ) ) {
153
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
154
+    if (!is_email($recipient)) {
155 155
         return false;
156 156
     }
157 157
         
@@ -168,41 +168,41 @@  discard block
 block discarded – undo
168 168
     $wpinv_email_search     = $search;
169 169
     $wpinv_email_replace    = $replace;
170 170
     
171
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
172
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
173
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
174
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
171
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
172
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
173
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
174
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
175 175
     
176
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
176
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
177 177
             'invoice'       => $invoice,
178 178
             'email_type'    => $email_type,
179 179
             'email_heading' => $email_heading,
180 180
             'sent_to_admin' => true,
181 181
             'plain_text'    => false,
182
-        ) );
182
+        ));
183 183
     
184
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
184
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
185 185
 }
186 186
 
187
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
187
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
188 188
     global $wpinv_email_search, $wpinv_email_replace;
189 189
     
190 190
     $email_type = 'failed_invoice';
191
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
191
+    if (!wpinv_email_is_enabled($email_type)) {
192 192
         return false;
193 193
     }
194 194
     
195
-    $invoice = wpinv_get_invoice( $invoice_id );
196
-    if ( empty( $invoice ) ) {
195
+    $invoice = wpinv_get_invoice($invoice_id);
196
+    if (empty($invoice)) {
197 197
         return false;
198 198
     }
199 199
 
200
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
200
+    if (!("wpi_invoice" === $invoice->post_type)) {
201 201
         return false;
202 202
     }
203 203
     
204
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
205
-    if ( !is_email( $recipient ) ) {
204
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
205
+    if (!is_email($recipient)) {
206 206
         return false;
207 207
     }
208 208
         
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
     $wpinv_email_search     = $search;
220 220
     $wpinv_email_replace    = $replace;
221 221
     
222
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
223
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
224
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
225
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
222
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
223
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
224
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
225
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
226 226
     
227
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
227
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
228 228
             'invoice'       => $invoice,
229 229
             'email_type'    => $email_type,
230 230
             'email_heading' => $email_heading,
231 231
             'sent_to_admin' => true,
232 232
             'plain_text'    => false,
233
-        ) );
233
+        ));
234 234
     
235
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
235
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
236 236
 }
237 237
 
238
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
238
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
239 239
     global $wpinv_email_search, $wpinv_email_replace;
240 240
     
241 241
     $email_type = 'onhold_invoice';
242
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
242
+    if (!wpinv_email_is_enabled($email_type)) {
243 243
         return false;
244 244
     }
245 245
     
246
-    $invoice = wpinv_get_invoice( $invoice_id );
247
-    if ( empty( $invoice ) ) {
246
+    $invoice = wpinv_get_invoice($invoice_id);
247
+    if (empty($invoice)) {
248 248
         return false;
249 249
     }
250 250
 
251
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
251
+    if (!("wpi_invoice" === $invoice->post_type)) {
252 252
         return false;
253 253
     }
254 254
     
255
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
256
-    if ( !is_email( $recipient ) ) {
255
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
256
+    if (!is_email($recipient)) {
257 257
         return false;
258 258
     }
259 259
         
@@ -270,49 +270,49 @@  discard block
 block discarded – undo
270 270
     $wpinv_email_search     = $search;
271 271
     $wpinv_email_replace    = $replace;
272 272
     
273
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
274
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
275
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
276
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
273
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
274
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
275
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
276
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
277 277
     
278
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
278
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
279 279
             'invoice'       => $invoice,
280 280
             'email_type'    => $email_type,
281 281
             'email_heading' => $email_heading,
282 282
             'sent_to_admin' => false,
283 283
             'plain_text'    => false,
284
-        ) );
284
+        ));
285 285
     
286
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
286
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
287 287
     
288
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
289
-        $recipient  = wpinv_get_admin_email();
290
-        $subject    .= ' - ADMIN BCC COPY';
291
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
288
+    if (wpinv_mail_admin_bcc_active($email_type)) {
289
+        $recipient = wpinv_get_admin_email();
290
+        $subject .= ' - ADMIN BCC COPY';
291
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
292 292
     }
293 293
     
294 294
     return $sent;
295 295
 }
296 296
 
297
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
297
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
298 298
     global $wpinv_email_search, $wpinv_email_replace;
299 299
     
300 300
     $email_type = 'processing_invoice';
301
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
301
+    if (!wpinv_email_is_enabled($email_type)) {
302 302
         return false;
303 303
     }
304 304
     
305
-    $invoice = wpinv_get_invoice( $invoice_id );
306
-    if ( empty( $invoice ) ) {
305
+    $invoice = wpinv_get_invoice($invoice_id);
306
+    if (empty($invoice)) {
307 307
         return false;
308 308
     }
309 309
 
310
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
310
+    if (!("wpi_invoice" === $invoice->post_type)) {
311 311
         return false;
312 312
     }
313 313
     
314
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
315
-    if ( !is_email( $recipient ) ) {
314
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
315
+    if (!is_email($recipient)) {
316 316
         return false;
317 317
     }
318 318
         
@@ -329,49 +329,49 @@  discard block
 block discarded – undo
329 329
     $wpinv_email_search     = $search;
330 330
     $wpinv_email_replace    = $replace;
331 331
     
332
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
333
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
334
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
335
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
332
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
333
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
334
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
335
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
336 336
     
337
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
337
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
338 338
             'invoice'       => $invoice,
339 339
             'email_type'    => $email_type,
340 340
             'email_heading' => $email_heading,
341 341
             'sent_to_admin' => false,
342 342
             'plain_text'    => false,
343
-        ) );
343
+        ));
344 344
     
345
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
345
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
346 346
     
347
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
348
-        $recipient  = wpinv_get_admin_email();
349
-        $subject    .= ' - ADMIN BCC COPY';
350
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
347
+    if (wpinv_mail_admin_bcc_active($email_type)) {
348
+        $recipient = wpinv_get_admin_email();
349
+        $subject .= ' - ADMIN BCC COPY';
350
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
351 351
     }
352 352
     
353 353
     return $sent;
354 354
 }
355 355
 
356
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
356
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
357 357
     global $wpinv_email_search, $wpinv_email_replace;
358 358
     
359 359
     $email_type = 'completed_invoice';
360
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
360
+    if (!wpinv_email_is_enabled($email_type)) {
361 361
         return false;
362 362
     }
363 363
     
364
-    $invoice = wpinv_get_invoice( $invoice_id );
365
-    if ( empty( $invoice ) ) {
364
+    $invoice = wpinv_get_invoice($invoice_id);
365
+    if (empty($invoice)) {
366 366
         return false;
367 367
     }
368 368
 
369
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
369
+    if (!("wpi_invoice" === $invoice->post_type)) {
370 370
         return false;
371 371
     }
372 372
     
373
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
374
-    if ( !is_email( $recipient ) ) {
373
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
374
+    if (!is_email($recipient)) {
375 375
         return false;
376 376
     }
377 377
         
@@ -388,49 +388,49 @@  discard block
 block discarded – undo
388 388
     $wpinv_email_search     = $search;
389 389
     $wpinv_email_replace    = $replace;
390 390
     
391
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
392
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
393
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
394
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
391
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
392
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
393
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
394
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
395 395
     
396
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
396
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
397 397
             'invoice'       => $invoice,
398 398
             'email_type'    => $email_type,
399 399
             'email_heading' => $email_heading,
400 400
             'sent_to_admin' => false,
401 401
             'plain_text'    => false,
402
-        ) );
402
+        ));
403 403
     
404
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
404
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
405 405
     
406
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
407
-        $recipient  = wpinv_get_admin_email();
408
-        $subject    .= ' - ADMIN BCC COPY';
409
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
406
+    if (wpinv_mail_admin_bcc_active($email_type)) {
407
+        $recipient = wpinv_get_admin_email();
408
+        $subject .= ' - ADMIN BCC COPY';
409
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
410 410
     }
411 411
     
412 412
     return $sent;
413 413
 }
414 414
 
415
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
415
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
416 416
     global $wpinv_email_search, $wpinv_email_replace;
417 417
     
418 418
     $email_type = 'refunded_invoice';
419
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
419
+    if (!wpinv_email_is_enabled($email_type)) {
420 420
         return false;
421 421
     }
422 422
     
423
-    $invoice = wpinv_get_invoice( $invoice_id );
424
-    if ( empty( $invoice ) ) {
423
+    $invoice = wpinv_get_invoice($invoice_id);
424
+    if (empty($invoice)) {
425 425
         return false;
426 426
     }
427 427
 
428
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
428
+    if (!("wpi_invoice" === $invoice->post_type)) {
429 429
         return false;
430 430
     }
431 431
     
432
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
433
-    if ( !is_email( $recipient ) ) {
432
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
433
+    if (!is_email($recipient)) {
434 434
         return false;
435 435
     }
436 436
         
@@ -447,50 +447,50 @@  discard block
 block discarded – undo
447 447
     $wpinv_email_search     = $search;
448 448
     $wpinv_email_replace    = $replace;
449 449
     
450
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
451
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
452
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
453
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
450
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
451
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
452
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
453
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
454 454
     
455
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
455
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
456 456
             'invoice'           => $invoice,
457 457
             'email_type'        => $email_type,
458 458
             'email_heading'     => $email_heading,
459 459
             'sent_to_admin'     => false,
460 460
             'plain_text'        => false,
461 461
             'partial_refund'    => false
462
-        ) );
462
+        ));
463 463
     
464
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
464
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
465 465
     
466
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
467
-        $recipient  = wpinv_get_admin_email();
468
-        $subject    .= ' - ADMIN BCC COPY';
469
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
466
+    if (wpinv_mail_admin_bcc_active($email_type)) {
467
+        $recipient = wpinv_get_admin_email();
468
+        $subject .= ' - ADMIN BCC COPY';
469
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
470 470
     }
471 471
     
472 472
     return $sent;
473 473
 }
474 474
 
475
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
475
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
476 476
     global $wpinv_email_search, $wpinv_email_replace;
477 477
     
478 478
     $email_type = 'refunded_invoice';
479
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
479
+    if (!wpinv_email_is_enabled($email_type)) {
480 480
         return false;
481 481
     }
482 482
     
483
-    $invoice = wpinv_get_invoice( $invoice_id );
484
-    if ( empty( $invoice ) ) {
483
+    $invoice = wpinv_get_invoice($invoice_id);
484
+    if (empty($invoice)) {
485 485
         return false;
486 486
     }
487 487
 
488
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
488
+    if (!("wpi_invoice" === $invoice->post_type)) {
489 489
         return false;
490 490
     }
491 491
     
492
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
493
-    if ( !is_email( $recipient ) ) {
492
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
493
+    if (!is_email($recipient)) {
494 494
         return false;
495 495
     }
496 496
         
@@ -507,53 +507,53 @@  discard block
 block discarded – undo
507 507
     $wpinv_email_search     = $search;
508 508
     $wpinv_email_replace    = $replace;
509 509
     
510
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
511
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
512
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
513
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
510
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
511
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
512
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
513
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
514 514
     
515
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
515
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
516 516
             'invoice'           => $invoice,
517 517
             'email_type'        => $email_type,
518 518
             'email_heading'     => $email_heading,
519 519
             'sent_to_admin'     => false,
520 520
             'plain_text'        => false,
521 521
             'partial_refund'    => true
522
-        ) );
522
+        ));
523 523
     
524
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
524
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
525 525
     
526
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
527
-        $recipient  = wpinv_get_admin_email();
528
-        $subject    .= ' - ADMIN BCC COPY';
529
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
526
+    if (wpinv_mail_admin_bcc_active($email_type)) {
527
+        $recipient = wpinv_get_admin_email();
528
+        $subject .= ' - ADMIN BCC COPY';
529
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
530 530
     }
531 531
     
532 532
     return $sent;
533 533
 }
534 534
 
535
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
535
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
536 536
 }
537 537
 
538
-function wpinv_user_invoice_notification( $invoice_id ) {
538
+function wpinv_user_invoice_notification($invoice_id) {
539 539
     global $wpinv_email_search, $wpinv_email_replace;
540 540
     
541 541
     $email_type = 'user_invoice';
542
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
542
+    if (!wpinv_email_is_enabled($email_type)) {
543 543
         return false;
544 544
     }
545 545
     
546
-    $invoice = wpinv_get_invoice( $invoice_id );
547
-    if ( empty( $invoice ) ) {
546
+    $invoice = wpinv_get_invoice($invoice_id);
547
+    if (empty($invoice)) {
548 548
         return false;
549 549
     }
550 550
 
551
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
551
+    if (!("wpi_invoice" === $invoice->post_type)) {
552 552
         return false;
553 553
     }
554 554
     
555
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
556
-    if ( !is_email( $recipient ) ) {
555
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
556
+    if (!is_email($recipient)) {
557 557
         return false;
558 558
     }
559 559
         
@@ -570,53 +570,53 @@  discard block
 block discarded – undo
570 570
     $wpinv_email_search     = $search;
571 571
     $wpinv_email_replace    = $replace;
572 572
     
573
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
574
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
575
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
576
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
573
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
574
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
575
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
576
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
577 577
     
578
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
578
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
579 579
             'invoice'       => $invoice,
580 580
             'email_type'    => $email_type,
581 581
             'email_heading' => $email_heading,
582 582
             'sent_to_admin' => false,
583 583
             'plain_text'    => false,
584
-        ) );
584
+        ));
585 585
     
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
     
588
-    if ( $sent ) {
589
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
588
+    if ($sent) {
589
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
590 590
     } else {
591
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
591
+        $note = __('Fail to send invoice to the user!', 'invoicing');
592 592
     }
593 593
     
594
-    $invoice->add_note( $note, '', '', true ); // Add system note.
594
+    $invoice->add_note($note, '', '', true); // Add system note.
595 595
 
596
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
597
-        $recipient  = wpinv_get_admin_email();
598
-        $subject    .= ' - ADMIN BCC COPY';
599
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
596
+    if (wpinv_mail_admin_bcc_active($email_type)) {
597
+        $recipient = wpinv_get_admin_email();
598
+        $subject .= ' - ADMIN BCC COPY';
599
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
600 600
     }
601 601
     
602 602
     return $sent;
603 603
 }
604 604
 
605
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
605
+function wpinv_user_note_notification($invoice_id, $args = array()) {
606 606
     global $wpinv_email_search, $wpinv_email_replace;
607 607
     
608 608
     $email_type = 'user_note';
609
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
609
+    if (!wpinv_email_is_enabled($email_type)) {
610 610
         return false;
611 611
     }
612 612
     
613
-    $invoice = wpinv_get_invoice( $invoice_id );
614
-    if ( empty( $invoice ) ) {
613
+    $invoice = wpinv_get_invoice($invoice_id);
614
+    if (empty($invoice)) {
615 615
         return false;
616 616
     }
617 617
     
618
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
619
-    if ( !is_email( $recipient ) ) {
618
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
619
+    if (!is_email($recipient)) {
620 620
         return false;
621 621
     }
622 622
     
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
         'user_note' => ''
625 625
     );
626 626
 
627
-    $args = wp_parse_args( $args, $defaults );
627
+    $args = wp_parse_args($args, $defaults);
628 628
         
629 629
     $search                     = array();
630 630
     $search['invoice_number']   = '{invoice_number}';
@@ -643,46 +643,46 @@  discard block
 block discarded – undo
643 643
     $wpinv_email_search     = $search;
644 644
     $wpinv_email_replace    = $replace;
645 645
     
646
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
647
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
648
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
649
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
646
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
647
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
648
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
649
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
650 650
     
651
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
651
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
652 652
             'invoice'       => $invoice,
653 653
             'email_type'    => $email_type,
654 654
             'email_heading' => $email_heading,
655 655
             'sent_to_admin' => false,
656 656
             'plain_text'    => false,
657 657
             'customer_note' => $args['user_note']
658
-        ) );
658
+        ));
659 659
         
660
-    $content        = wpinv_email_format_text( $content );
660
+    $content = wpinv_email_format_text($content);
661 661
     
662
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
662
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
663 663
         
664 664
     return $sent;
665 665
 }
666 666
 
667 667
 function wpinv_mail_get_from_address() {
668
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
669
-    return sanitize_email( $from_address );
668
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
669
+    return sanitize_email($from_address);
670 670
 }
671 671
 
672 672
 function wpinv_mail_get_from_name() {
673
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
674
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
673
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
674
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
675 675
 }
676 676
 
677
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
678
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
679
-    return ( $active ? true : false );
677
+function wpinv_mail_admin_bcc_active($mail_type = '') {
678
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
679
+    return ($active ? true : false);
680 680
 }
681 681
     
682
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
683
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
682
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
683
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
684 684
     
685
-    switch ( $email_type ) {
685
+    switch ($email_type) {
686 686
         case 'html' :
687 687
             $content_type = 'text/html';
688 688
             break;
@@ -697,35 +697,35 @@  discard block
 block discarded – undo
697 697
     return $content_type;
698 698
 }
699 699
     
700
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
701
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
702
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
703
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
700
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
701
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
702
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
703
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
704 704
 
705
-    $message = wpinv_email_style_body( $message );
706
-    $message = apply_filters( 'wpinv_mail_content', $message );
705
+    $message = wpinv_email_style_body($message);
706
+    $message = apply_filters('wpinv_mail_content', $message);
707 707
     
708
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
708
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
709 709
     
710
-    if ( !$sent ) {
711
-        $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 );
712
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
710
+    if (!$sent) {
711
+        $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);
712
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
713 713
     }
714 714
 
715
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
716
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
717
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
715
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
716
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
717
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
718 718
 
719 719
     return $sent;
720 720
 }
721 721
     
722 722
 function wpinv_get_emails() {
723 723
     $overdue_days_options       = array();
724
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
725
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
724
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
725
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
726 726
     
727
-    for ( $i = 2; $i <= 10; $i++ ) {
728
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
727
+    for ($i = 2; $i <= 10; $i++) {
728
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
729 729
     }
730 730
 
731 731
     // Default, built-in gateways
@@ -733,130 +733,130 @@  discard block
 block discarded – undo
733 733
             'new_invoice' => array(
734 734
             'email_new_invoice_header' => array(
735 735
                 'id'   => 'email_new_invoice_header',
736
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
737
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
736
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
737
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
738 738
                 'type' => 'header',
739 739
             ),
740 740
             'email_new_invoice_active' => array(
741 741
                 'id'   => 'email_new_invoice_active',
742
-                'name' => __( 'Enable/Disable', 'invoicing' ),
743
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
742
+                'name' => __('Enable/Disable', 'invoicing'),
743
+                'desc' => __('Enable this email notification', 'invoicing'),
744 744
                 'type' => 'checkbox',
745 745
                 'std'  => 1
746 746
             ),
747 747
             'email_new_invoice_subject' => array(
748 748
                 'id'   => 'email_new_invoice_subject',
749
-                'name' => __( 'Subject', 'invoicing' ),
750
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
749
+                'name' => __('Subject', 'invoicing'),
750
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
751 751
                 'type' => 'text',
752
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
752
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
753 753
                 'size' => 'large'
754 754
             ),
755 755
             'email_new_invoice_heading' => array(
756 756
                 'id'   => 'email_new_invoice_heading',
757
-                'name' => __( 'Email Heading', 'invoicing' ),
758
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
757
+                'name' => __('Email Heading', 'invoicing'),
758
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
759 759
                 'type' => 'text',
760
-                'std'  => __( 'New payment invoice', 'invoicing' ),
760
+                'std'  => __('New payment invoice', 'invoicing'),
761 761
                 'size' => 'large'
762 762
             ),
763 763
         ),
764 764
         'cancelled_invoice' => array(
765 765
             'email_cancelled_invoice_header' => array(
766 766
                 'id'   => 'email_cancelled_invoice_header',
767
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
768
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
767
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
768
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
769 769
                 'type' => 'header',
770 770
             ),
771 771
             'email_cancelled_invoice_active' => array(
772 772
                 'id'   => 'email_cancelled_invoice_active',
773
-                'name' => __( 'Enable/Disable', 'invoicing' ),
774
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
773
+                'name' => __('Enable/Disable', 'invoicing'),
774
+                'desc' => __('Enable this email notification', 'invoicing'),
775 775
                 'type' => 'checkbox',
776 776
                 'std'  => 1
777 777
             ),
778 778
             'email_cancelled_invoice_subject' => array(
779 779
                 'id'   => 'email_cancelled_invoice_subject',
780
-                'name' => __( 'Subject', 'invoicing' ),
781
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
780
+                'name' => __('Subject', 'invoicing'),
781
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
782 782
                 'type' => 'text',
783
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
783
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
784 784
                 'size' => 'large'
785 785
             ),
786 786
             'email_cancelled_invoice_heading' => array(
787 787
                 'id'   => 'email_cancelled_invoice_heading',
788
-                'name' => __( 'Email Heading', 'invoicing' ),
789
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
788
+                'name' => __('Email Heading', 'invoicing'),
789
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
790 790
                 'type' => 'text',
791
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
791
+                'std'  => __('Cancelled invoice', 'invoicing'),
792 792
                 'size' => 'large'
793 793
             ),
794 794
         ),
795 795
         'failed_invoice' => array(
796 796
             'email_failed_invoice_header' => array(
797 797
                 'id'   => 'email_failed_invoice_header',
798
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
799
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
798
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
799
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
800 800
                 'type' => 'header',
801 801
             ),
802 802
             'email_failed_invoice_active' => array(
803 803
                 'id'   => 'email_failed_invoice_active',
804
-                'name' => __( 'Enable/Disable', 'invoicing' ),
805
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
804
+                'name' => __('Enable/Disable', 'invoicing'),
805
+                'desc' => __('Enable this email notification', 'invoicing'),
806 806
                 'type' => 'checkbox',
807 807
                 'std'  => 1
808 808
             ),
809 809
             'email_failed_invoice_subject' => array(
810 810
                 'id'   => 'email_failed_invoice_subject',
811
-                'name' => __( 'Subject', 'invoicing' ),
812
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
811
+                'name' => __('Subject', 'invoicing'),
812
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
813 813
                 'type' => 'text',
814
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
814
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
815 815
                 'size' => 'large'
816 816
             ),
817 817
             'email_failed_invoice_heading' => array(
818 818
                 'id'   => 'email_failed_invoice_heading',
819
-                'name' => __( 'Email Heading', 'invoicing' ),
820
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
819
+                'name' => __('Email Heading', 'invoicing'),
820
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
821 821
                 'type' => 'text',
822
-                'std'  => __( 'Failed invoice', 'invoicing' ),
822
+                'std'  => __('Failed invoice', 'invoicing'),
823 823
                 'size' => 'large'
824 824
             )
825 825
         ),
826 826
         'onhold_invoice' => array(
827 827
             'email_onhold_invoice_header' => array(
828 828
                 'id'   => 'email_onhold_invoice_header',
829
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
829
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_onhold_invoice_active' => array(
834 834
                 'id'   => 'email_onhold_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_onhold_invoice_subject' => array(
841 841
                 'id'   => 'email_onhold_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_onhold_invoice_heading' => array(
849 849
                 'id'   => 'email_onhold_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_onhold_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_onhold_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
@@ -864,37 +864,37 @@  discard block
 block discarded – undo
864 864
         'processing_invoice' => array(
865 865
             'email_processing_invoice_header' => array(
866 866
                 'id'   => 'email_processing_invoice_header',
867
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
868
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
867
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
868
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
869 869
                 'type' => 'header',
870 870
             ),
871 871
             'email_processing_invoice_active' => array(
872 872
                 'id'   => 'email_processing_invoice_active',
873
-                'name' => __( 'Enable/Disable', 'invoicing' ),
874
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
873
+                'name' => __('Enable/Disable', 'invoicing'),
874
+                'desc' => __('Enable this email notification', 'invoicing'),
875 875
                 'type' => 'checkbox',
876 876
                 'std'  => 1
877 877
             ),
878 878
             'email_processing_invoice_subject' => array(
879 879
                 'id'   => 'email_processing_invoice_subject',
880
-                'name' => __( 'Subject', 'invoicing' ),
881
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
880
+                'name' => __('Subject', 'invoicing'),
881
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
882 882
                 'type' => 'text',
883
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
883
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
884 884
                 'size' => 'large'
885 885
             ),
886 886
             'email_processing_invoice_heading' => array(
887 887
                 'id'   => 'email_processing_invoice_heading',
888
-                'name' => __( 'Email Heading', 'invoicing' ),
889
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
888
+                'name' => __('Email Heading', 'invoicing'),
889
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
890 890
                 'type' => 'text',
891
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
891
+                'std'  => __('Thank you for your invoice', 'invoicing'),
892 892
                 'size' => 'large'
893 893
             ),
894 894
             'email_processing_invoice_admin_bcc' => array(
895 895
                 'id'   => 'email_processing_invoice_admin_bcc',
896
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
897
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
896
+                'name' => __('Enable Admin BCC', 'invoicing'),
897
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
898 898
                 'type' => 'checkbox',
899 899
                 'std'  => 1
900 900
             ),
@@ -902,37 +902,37 @@  discard block
 block discarded – undo
902 902
         'completed_invoice' => array(
903 903
             'email_completed_invoice_header' => array(
904 904
                 'id'   => 'email_completed_invoice_header',
905
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
906
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
905
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
906
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
907 907
                 'type' => 'header',
908 908
             ),
909 909
             'email_completed_invoice_active' => array(
910 910
                 'id'   => 'email_completed_invoice_active',
911
-                'name' => __( 'Enable/Disable', 'invoicing' ),
912
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
911
+                'name' => __('Enable/Disable', 'invoicing'),
912
+                'desc' => __('Enable this email notification', 'invoicing'),
913 913
                 'type' => 'checkbox',
914 914
                 'std'  => 1
915 915
             ),
916 916
             'email_completed_invoice_subject' => array(
917 917
                 'id'   => 'email_completed_invoice_subject',
918
-                'name' => __( 'Subject', 'invoicing' ),
919
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
918
+                'name' => __('Subject', 'invoicing'),
919
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
920 920
                 'type' => 'text',
921
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
921
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
922 922
                 'size' => 'large'
923 923
             ),
924 924
             'email_completed_invoice_heading' => array(
925 925
                 'id'   => 'email_completed_invoice_heading',
926
-                'name' => __( 'Email Heading', 'invoicing' ),
927
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
926
+                'name' => __('Email Heading', 'invoicing'),
927
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
928 928
                 'type' => 'text',
929
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
929
+                'std'  => __('Your invoice has been paid', 'invoicing'),
930 930
                 'size' => 'large'
931 931
             ),
932 932
             'email_completed_invoice_admin_bcc' => array(
933 933
                 'id'   => 'email_completed_invoice_admin_bcc',
934
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
935
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
934
+                'name' => __('Enable Admin BCC', 'invoicing'),
935
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
936 936
                 'type' => 'checkbox',
937 937
             ),
938 938
             'std'  => 1
@@ -940,37 +940,37 @@  discard block
 block discarded – undo
940 940
         'refunded_invoice' => array(
941 941
             'email_refunded_invoice_header' => array(
942 942
                 'id'   => 'email_refunded_invoice_header',
943
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
944
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
943
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
944
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
945 945
                 'type' => 'header',
946 946
             ),
947 947
             'email_refunded_invoice_active' => array(
948 948
                 'id'   => 'email_refunded_invoice_active',
949
-                'name' => __( 'Enable/Disable', 'invoicing' ),
950
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
949
+                'name' => __('Enable/Disable', 'invoicing'),
950
+                'desc' => __('Enable this email notification', 'invoicing'),
951 951
                 'type' => 'checkbox',
952 952
                 'std'  => 1
953 953
             ),
954 954
             'email_refunded_invoice_subject' => array(
955 955
                 'id'   => 'email_refunded_invoice_subject',
956
-                'name' => __( 'Subject', 'invoicing' ),
957
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
956
+                'name' => __('Subject', 'invoicing'),
957
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
958 958
                 'type' => 'text',
959
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
959
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
960 960
                 'size' => 'large'
961 961
             ),
962 962
             'email_refunded_invoice_heading' => array(
963 963
                 'id'   => 'email_refunded_invoice_heading',
964
-                'name' => __( 'Email Heading', 'invoicing' ),
965
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
964
+                'name' => __('Email Heading', 'invoicing'),
965
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
966 966
                 'type' => 'text',
967
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
967
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
968 968
                 'size' => 'large'
969 969
             ),
970 970
             'email_refunded_invoice_admin_bcc' => array(
971 971
                 'id'   => 'email_refunded_invoice_admin_bcc',
972
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
973
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
972
+                'name' => __('Enable Admin BCC', 'invoicing'),
973
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
974 974
                 'type' => 'checkbox',
975 975
                 'std'  => 1
976 976
             ),
@@ -978,37 +978,37 @@  discard block
 block discarded – undo
978 978
         'user_invoice' => array(
979 979
             'email_user_invoice_header' => array(
980 980
                 'id'   => 'email_user_invoice_header',
981
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
982
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
981
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
982
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
983 983
                 'type' => 'header',
984 984
             ),
985 985
             'email_user_invoice_active' => array(
986 986
                 'id'   => 'email_user_invoice_active',
987
-                'name' => __( 'Enable/Disable', 'invoicing' ),
988
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
987
+                'name' => __('Enable/Disable', 'invoicing'),
988
+                'desc' => __('Enable this email notification', 'invoicing'),
989 989
                 'type' => 'checkbox',
990 990
                 'std'  => 1
991 991
             ),
992 992
             'email_user_invoice_subject' => array(
993 993
                 'id'   => 'email_user_invoice_subject',
994
-                'name' => __( 'Subject', 'invoicing' ),
995
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
994
+                'name' => __('Subject', 'invoicing'),
995
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
996 996
                 'type' => 'text',
997
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
997
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
998 998
                 'size' => 'large'
999 999
             ),
1000 1000
             'email_user_invoice_heading' => array(
1001 1001
                 'id'   => 'email_user_invoice_heading',
1002
-                'name' => __( 'Email Heading', 'invoicing' ),
1003
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
1002
+                'name' => __('Email Heading', 'invoicing'),
1003
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1004 1004
                 'type' => 'text',
1005
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1005
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1006 1006
                 'size' => 'large'
1007 1007
             ),
1008 1008
             'email_user_invoice_admin_bcc' => array(
1009 1009
                 'id'   => 'email_user_invoice_admin_bcc',
1010
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1011
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1010
+                'name' => __('Enable Admin BCC', 'invoicing'),
1011
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1012 1012
                 'type' => 'checkbox',
1013 1013
                 'std'  => 1
1014 1014
             ),
@@ -1016,177 +1016,177 @@  discard block
 block discarded – undo
1016 1016
         'user_note' => array(
1017 1017
             'email_user_note_header' => array(
1018 1018
                 'id'   => 'email_user_note_header',
1019
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1020
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1019
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1020
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1021 1021
                 'type' => 'header',
1022 1022
             ),
1023 1023
             'email_user_note_active' => array(
1024 1024
                 'id'   => 'email_user_note_active',
1025
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1026
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1025
+                'name' => __('Enable/Disable', 'invoicing'),
1026
+                'desc' => __('Enable this email notification', 'invoicing'),
1027 1027
                 'type' => 'checkbox',
1028 1028
                 'std'  => 1
1029 1029
             ),
1030 1030
             'email_user_note_subject' => array(
1031 1031
                 'id'   => 'email_user_note_subject',
1032
-                'name' => __( 'Subject', 'invoicing' ),
1033
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1032
+                'name' => __('Subject', 'invoicing'),
1033
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1034 1034
                 'type' => 'text',
1035
-                'std'  => __( '[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing' ),
1035
+                'std'  => __('[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing'),
1036 1036
                 'size' => 'large'
1037 1037
             ),
1038 1038
             'email_user_note_heading' => array(
1039 1039
                 'id'   => 'email_user_note_heading',
1040
-                'name' => __( 'Email Heading', 'invoicing' ),
1041
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1040
+                'name' => __('Email Heading', 'invoicing'),
1041
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1042 1042
                 'type' => 'text',
1043
-                'std'  => __( 'A note has been added to your {invoice_quote}', 'invoicing' ),
1043
+                'std'  => __('A note has been added to your {invoice_quote}', 'invoicing'),
1044 1044
                 'size' => 'large'
1045 1045
             ),
1046 1046
         ),
1047 1047
         'overdue' => array(
1048 1048
             'email_overdue_header' => array(
1049 1049
                 'id'   => 'email_overdue_header',
1050
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1051
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1050
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1051
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1052 1052
                 'type' => 'header',
1053 1053
             ),
1054 1054
             'email_overdue_active' => array(
1055 1055
                 'id'   => 'email_overdue_active',
1056
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1057
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1056
+                'name' => __('Enable/Disable', 'invoicing'),
1057
+                'desc' => __('Enable this email notification', 'invoicing'),
1058 1058
                 'type' => 'checkbox',
1059 1059
                 'std'  => 1
1060 1060
             ),
1061 1061
             'email_due_reminder_days' => array(
1062 1062
                 'id'        => 'email_due_reminder_days',
1063
-                'name'      => __( 'When to Send', 'invoicing' ),
1064
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1063
+                'name'      => __('When to Send', 'invoicing'),
1064
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1065 1065
                 'default'   => '',
1066 1066
                 'type'      => 'multicheck',
1067 1067
                 'options'   => $overdue_days_options,
1068 1068
             ),
1069 1069
             'email_overdue_subject' => array(
1070 1070
                 'id'   => 'email_overdue_subject',
1071
-                'name' => __( 'Subject', 'invoicing' ),
1072
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1071
+                'name' => __('Subject', 'invoicing'),
1072
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1073 1073
                 'type' => 'text',
1074
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1074
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1075 1075
                 'size' => 'large'
1076 1076
             ),
1077 1077
             'email_overdue_heading' => array(
1078 1078
                 'id'   => 'email_overdue_heading',
1079
-                'name' => __( 'Email Heading', 'invoicing' ),
1080
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1079
+                'name' => __('Email Heading', 'invoicing'),
1080
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1081 1081
                 'type' => 'text',
1082
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1082
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1083 1083
                 'size' => 'large'
1084 1084
             ),
1085 1085
             'email_overdue_body' => array(
1086 1086
                 'id'   => 'email_overdue_body',
1087
-                'name' => __( 'Email Content', 'invoicing' ),
1088
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1087
+                'name' => __('Email Content', 'invoicing'),
1088
+                'desc' => __('The content of the email.', 'invoicing'),
1089 1089
                 'type' => 'rich_editor',
1090
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1090
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1091 1091
                 'class' => 'large',
1092 1092
                 'size'  => 10,
1093 1093
             ),
1094 1094
         ),
1095 1095
     );
1096 1096
 
1097
-    return apply_filters( 'wpinv_get_emails', $emails );
1097
+    return apply_filters('wpinv_get_emails', $emails);
1098 1098
 }
1099 1099
 
1100
-function wpinv_settings_emails( $settings = array() ) {
1100
+function wpinv_settings_emails($settings = array()) {
1101 1101
     $emails = wpinv_get_emails();
1102 1102
     
1103
-    if ( !empty( $emails ) ) {
1104
-        foreach ( $emails as $key => $email ) {
1103
+    if (!empty($emails)) {
1104
+        foreach ($emails as $key => $email) {
1105 1105
             $settings[$key] = $email;
1106 1106
         }
1107 1107
     }
1108 1108
     
1109
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1109
+    return apply_filters('wpinv_settings_get_emails', $settings);
1110 1110
 }
1111
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1111
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1112 1112
 
1113
-function wpinv_settings_sections_emails( $settings ) {
1113
+function wpinv_settings_sections_emails($settings) {
1114 1114
     $emails = wpinv_get_emails();
1115 1115
     
1116 1116
     if (!empty($emails)) {
1117
-        foreach  ($emails as $key => $email) {
1118
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1117
+        foreach ($emails as $key => $email) {
1118
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1119 1119
         }
1120 1120
     }
1121 1121
     
1122 1122
     return $settings;    
1123 1123
 }
1124
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1124
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1125 1125
 
1126
-function wpinv_email_is_enabled( $email_type ) {
1126
+function wpinv_email_is_enabled($email_type) {
1127 1127
     $emails = wpinv_get_emails();
1128
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1128
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1129 1129
 
1130
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1130
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1131 1131
 }
1132 1132
 
1133
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1134
-    switch ( $email_type ) {
1133
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1134
+    switch ($email_type) {
1135 1135
         case 'new_invoice':
1136 1136
         case 'cancelled_invoice':
1137 1137
         case 'failed_invoice':
1138 1138
             $recipient  = wpinv_get_admin_email();
1139 1139
         break;
1140 1140
         default:
1141
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1142
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1141
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1142
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1143 1143
         break;
1144 1144
     }
1145 1145
     
1146
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1146
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1147 1147
 }
1148 1148
 
1149
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1150
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1149
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1150
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1151 1151
     
1152
-    $subject    = wpinv_email_format_text( $subject );
1152
+    $subject    = wpinv_email_format_text($subject);
1153 1153
     
1154
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1154
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1155 1155
 }
1156 1156
 
1157
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1158
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1157
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1158
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1159 1159
     
1160
-    $email_heading = wpinv_email_format_text( $email_heading );
1160
+    $email_heading = wpinv_email_format_text($email_heading);
1161 1161
     
1162
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1162
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1163 1163
 }
1164 1164
 
1165
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1166
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1165
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1166
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1167 1167
     
1168
-    $content    = wpinv_email_format_text( $content );
1168
+    $content    = wpinv_email_format_text($content);
1169 1169
     
1170
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1170
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1171 1171
 }
1172 1172
 
1173
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1174 1174
     $from_name = wpinv_mail_get_from_address();
1175 1175
     $from_email = wpinv_mail_get_from_address();
1176 1176
     
1177
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1177
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1178 1178
     
1179
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1180
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1179
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1180
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1181 1181
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1182 1182
     
1183
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1183
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1184 1184
 }
1185 1185
 
1186
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1186
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1187 1187
     $attachments = array();
1188 1188
     
1189
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1189
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1190 1190
 }
1191 1191
 
1192 1192
 function wpinv_email_global_vars() {
@@ -1203,73 +1203,73 @@  discard block
 block discarded – undo
1203 1203
     $replace['sitename']    = $blogname;
1204 1204
     $replace['site-title']  = $blogname;
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) );
1206
+    return apply_filters('wpinv_email_global_vars', array($search, $replace));
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content ) {
1209
+function wpinv_email_format_text($content) {
1210 1210
     global $wpinv_email_search, $wpinv_email_replace;
1211 1211
     
1212
-    if ( empty( $wpinv_email_search ) ) {
1212
+    if (empty($wpinv_email_search)) {
1213 1213
         $wpinv_email_search = array();
1214 1214
     }
1215 1215
     
1216
-    if ( empty( $wpinv_email_replace ) ) {
1216
+    if (empty($wpinv_email_replace)) {
1217 1217
         $wpinv_email_replace = array();
1218 1218
     }
1219 1219
     
1220
-    $wpinv_email_search     = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search );
1221
-    $wpinv_email_replace    = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace );
1220
+    $wpinv_email_search     = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search);
1221
+    $wpinv_email_replace    = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace);
1222 1222
     
1223 1223
     $global_vars    = wpinv_email_global_vars();
1224 1224
     
1225
-    $search         = array_merge( $global_vars[0], $wpinv_email_search );
1226
-    $replace        = array_merge( $global_vars[1], $wpinv_email_replace );
1225
+    $search         = array_merge($global_vars[0], $wpinv_email_search);
1226
+    $replace        = array_merge($global_vars[1], $wpinv_email_replace);
1227 1227
     
1228
-    if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) {
1228
+    if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) {
1229 1229
         return  $content;
1230 1230
     }
1231 1231
         
1232
-    return str_replace( $search, $replace, $content );
1232
+    return str_replace($search, $replace, $content);
1233 1233
 }
1234 1234
 
1235
-function wpinv_email_style_body( $content ) {
1235
+function wpinv_email_style_body($content) {
1236 1236
     // make sure we only inline CSS for html emails
1237
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1237
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1238 1238
         ob_start();
1239
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1240
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1239
+        wpinv_get_template('emails/wpinv-email-styles.php');
1240
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1241 1241
         
1242 1242
         // apply CSS styles inline for picky email clients
1243 1243
         try {
1244
-            $emogrifier = new Emogrifier( $content, $css );
1244
+            $emogrifier = new Emogrifier($content, $css);
1245 1245
             $content    = $emogrifier->emogrify();
1246
-        } catch ( Exception $e ) {
1247
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1246
+        } catch (Exception $e) {
1247
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1248 1248
         }
1249 1249
     }
1250 1250
     return $content;
1251 1251
 }
1252 1252
 
1253
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1254
-    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 ) );
1253
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1254
+    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));
1255 1255
 }
1256 1256
 
1257 1257
 /**
1258 1258
  * Get the email footer.
1259 1259
  */
1260
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1261
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1260
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1261
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_wrap_message( $message ) {
1264
+function wpinv_email_wrap_message($message) {
1265 1265
     // Buffer
1266 1266
     ob_start();
1267 1267
 
1268
-    do_action( 'wpinv_email_header' );
1268
+    do_action('wpinv_email_header');
1269 1269
 
1270
-    echo wpautop( wptexturize( $message ) );
1270
+    echo wpautop(wptexturize($message));
1271 1271
 
1272
-    do_action( 'wpinv_email_footer' );
1272
+    do_action('wpinv_email_footer');
1273 1273
 
1274 1274
     // Get contents
1275 1275
     $message = ob_get_clean();
@@ -1277,86 +1277,86 @@  discard block
 block discarded – undo
1277 1277
     return $message;
1278 1278
 }
1279 1279
 
1280
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1281
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1280
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1281
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1282 1282
 }
1283 1283
 
1284
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1285
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1284
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1285
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1286 1286
 }
1287 1287
 
1288
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1289
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1288
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1289
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1290 1290
 }
1291 1291
 
1292
-function wpinv_send_customer_invoice( $data = array() ) {
1293
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1292
+function wpinv_send_customer_invoice($data = array()) {
1293
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1294 1294
     
1295
-    if ( empty( $invoice_id ) ) {
1295
+    if (empty($invoice_id)) {
1296 1296
         return;
1297 1297
     }
1298 1298
 
1299
-    if ( !current_user_can( 'manage_options' ) ) {
1300
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1299
+    if (!current_user_can('manage_options')) {
1300
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1301 1301
     }
1302 1302
     
1303
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1303
+    $sent = wpinv_user_invoice_notification($invoice_id);
1304 1304
     
1305 1305
     $status = $sent ? 'email_sent' : 'email_fail';
1306 1306
     
1307
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1308
-    wp_redirect( $redirect );
1307
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1308
+    wp_redirect($redirect);
1309 1309
     exit;
1310 1310
 }
1311
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1311
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1312 1312
 
1313
-function wpinv_send_overdue_reminder( $data = array() ) {
1314
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1313
+function wpinv_send_overdue_reminder($data = array()) {
1314
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1315 1315
     
1316
-    if ( empty( $invoice_id ) ) {
1316
+    if (empty($invoice_id)) {
1317 1317
         return;
1318 1318
     }
1319 1319
 
1320
-    if ( !current_user_can( 'manage_options' ) ) {
1321
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1320
+    if (!current_user_can('manage_options')) {
1321
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1322 1322
     }
1323 1323
     
1324
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1324
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1325 1325
     
1326 1326
     $status = $sent ? 'email_sent' : 'email_fail';
1327 1327
     
1328
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1329
-    wp_redirect( $redirect );
1328
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1329
+    wp_redirect($redirect);
1330 1330
     exit;
1331 1331
 }
1332
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1332
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1333 1333
 
1334
-function wpinv_send_customer_note_email( $data ) {
1335
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1334
+function wpinv_send_customer_note_email($data) {
1335
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1336 1336
     
1337
-    if ( empty( $invoice_id ) ) {
1337
+    if (empty($invoice_id)) {
1338 1338
         return;
1339 1339
     }
1340 1340
     
1341
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1341
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1342 1342
 }
1343
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1343
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1344 1344
 
1345
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1346
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1347
-        $date_format = get_option( 'date_format' );
1348
-        $time_format = get_option( 'time_format' );
1345
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1346
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1347
+        $date_format = get_option('date_format');
1348
+        $time_format = get_option('time_format');
1349 1349
         ?>
1350 1350
         <div id="wpinv-email-notes">
1351
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1351
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1352 1352
             <ol class="wpinv-notes-lists">
1353 1353
         <?php
1354
-        foreach ( $invoice_notes as $note ) {
1355
-            $note_time = strtotime( $note->comment_date );
1354
+        foreach ($invoice_notes as $note) {
1355
+            $note_time = strtotime($note->comment_date);
1356 1356
             ?>
1357 1357
             <li class="comment wpinv-note">
1358
-            <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>
1359
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1358
+            <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>
1359
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1360 1360
             </li>
1361 1361
             <?php
1362 1362
         }
@@ -1365,21 +1365,21 @@  discard block
 block discarded – undo
1365 1365
         <?php
1366 1366
     }
1367 1367
 }
1368
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1368
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1369 1369
 
1370 1370
 function wpinv_email_payment_reminders() {    
1371 1371
     global $wpi_auto_reminder;
1372
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1372
+    if (!wpinv_get_option('email_overdue_active')) {
1373 1373
         return;
1374 1374
     }
1375 1375
     
1376
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1377
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1376
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1377
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1378 1378
         
1379
-        if ( empty( $reminder_days ) ) {
1379
+        if (empty($reminder_days)) {
1380 1380
             return;
1381 1381
         }
1382
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1382
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1383 1383
         
1384 1384
         $args = array(
1385 1385
             'post_type'     => 'wpi_invoice',
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
             'meta_query'    => array(
1390 1390
                 array(
1391 1391
                     'key'       =>  '_wpinv_due_date',
1392
-                    'value'     =>  array( '', 'none' ),
1392
+                    'value'     =>  array('', 'none'),
1393 1393
                     'compare'   =>  'NOT IN',
1394 1394
                 )
1395 1395
             ),
@@ -1398,64 +1398,64 @@  discard block
 block discarded – undo
1398 1398
             'order'         => 'ASC',
1399 1399
         );
1400 1400
         
1401
-        $invoices = get_posts( $args );
1401
+        $invoices = get_posts($args);
1402 1402
         
1403
-        if ( empty( $invoices ) ) {
1403
+        if (empty($invoices)) {
1404 1404
             return;
1405 1405
         }
1406 1406
         
1407
-        $date_to_send   = array();
1407
+        $date_to_send = array();
1408 1408
         
1409
-        foreach ( $invoices as $id ) {
1410
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1409
+        foreach ($invoices as $id) {
1410
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1411 1411
             
1412
-            foreach ( $reminder_days as $key => $days ) {
1413
-                if ( $days !== '' ) {
1414
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1412
+            foreach ($reminder_days as $key => $days) {
1413
+                if ($days !== '') {
1414
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1415 1415
                 }
1416 1416
             }
1417 1417
         }
1418 1418
 
1419
-        $today              = date_i18n( 'Y-m-d' );
1419
+        $today              = date_i18n('Y-m-d');
1420 1420
         $wpi_auto_reminder  = true;
1421 1421
 
1422
-        foreach ( $date_to_send as $id => $values ) {
1423
-            if ( in_array( $today, $values ) ) {
1424
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1422
+        foreach ($date_to_send as $id => $values) {
1423
+            if (in_array($today, $values)) {
1424
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1425 1425
 
1426
-                if ( isset( $sent ) && !empty( $sent ) ) {
1427
-                    if ( !in_array( $today, $sent ) ) {
1428
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1426
+                if (isset($sent) && !empty($sent)) {
1427
+                    if (!in_array($today, $sent)) {
1428
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1429 1429
                     }
1430 1430
                 } else {
1431
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1431
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
         
1436
-        $wpi_auto_reminder  = false;
1436
+        $wpi_auto_reminder = false;
1437 1437
     }
1438 1438
 }
1439 1439
 
1440
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1440
+function wpinv_send_payment_reminder_notification($invoice_id) {
1441 1441
     global $wpinv_email_search, $wpinv_email_replace;
1442 1442
     
1443 1443
     $email_type = 'overdue';
1444
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1444
+    if (!wpinv_email_is_enabled($email_type)) {
1445 1445
         return false;
1446 1446
     }
1447 1447
     
1448
-    $invoice    = wpinv_get_invoice( $invoice_id );
1449
-    if ( empty( $invoice ) ) {
1448
+    $invoice = wpinv_get_invoice($invoice_id);
1449
+    if (empty($invoice)) {
1450 1450
         return false;
1451 1451
     }
1452 1452
     
1453
-    if ( !$invoice->needs_payment() ) {
1453
+    if (!$invoice->needs_payment()) {
1454 1454
         return false;
1455 1455
     }
1456 1456
     
1457
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1458
-    if ( !is_email( $recipient ) ) {
1457
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1458
+    if (!is_email($recipient)) {
1459 1459
         return false;
1460 1460
     }
1461 1461
         
@@ -1471,70 +1471,70 @@  discard block
 block discarded – undo
1471 1471
     $replace                    = array();
1472 1472
     $replace['full_name']       = $invoice->get_user_full_name();
1473 1473
     $replace['invoice_number']  = $invoice->get_number();
1474
-    $replace['invoice_due_date']= $invoice->get_due_date( true );
1475
-    $replace['invoice_total']   = $invoice->get_total( true );
1476
-    $replace['invoice_link']    = $invoice->get_view_url( true );
1477
-    $replace['invoice_pay_link']= $replace['invoice_link'];
1478
-    $replace['is_was']          = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' );
1474
+    $replace['invoice_due_date'] = $invoice->get_due_date(true);
1475
+    $replace['invoice_total']   = $invoice->get_total(true);
1476
+    $replace['invoice_link']    = $invoice->get_view_url(true);
1477
+    $replace['invoice_pay_link'] = $replace['invoice_link'];
1478
+    $replace['is_was']          = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing');
1479 1479
 
1480 1480
     $wpinv_email_search         = $search;
1481 1481
     $wpinv_email_replace        = $replace;
1482 1482
     
1483
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1484
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1485
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1486
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1483
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1484
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1485
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1486
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1487 1487
     
1488
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1488
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1489 1489
     
1490
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1490
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1491 1491
             'invoice'       => $invoice,
1492 1492
             'email_type'    => $email_type,
1493 1493
             'email_heading' => $email_heading,
1494 1494
             'sent_to_admin' => false,
1495 1495
             'plain_text'    => false,
1496 1496
             'message_body'  => $message_body
1497
-        ) );
1497
+        ));
1498 1498
         
1499
-    $content        = wpinv_email_format_text( $content );
1499
+    $content = wpinv_email_format_text($content);
1500 1500
 
1501
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1502
-    if ( $sent ) {
1503
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1501
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1502
+    if ($sent) {
1503
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1504 1504
     }
1505 1505
         
1506 1506
     return $sent;
1507 1507
 }
1508
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1508
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1509 1509
 
1510
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1510
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1511 1511
     global $wpi_auto_reminder;
1512 1512
     
1513
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1513
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1514 1514
     
1515
-    if ( empty( $sent ) ) {
1515
+    if (empty($sent)) {
1516 1516
         $sent = array();
1517 1517
     }
1518
-    $sent[] = date_i18n( 'Y-m-d' );
1518
+    $sent[] = date_i18n('Y-m-d');
1519 1519
     
1520
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1520
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1521 1521
     
1522
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note, false, false, true );
1522
+    if ($wpi_auto_reminder) { // Auto reminder note.
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note, false, false, true);
1525 1525
     } else { // Menual reminder note.
1526
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1527
-        $invoice->add_note( $note );
1526
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1527
+        $invoice->add_note($note);
1528 1528
     }
1529 1529
 }
1530
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1530
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1531 1531
 
1532
-function wpinv_email_before_note_details( $invoice, $email_type, $sent_to_admin, $customer_note ) {
1532
+function wpinv_email_before_note_details($invoice, $email_type, $sent_to_admin, $customer_note) {
1533 1533
     if ("wpi_invoice" === $invoice->post_type && !empty($customer_note)) {
1534 1534
         $before_note = '';
1535
-        $before_note .= __( 'Hello, a note has just been added to your invoice:', 'invoicing' );
1536
-        $before_note .= '<blockquote class="wpinv-note">'.wpautop( wptexturize( $customer_note ) ).'</blockquote>';
1537
-        $before_note .= __( 'For your reference, your invoice details are shown below.', 'invoicing' );
1535
+        $before_note .= __('Hello, a note has just been added to your invoice:', 'invoicing');
1536
+        $before_note .= '<blockquote class="wpinv-note">' . wpautop(wptexturize($customer_note)) . '</blockquote>';
1537
+        $before_note .= __('For your reference, your invoice details are shown below.', 'invoicing');
1538 1538
         echo $before_note;
1539 1539
     }
1540 1540
 }
1541 1541
\ No newline at end of file
Please login to merge, or discard this patch.