Passed
Pull Request — master (#217)
by Patrik
03:42 queued 13s
created
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -87,17 +87,17 @@  discard block
 block discarded – undo
87 87
 		 * @return WP_Font_Awesome_Settings - Main instance.
88 88
 		 */
89 89
 		public static function instance() {
90
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
90
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
91 91
 				self::$instance = new WP_Font_Awesome_Settings;
92 92
 
93
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
93
+				add_action('init', array(self::$instance, 'init')); // set settings
94 94
 
95
-				if ( is_admin() ) {
96
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
97
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
95
+				if (is_admin()) {
96
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
97
+					add_action('admin_init', array(self::$instance, 'register_settings'));
98 98
 				}
99 99
 
100
-				do_action( 'wp_font_awesome_settings_loaded' );
100
+				do_action('wp_font_awesome_settings_loaded');
101 101
 			}
102 102
 
103 103
 			return self::$instance;
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		public function init() {
112 112
 			$this->settings = $this->get_settings();
113 113
 
114
-			if ( $this->settings['type'] == 'CSS' ) {
114
+			if ($this->settings['type'] == 'CSS') {
115 115
 
116
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
117
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
116
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
117
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
118 118
 				}
119 119
 
120
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
121
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
120
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
121
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
122 122
 				}
123 123
 
124 124
 			} else {
125 125
 
126
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
127
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
126
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
127
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
128 128
 				}
129 129
 
130
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
131
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
130
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
131
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
132 132
 				}
133 133
 			}
134 134
 
135 135
 			// remove font awesome if set to do so
136
-			if ( $this->settings['dequeue'] == '1' ) {
137
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
136
+			if ($this->settings['dequeue'] == '1') {
137
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
138 138
 			}
139 139
 
140 140
 		}
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 			// build url
147 147
 			$url = $this->get_url();
148 148
 
149
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
150
-			wp_register_style( 'font-awesome', $url, array(), null );
151
-			wp_enqueue_style( 'font-awesome' );
149
+			wp_deregister_style('font-awesome'); // deregister in case its already there
150
+			wp_register_style('font-awesome', $url, array(), null);
151
+			wp_enqueue_style('font-awesome');
152 152
 
153
-			if ( $this->settings['shims'] ) {
154
-				$url = $this->get_url( true );
155
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
156
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
157
-				wp_enqueue_style( 'font-awesome-shims' );
153
+			if ($this->settings['shims']) {
154
+				$url = $this->get_url(true);
155
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
156
+				wp_register_style('font-awesome-shims', $url, array(), null);
157
+				wp_enqueue_style('font-awesome-shims');
158 158
 			}
159 159
 		}
160 160
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			$url = $this->get_url();
167 167
 
168 168
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
169
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
170
-			wp_register_script( 'font-awesome', $url, array(), null );
171
-			wp_enqueue_script( 'font-awesome' );
172
-
173
-			if ( $this->settings['shims'] ) {
174
-				$url = $this->get_url( true );
175
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
176
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
177
-				wp_enqueue_script( 'font-awesome-shims' );
169
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
170
+			wp_register_script('font-awesome', $url, array(), null);
171
+			wp_enqueue_script('font-awesome');
172
+
173
+			if ($this->settings['shims']) {
174
+				$url = $this->get_url(true);
175
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
176
+				wp_register_script('font-awesome-shims', $url, array(), null);
177
+				wp_enqueue_script('font-awesome-shims');
178 178
 			}
179 179
 		}
180 180
 
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
 		 *
186 186
 		 * @return string The url to the file.
187 187
 		 */
188
-		public function get_url( $shims = false ) {
188
+		public function get_url($shims = false) {
189 189
 			$script  = $shims ? 'v4-shims' : 'all';
190 190
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
191 191
 			$type    = $this->settings['type'];
192 192
 			$version = $this->settings['version'];
193
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
193
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
194 194
 			$url     = '';
195 195
 
196
-			if ( $type == 'KIT' && $kit_url ) {
197
-				if ( $shims ) {
196
+			if ($type == 'KIT' && $kit_url) {
197
+				if ($shims) {
198 198
 					// if its a kit then we don't add shims here
199 199
 					return '';
200 200
 				}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$url .= "?wpfas=true"; // set our var so our version is not removed
203 203
 			} else {
204 204
 				$url .= "https://$sub.fontawesome.com/releases/"; // CDN
205
-				$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
205
+				$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
206 206
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
207 207
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
208 208
 				$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 		 *
223 223
 		 * @return string The filtered url.
224 224
 		 */
225
-		public function remove_font_awesome( $url, $original_url, $_context ) {
225
+		public function remove_font_awesome($url, $original_url, $_context) {
226 226
 
227
-			if ( $_context == 'display'
228
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
229
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
227
+			if ($_context == 'display'
228
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
229
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
230 230
 			) {// it's a font-awesome-url (probably)
231 231
 
232
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
233
-					if ( $this->settings['type'] == 'JS' ) {
234
-						if ( $this->settings['js-pseudo'] ) {
232
+				if (strstr($url, "wpfas=true") !== false) {
233
+					if ($this->settings['type'] == 'JS') {
234
+						if ($this->settings['js-pseudo']) {
235 235
 							$url .= "' data-search-pseudo-elements defer='defer";
236 236
 						} else {
237 237
 							$url .= "' defer='defer";
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * Register the database settings with WordPress.
251 251
 		 */
252 252
 		public function register_settings() {
253
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
253
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
254 254
 		}
255 255
 
256 256
 		/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		 */
260 260
 		public function menu_item() {
261 261
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
262
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
262
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
263 263
 				$this,
264 264
 				'settings_page'
265
-			) );
265
+			));
266 266
 		}
267 267
 
268 268
 		/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 		 */
273 273
 		public function get_settings() {
274 274
 
275
-			$db_settings = get_option( 'wp-font-awesome-settings' );
275
+			$db_settings = get_option('wp-font-awesome-settings');
276 276
 
277 277
 			$defaults = array(
278 278
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 				'kit-url'   => '', // the kit url
286 286
 			);
287 287
 
288
-			$settings = wp_parse_args( $db_settings, $defaults );
288
+			$settings = wp_parse_args($db_settings, $defaults);
289 289
 
290 290
 			/**
291 291
 			 * Filter the Font Awesome settings.
292 292
 			 *
293 293
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
294 294
 			 */
295
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
295
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
296 296
 		}
297 297
 
298 298
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 		 * The settings page html output.
301 301
 		 */
302 302
 		public function settings_page() {
303
-			if ( ! current_user_can( 'manage_options' ) ) {
304
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
303
+			if (!current_user_can('manage_options')) {
304
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
305 305
 			}
306 306
 
307 307
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
308
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
309
-				$this->get_latest_version( $force_api = true );
308
+			if (isset($_REQUEST['force-version-check'])) {
309
+				$this->get_latest_version($force_api = true);
310 310
 			}
311 311
 			?>
312 312
 			<style>
@@ -326,37 +326,37 @@  discard block
 block discarded – undo
326 326
 				<h1><?php echo $this->name; ?></h1>
327 327
 				<form method="post" action="options.php">
328 328
 					<?php
329
-					settings_fields( 'wp-font-awesome-settings' );
330
-					do_settings_sections( 'wp-font-awesome-settings' );
329
+					settings_fields('wp-font-awesome-settings');
330
+					do_settings_sections('wp-font-awesome-settings');
331 331
 					$kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : '';
332 332
 					?>
333
-					<table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>">
333
+					<table class="form-table wpfas-table-settings <?php echo esc_attr($kit_set); ?>">
334 334
 						<tr valign="top">
335 335
 							<th scope="row"><label
336
-									for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
336
+									for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
337 337
 							<td>
338 338
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type"
339 339
 								        onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
340 340
 									<option
341
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
342
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
341
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
342
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
343 343
 									<option
344
-										value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
344
+										value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
345 345
 								</select>
346 346
 							</td>
347 347
 						</tr>
348 348
 
349 349
 						<tr valign="top" class="wpfas-kit-show">
350 350
 							<th scope="row"><label
351
-									for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
351
+									for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
352 352
 							<td>
353 353
 								<input class="regular-text" id="wpfas-kit-url" type="url"
354 354
 								       name="wp-font-awesome-settings[kit-url]"
355
-								       value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>"
355
+								       value="<?php echo esc_attr($this->settings['kit-url']); ?>"
356 356
 								       placeholder="https://kit.fontawesome.com/123abc.js"/>
357 357
 								<span><?php
358 358
 									echo sprintf(
359
-										__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
359
+										__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
360 360
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
361 361
 										'</a>'
362 362
 									);
@@ -366,31 +366,31 @@  discard block
 block discarded – undo
366 366
 
367 367
 						<tr valign="top" class="wpfas-kit-hide">
368 368
 							<th scope="row"><label
369
-									for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
369
+									for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
370 370
 							<td>
371 371
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
372 372
 									<option
373
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
373
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
374 374
 									</option>
375
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
375
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
376 376
 										5.6.0
377 377
 									</option>
378
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
378
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
379 379
 										5.5.0
380 380
 									</option>
381
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
381
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
382 382
 										5.4.0
383 383
 									</option>
384
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
384
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
385 385
 										5.3.0
386 386
 									</option>
387
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
387
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
388 388
 										5.2.0
389 389
 									</option>
390
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
390
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
391 391
 										5.1.0
392 392
 									</option>
393
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
393
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
394 394
 										4.7.1 (CSS only)
395 395
 									</option>
396 396
 								</select>
@@ -399,29 +399,29 @@  discard block
 block discarded – undo
399 399
 
400 400
 						<tr valign="top">
401 401
 							<th scope="row"><label
402
-									for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
402
+									for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
403 403
 							<td>
404 404
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
405 405
 									<option
406
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
406
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
407 407
 									<option
408
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
408
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
409 409
 									<option
410
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
410
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
411 411
 								</select>
412 412
 							</td>
413 413
 						</tr>
414 414
 
415 415
 						<tr valign="top" class="wpfas-kit-hide">
416 416
 							<th scope="row"><label
417
-									for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
417
+									for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
418 418
 							<td>
419 419
 								<input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
420 420
 								<input type="checkbox" name="wp-font-awesome-settings[pro]"
421
-								       value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/>
421
+								       value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/>
422 422
 								<span><?php
423 423
 									echo sprintf(
424
-										__( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ),
424
+										__('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'),
425 425
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>',
426 426
 										'</a>',
427 427
 										'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>',
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
 
434 434
 						<tr valign="top" class="wpfas-kit-hide">
435 435
 							<th scope="row"><label
436
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
436
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
437 437
 							</th>
438 438
 							<td>
439 439
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
440 440
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
441
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
442
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
441
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
442
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
443 443
 							</td>
444 444
 						</tr>
445 445
 
446 446
 						<tr valign="top" class="wpfas-kit-hide">
447 447
 							<th scope="row"><label
448
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
448
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
449 449
 							</th>
450 450
 							<td>
451 451
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
452 452
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
453
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
453
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
454 454
 								       id="wpfas-js-pseudo"/>
455
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
455
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
456 456
 							</td>
457 457
 						</tr>
458 458
 
459 459
 						<tr valign="top">
460 460
 							<th scope="row"><label
461
-									for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
461
+									for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
462 462
 							<td>
463 463
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
464 464
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
465
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
465
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
466 466
 								       id="wpfas-dequeue"/>
467
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
467
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
468 468
 							</td>
469 469
 						</tr>
470 470
 
@@ -489,12 +489,12 @@  discard block
 block discarded – undo
489 489
 		 *
490 490
 		 * @return string Either a valid version number or an empty string.
491 491
 		 */
492
-		public function validate_version_number( $version ) {
492
+		public function validate_version_number($version) {
493 493
 
494
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
494
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
495 495
 				// valid
496 496
 			} else {
497
-				$version = '';// not validated
497
+				$version = ''; // not validated
498 498
 			}
499 499
 
500 500
 			return $version;
@@ -509,19 +509,19 @@  discard block
 block discarded – undo
509 509
 		 * @since 1.0.7
510 510
 		 * @return mixed|string The latest version number found.
511 511
 		 */
512
-		public function get_latest_version( $force_api = false ) {
512
+		public function get_latest_version($force_api = false) {
513 513
 			$latest_version = $this->latest;
514 514
 
515
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
515
+			$cache = get_transient('wp-font-awesome-settings-version');
516 516
 
517
-			if ( $cache === false || $force_api ) { // its not set
517
+			if ($cache === false || $force_api) { // its not set
518 518
 				$api_ver = $this->get_latest_version_from_api();
519
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
519
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
520 520
 					$latest_version = $api_ver;
521
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
521
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
522 522
 				}
523
-			} elseif ( $this->validate_version_number( $cache ) ) {
524
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
523
+			} elseif ($this->validate_version_number($cache)) {
524
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
525 525
 					$latest_version = $cache;
526 526
 				}
527 527
 			}
@@ -537,10 +537,10 @@  discard block
 block discarded – undo
537 537
 		 */
538 538
 		public function get_latest_version_from_api() {
539 539
 			$version  = "0";
540
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
541
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
542
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
543
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
540
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
541
+			if (!is_wp_error($response) && is_array($response)) {
542
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
543
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
544 544
 					$version = $api_response['tag_name'];
545 545
 				}
546 546
 			}
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +389 added lines, -389 removed lines patch added patch discarded remove patch
@@ -7,132 +7,132 @@  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_item_quantities_enabled() {
15
-    $ret = wpinv_get_option( 'item_quantities', true );
15
+    $ret = wpinv_get_option('item_quantities', true);
16 16
 
17
-    return (bool) apply_filters( 'wpinv_item_quantities_enabled', $ret );
17
+    return (bool)apply_filters('wpinv_item_quantities_enabled', $ret);
18 18
 }
19 19
 
20 20
 function wpinv_get_ip() {
21 21
     $ip = '127.0.0.1';
22 22
 
23
-    if ( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
24
-        $ip = sanitize_text_field( $_SERVER['HTTP_CLIENT_IP'] );
25
-    } elseif ( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
26
-        $ip = sanitize_text_field( $_SERVER['HTTP_X_FORWARDED_FOR'] );
27
-    } elseif( !empty( $_SERVER['REMOTE_ADDR'] ) ) {
28
-        $ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] );
23
+    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
24
+        $ip = sanitize_text_field($_SERVER['HTTP_CLIENT_IP']);
25
+    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
26
+        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
27
+    } elseif (!empty($_SERVER['REMOTE_ADDR'])) {
28
+        $ip = sanitize_text_field($_SERVER['REMOTE_ADDR']);
29 29
     }
30 30
 
31
-    return apply_filters( 'wpinv_get_ip', $ip );
31
+    return apply_filters('wpinv_get_ip', $ip);
32 32
 }
33 33
 
34 34
 function wpinv_get_user_agent() {
35
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
36
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
35
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
36
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
37 37
     } else {
38 38
         $user_agent = '';
39 39
     }
40 40
 
41
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
41
+    return apply_filters('wpinv_get_user_agent', $user_agent);
42 42
 }
43 43
 
44
-function wpinv_sanitize_amount( $amount, $decimals = NULL ) {
44
+function wpinv_sanitize_amount($amount, $decimals = NULL) {
45 45
     $is_negative   = false;
46 46
     $thousands_sep = wpinv_thousands_separator();
47 47
     $decimal_sep   = wpinv_decimal_separator();
48
-    if ( $decimals === NULL ) {
48
+    if ($decimals === NULL) {
49 49
         $decimals = wpinv_decimals();
50 50
     }
51 51
 
52 52
     // Sanitize the amount
53
-    if ( $decimal_sep == ',' && false !== ( $found = strpos( $amount, $decimal_sep ) ) ) {
54
-        if ( ( $thousands_sep == '.' || $thousands_sep == ' ' ) && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
55
-            $amount = str_replace( $thousands_sep, '', $amount );
56
-        } elseif( empty( $thousands_sep ) && false !== ( $found = strpos( $amount, '.' ) ) ) {
57
-            $amount = str_replace( '.', '', $amount );
53
+    if ($decimal_sep == ',' && false !== ($found = strpos($amount, $decimal_sep))) {
54
+        if (($thousands_sep == '.' || $thousands_sep == ' ') && false !== ($found = strpos($amount, $thousands_sep))) {
55
+            $amount = str_replace($thousands_sep, '', $amount);
56
+        } elseif (empty($thousands_sep) && false !== ($found = strpos($amount, '.'))) {
57
+            $amount = str_replace('.', '', $amount);
58 58
         }
59 59
 
60
-        $amount = str_replace( $decimal_sep, '.', $amount );
61
-    } elseif( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
62
-        $amount = str_replace( $thousands_sep, '', $amount );
60
+        $amount = str_replace($decimal_sep, '.', $amount);
61
+    } elseif ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
62
+        $amount = str_replace($thousands_sep, '', $amount);
63 63
     }
64 64
 
65
-    if( $amount < 0 ) {
65
+    if ($amount < 0) {
66 66
         $is_negative = true;
67 67
     }
68 68
 
69
-    $amount   = preg_replace( '/[^0-9\.]/', '', $amount );
69
+    $amount   = preg_replace('/[^0-9\.]/', '', $amount);
70 70
 
71
-    $decimals = apply_filters( 'wpinv_sanitize_amount_decimals', absint( $decimals ), $amount );
72
-    $amount   = number_format( (double) $amount, absint( $decimals ), '.', '' );
71
+    $decimals = apply_filters('wpinv_sanitize_amount_decimals', absint($decimals), $amount);
72
+    $amount   = number_format((double)$amount, absint($decimals), '.', '');
73 73
 
74
-    if( $is_negative ) {
74
+    if ($is_negative) {
75 75
         $amount *= -1;
76 76
     }
77 77
 
78
-    return apply_filters( 'wpinv_sanitize_amount', $amount, $decimals );
78
+    return apply_filters('wpinv_sanitize_amount', $amount, $decimals);
79 79
 }
80
-add_filter( 'wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
80
+add_filter('wpinv_sanitize_amount_decimals', 'wpinv_currency_decimal_filter', 10, 1);
81 81
 
82
-function wpinv_round_amount( $amount, $decimals = NULL ) {
83
-    if ( $decimals === NULL ) {
82
+function wpinv_round_amount($amount, $decimals = NULL) {
83
+    if ($decimals === NULL) {
84 84
         $decimals = wpinv_decimals();
85 85
     }
86 86
     
87
-    $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) );
87
+    $amount = round((double)$amount, wpinv_currency_decimal_filter(absint($decimals)));
88 88
 
89
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
89
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
90 90
 }
91 91
 
92
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
92
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
93 93
     global $post;
94 94
 
95 95
     $invoice_statuses = array(
96
-        'wpi-pending' => __( 'Pending Payment', 'invoicing' ),
97
-        'publish' => __( 'Paid', 'invoicing'),
98
-        'wpi-processing' => __( 'Processing', 'invoicing' ),
99
-        'wpi-onhold' => __( 'On Hold', 'invoicing' ),
100
-        'wpi-refunded' => __( 'Refunded', 'invoicing' ),
101
-        'wpi-cancelled' => __( 'Cancelled', 'invoicing' ),
102
-        'wpi-failed' => __( 'Failed', 'invoicing' ),
103
-        'wpi-renewal' => __( 'Renewal Payment', 'invoicing' )
96
+        'wpi-pending' => __('Pending Payment', 'invoicing'),
97
+        'publish' => __('Paid', 'invoicing'),
98
+        'wpi-processing' => __('Processing', 'invoicing'),
99
+        'wpi-onhold' => __('On Hold', 'invoicing'),
100
+        'wpi-refunded' => __('Refunded', 'invoicing'),
101
+        'wpi-cancelled' => __('Cancelled', 'invoicing'),
102
+        'wpi-failed' => __('Failed', 'invoicing'),
103
+        'wpi-renewal' => __('Renewal Payment', 'invoicing')
104 104
     );
105 105
 
106
-    if ( $draft ) {
107
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
106
+    if ($draft) {
107
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
108 108
     }
109 109
 
110
-    if ( $trashed ) {
111
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
110
+    if ($trashed) {
111
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
112 112
     }
113 113
 
114
-    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
114
+    return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
115 115
 }
116 116
 
117
-function wpinv_status_nicename( $status ) {
118
-    $statuses = wpinv_get_invoice_statuses( true, true );
119
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' );
117
+function wpinv_status_nicename($status) {
118
+    $statuses = wpinv_get_invoice_statuses(true, true);
119
+    $status   = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing');
120 120
 
121 121
     return $status;
122 122
 }
123 123
 
124 124
 function wpinv_get_currency() {
125
-    $currency = wpinv_get_option( 'currency', 'USD' );
125
+    $currency = wpinv_get_option('currency', 'USD');
126 126
     
127
-    return apply_filters( 'wpinv_currency', $currency );
127
+    return apply_filters('wpinv_currency', $currency);
128 128
 }
129 129
 
130
-function wpinv_currency_symbol( $currency = '' ) {
131
-    if ( empty( $currency ) ) {
130
+function wpinv_currency_symbol($currency = '') {
131
+    if (empty($currency)) {
132 132
         $currency = wpinv_get_currency();
133 133
     }
134 134
     
135
-    $symbols = apply_filters( 'wpinv_currency_symbols', array(
135
+    $symbols = apply_filters('wpinv_currency_symbols', array(
136 136
         'AED' => '&#x62f;.&#x625;',
137 137
         'AFN' => '&#x60b;',
138 138
         'ALL' => 'L',
@@ -295,209 +295,209 @@  discard block
 block discarded – undo
295 295
         'YER' => '&#xfdfc;',
296 296
         'ZAR' => '&#82;',
297 297
         'ZMW' => 'ZK',
298
-    ) );
298
+    ));
299 299
 
300
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
300
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
301 301
 
302
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
302
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
303 303
 }
304 304
 
305 305
 function wpinv_currency_position() {
306
-    $position = wpinv_get_option( 'currency_position', 'left' );
306
+    $position = wpinv_get_option('currency_position', 'left');
307 307
     
308
-    return apply_filters( 'wpinv_currency_position', $position );
308
+    return apply_filters('wpinv_currency_position', $position);
309 309
 }
310 310
 
311 311
 function wpinv_thousands_separator() {
312
-    $thousand_sep = wpinv_get_option( 'thousands_separator', ',' );
312
+    $thousand_sep = wpinv_get_option('thousands_separator', ',');
313 313
     
314
-    return apply_filters( 'wpinv_thousands_separator', $thousand_sep );
314
+    return apply_filters('wpinv_thousands_separator', $thousand_sep);
315 315
 }
316 316
 
317 317
 function wpinv_decimal_separator() {
318
-    $decimal_sep = wpinv_get_option( 'decimal_separator', '.' );
318
+    $decimal_sep = wpinv_get_option('decimal_separator', '.');
319 319
     
320
-    return apply_filters( 'wpinv_decimal_separator', $decimal_sep );
320
+    return apply_filters('wpinv_decimal_separator', $decimal_sep);
321 321
 }
322 322
 
323 323
 function wpinv_decimals() {
324
-    $decimals = apply_filters( 'wpinv_decimals', wpinv_get_option( 'decimals', 2 ) );
324
+    $decimals = apply_filters('wpinv_decimals', wpinv_get_option('decimals', 2));
325 325
     
326
-    return absint( $decimals );
326
+    return absint($decimals);
327 327
 }
328 328
 
329 329
 function wpinv_get_currencies() {
330 330
     $currencies = array(
331
-        'USD' => __( 'US Dollar', 'invoicing' ),
332
-        'EUR' => __( 'Euro', 'invoicing' ),
333
-        'GBP' => __( 'Pound Sterling', 'invoicing' ),
334
-        'AED' => __( 'United Arab Emirates', 'invoicing' ),
335
-        'AFN' => __( 'Afghan Afghani', 'invoicing' ),
336
-        'ALL' => __( 'Albanian Lek', 'invoicing' ),
337
-        'AMD' => __( 'Armenian Dram', 'invoicing' ),
338
-        'ANG' => __( 'Netherlands Antillean Guilder', 'invoicing' ),
339
-        'AOA' => __( 'Angolan Kwanza', 'invoicing' ),
340
-        'ARS' => __( 'Argentine Peso', 'invoicing' ),
341
-        'AUD' => __( 'Australian Dollar', 'invoicing' ),
342
-        'AWG' => __( 'Aruban Florin', 'invoicing' ),
343
-        'AZN' => __( 'Azerbaijani Manat', 'invoicing' ),
344
-        'BAM' => __( 'Bosnia and Herzegovina Convertible Marka', 'invoicing' ),
345
-        'BBD' => __( 'Barbadian Dollar', 'invoicing' ),
346
-        'BDT' => __( 'Bangladeshi Taka', 'invoicing' ),
347
-        'BGN' => __( 'Bulgarian Lev', 'invoicing' ),
348
-        'BHD' => __( 'Bahraini Dinar', 'invoicing' ),
349
-        'BIF' => __( 'Burundian Franc', 'invoicing' ),
350
-        'BMD' => __( 'Bermudian Dollar', 'invoicing' ),
351
-        'BND' => __( 'Brunei Dollar', 'invoicing' ),
352
-        'BOB' => __( 'Bolivian Boliviano', 'invoicing' ),
353
-        'BRL' => __( 'Brazilian Real', 'invoicing' ),
354
-        'BSD' => __( 'Bahamian Dollar', 'invoicing' ),
355
-        'BTC' => __( 'Bitcoin', 'invoicing' ),
356
-        'BTN' => __( 'Bhutanese Ngultrum', 'invoicing' ),
357
-        'BWP' => __( 'Botswana Pula', 'invoicing' ),
358
-        'BYN' => __( 'Belarusian Ruble', 'invoicing' ),
359
-        'BZD' => __( 'Belize Dollar', 'invoicing' ),
360
-        'CAD' => __( 'Canadian Dollar', 'invoicing' ),
361
-        'CDF' => __( 'Congolese Franc', 'invoicing' ),
362
-        'CHF' => __( 'Swiss Franc', 'invoicing' ),
363
-        'CLP' => __( 'Chilean Peso', 'invoicing' ),
364
-        'CNY' => __( 'Chinese Yuan', 'invoicing' ),
365
-        'COP' => __( 'Colombian Peso', 'invoicing' ),
366
-        'CRC' => __( 'Costa Rican Colon', 'invoicing' ),
367
-        'CUC' => __( 'Cuban Convertible Peso', 'invoicing' ),
368
-        'CUP' => __( 'Cuban Peso', 'invoicing' ),
369
-        'CVE' => __( 'Cape Verdean escudo', 'invoicing' ),
370
-        'CZK' => __( 'Czech Koruna', 'invoicing' ),
371
-        'DJF' => __( 'Djiboutian Franc', 'invoicing' ),
372
-        'DKK' => __( 'Danish Krone', 'invoicing' ),
373
-        'DOP' => __( 'Dominican Peso', 'invoicing' ),
374
-        'DZD' => __( 'Algerian Dinar', 'invoicing' ),
375
-        'EGP' => __( 'Egyptian Pound', 'invoicing' ),
376
-        'ERN' => __( 'Eritrean Nakfa', 'invoicing' ),
377
-        'ETB' => __( 'Ethiopian Irr', 'invoicing' ),
378
-        'FJD' => __( 'Fijian Dollar', 'invoicing' ),
379
-        'FKP' => __( 'Falkland Islands Pound', 'invoicing' ),
380
-        'GEL' => __( 'Georgian Lari', 'invoicing' ),
381
-        'GGP' => __( 'Guernsey Pound', 'invoicing' ),
382
-        'GHS' => __( 'Ghana Cedi', 'invoicing' ),
383
-        'GIP' => __( 'Gibraltar Pound', 'invoicing' ),
384
-        'GMD' => __( 'Gambian Dalasi', 'invoicing' ),
385
-        'GNF' => __( 'Guinean Franc', 'invoicing' ),
386
-        'GTQ' => __( 'Guatemalan Quetzal', 'invoicing' ),
387
-        'GYD' => __( 'Guyanese Dollar', 'invoicing' ),
388
-        'HKD' => __( 'Hong Kong Dollar', 'invoicing' ),
389
-        'HNL' => __( 'Honduran Lempira', 'invoicing' ),
390
-        'HRK' => __( 'Croatian Kuna', 'invoicing' ),
391
-        'HTG' => __( 'Haitian Gourde', 'invoicing' ),
392
-        'HUF' => __( 'Hungarian Forint', 'invoicing' ),
393
-        'IDR' => __( 'Indonesian Rupiah', 'invoicing' ),
394
-        'ILS' => __( 'Israeli New Shekel', 'invoicing' ),
395
-        'IMP' => __( 'Manx Pound', 'invoicing' ),
396
-        'INR' => __( 'Indian Rupee', 'invoicing' ),
397
-        'IQD' => __( 'Iraqi Dinar', 'invoicing' ),
398
-        'IRR' => __( 'Iranian Rial', 'invoicing' ),
399
-        'IRT' => __( 'Iranian Toman', 'invoicing' ),
400
-        'ISK' => __( 'Icelandic Krona', 'invoicing' ),
401
-        'JEP' => __( 'Jersey Pound', 'invoicing' ),
402
-        'JMD' => __( 'Jamaican Dollar', 'invoicing' ),
403
-        'JOD' => __( 'Jordanian Dinar', 'invoicing' ),
404
-        'JPY' => __( 'Japanese Yen', 'invoicing' ),
405
-        'KES' => __( 'Kenyan Shilling', 'invoicing' ),
406
-        'KGS' => __( 'Kyrgyzstani Som', 'invoicing' ),
407
-        'KHR' => __( 'Cambodian Riel', 'invoicing' ),
408
-        'KMF' => __( 'Comorian Franc', 'invoicing' ),
409
-        'KPW' => __( 'North Korean Won', 'invoicing' ),
410
-        'KRW' => __( 'South Korean Won', 'invoicing' ),
411
-        'KWD' => __( 'Kuwaiti Dinar', 'invoicing' ),
412
-        'KYD' => __( 'Cayman Islands Dollar', 'invoicing' ),
413
-        'KZT' => __( 'Kazakhstani Tenge', 'invoicing' ),
414
-        'LAK' => __( 'Lao Kip', 'invoicing' ),
415
-        'LBP' => __( 'Lebanese Pound', 'invoicing' ),
416
-        'LKR' => __( 'Sri Lankan Rupee', 'invoicing' ),
417
-        'LRD' => __( 'Liberian Dollar', 'invoicing' ),
418
-        'LSL' => __( 'Lesotho Loti', 'invoicing' ),
419
-        'LYD' => __( 'Libyan Dinar', 'invoicing' ),
420
-        'MAD' => __( 'Moroccan Dirham', 'invoicing' ),
421
-        'MDL' => __( 'Moldovan Leu', 'invoicing' ),
422
-        'MGA' => __( 'Malagasy Ariary', 'invoicing' ),
423
-        'MKD' => __( 'Macedonian Denar', 'invoicing' ),
424
-        'MMK' => __( 'Burmese Kyat', 'invoicing' ),
425
-        'MNT' => __( 'Mongolian Tughrik', 'invoicing' ),
426
-        'MOP' => __( 'Macanese Pataca', 'invoicing' ),
427
-        'MRO' => __( 'Mauritanian Ouguiya', 'invoicing' ),
428
-        'MUR' => __( 'Mauritian Rupee', 'invoicing' ),
429
-        'MVR' => __( 'Maldivian Rufiyaa', 'invoicing' ),
430
-        'MWK' => __( 'Malawian Kwacha', 'invoicing' ),
431
-        'MXN' => __( 'Mexican Peso', 'invoicing' ),
432
-        'MYR' => __( 'Malaysian Ringgit', 'invoicing' ),
433
-        'MZN' => __( 'Mozambican Metical', 'invoicing' ),
434
-        'NAD' => __( 'Namibian Dollar', 'invoicing' ),
435
-        'NGN' => __( 'Nigerian Naira', 'invoicing' ),
436
-        'NIO' => __( 'Nicaraguan Cordoba', 'invoicing' ),
437
-        'NOK' => __( 'Norwegian Krone', 'invoicing' ),
438
-        'NPR' => __( 'Nepalese Rupee', 'invoicing' ),
439
-        'NZD' => __( 'New Zealand Dollar', 'invoicing' ),
440
-        'OMR' => __( 'Omani Rial', 'invoicing' ),
441
-        'PAB' => __( 'Panamanian Balboa', 'invoicing' ),
442
-        'PEN' => __( 'Peruvian Nuevo Sol', 'invoicing' ),
443
-        'PGK' => __( 'Papua New Guinean Kina', 'invoicing' ),
444
-        'PHP' => __( 'Philippine Peso', 'invoicing' ),
445
-        'PKR' => __( 'Pakistani Rupee', 'invoicing' ),
446
-        'PLN' => __( 'Polish Zloty', 'invoicing' ),
447
-        'PRB' => __( 'Transnistrian Ruble', 'invoicing' ),
448
-        'PYG' => __( 'Paraguayan Guarani', 'invoicing' ),
449
-        'QAR' => __( 'Qatari Riyal', 'invoicing' ),
450
-        'RON' => __( 'Romanian Leu', 'invoicing' ),
451
-        'RSD' => __( 'Serbian Dinar', 'invoicing' ),
452
-        'RUB' => __( 'Russian Ruble', 'invoicing' ),
453
-        'RWF' => __( 'Rwandan Franc', 'invoicing' ),
454
-        'SAR' => __( 'Saudi Riyal', 'invoicing' ),
455
-        'SBD' => __( 'Solomon Islands Dollar', 'invoicing' ),
456
-        'SCR' => __( 'Seychellois Rupee', 'invoicing' ),
457
-        'SDG' => __( 'Sudanese Pound', 'invoicing' ),
458
-        'SEK' => __( 'Swedish Krona', 'invoicing' ),
459
-        'SGD' => __( 'Singapore Dollar', 'invoicing' ),
460
-        'SHP' => __( 'Saint Helena Pound', 'invoicing' ),
461
-        'SLL' => __( 'Sierra Leonean Leone', 'invoicing' ),
462
-        'SOS' => __( 'Somali Shilling', 'invoicing' ),
463
-        'SRD' => __( 'Surinamese Dollar', 'invoicing' ),
464
-        'SSP' => __( 'South Sudanese Pound', 'invoicing' ),
465
-        'STD' => __( 'Sao Tomean Dobra', 'invoicing' ),
466
-        'SYP' => __( 'Syrian Pound', 'invoicing' ),
467
-        'SZL' => __( 'Swazi Lilangeni', 'invoicing' ),
468
-        'THB' => __( 'Thai Baht', 'invoicing' ),
469
-        'TJS' => __( 'Tajikistani Somoni', 'invoicing' ),
470
-        'TMT' => __( 'Turkmenistan Manat', 'invoicing' ),
471
-        'TND' => __( 'Tunisian Dinar', 'invoicing' ),
472
-        'TOP' => __( 'Tongan Pa&#x2bb;anga', 'invoicing' ),
473
-        'TRY' => __( 'Turkish Lira', 'invoicing' ),
474
-        'TTD' => __( 'Trinidad and Tobago Dollar', 'invoicing' ),
475
-        'TWD' => __( 'New Taiwan Dollar', 'invoicing' ),
476
-        'TZS' => __( 'Tanzanian Shilling', 'invoicing' ),
477
-        'UAH' => __( 'Ukrainian Hryvnia', 'invoicing' ),
478
-        'UGX' => __( 'Ugandan Shilling', 'invoicing' ),
479
-        'UYU' => __( 'Uruguayan Peso', 'invoicing' ),
480
-        'UZS' => __( 'Uzbekistani Som', 'invoicing' ),
481
-        'VEF' => __( 'Venezuelan Bol&iacute;var', 'invoicing' ),
482
-        'VND' => __( 'Vietnamese Dong', 'invoicing' ),
483
-        'VUV' => __( 'Vanuatu Vatu', 'invoicing' ),
484
-        'WST' => __( 'Samoan Tala', 'invoicing' ),
485
-        'XAF' => __( 'Central African CFA Franc', 'invoicing' ),
486
-        'XCD' => __( 'East Caribbean Dollar', 'invoicing' ),
487
-        'XOF' => __( 'West African CFA Franc', 'invoicing' ),
488
-        'XPF' => __( 'CFP Franc', 'invoicing' ),
489
-        'YER' => __( 'Yemeni Rial', 'invoicing' ),
490
-        'ZAR' => __( 'South African Rand', 'invoicing' ),
491
-        'ZMW' => __( 'Zambian Kwacha', 'invoicing' ),
331
+        'USD' => __('US Dollar', 'invoicing'),
332
+        'EUR' => __('Euro', 'invoicing'),
333
+        'GBP' => __('Pound Sterling', 'invoicing'),
334
+        'AED' => __('United Arab Emirates', 'invoicing'),
335
+        'AFN' => __('Afghan Afghani', 'invoicing'),
336
+        'ALL' => __('Albanian Lek', 'invoicing'),
337
+        'AMD' => __('Armenian Dram', 'invoicing'),
338
+        'ANG' => __('Netherlands Antillean Guilder', 'invoicing'),
339
+        'AOA' => __('Angolan Kwanza', 'invoicing'),
340
+        'ARS' => __('Argentine Peso', 'invoicing'),
341
+        'AUD' => __('Australian Dollar', 'invoicing'),
342
+        'AWG' => __('Aruban Florin', 'invoicing'),
343
+        'AZN' => __('Azerbaijani Manat', 'invoicing'),
344
+        'BAM' => __('Bosnia and Herzegovina Convertible Marka', 'invoicing'),
345
+        'BBD' => __('Barbadian Dollar', 'invoicing'),
346
+        'BDT' => __('Bangladeshi Taka', 'invoicing'),
347
+        'BGN' => __('Bulgarian Lev', 'invoicing'),
348
+        'BHD' => __('Bahraini Dinar', 'invoicing'),
349
+        'BIF' => __('Burundian Franc', 'invoicing'),
350
+        'BMD' => __('Bermudian Dollar', 'invoicing'),
351
+        'BND' => __('Brunei Dollar', 'invoicing'),
352
+        'BOB' => __('Bolivian Boliviano', 'invoicing'),
353
+        'BRL' => __('Brazilian Real', 'invoicing'),
354
+        'BSD' => __('Bahamian Dollar', 'invoicing'),
355
+        'BTC' => __('Bitcoin', 'invoicing'),
356
+        'BTN' => __('Bhutanese Ngultrum', 'invoicing'),
357
+        'BWP' => __('Botswana Pula', 'invoicing'),
358
+        'BYN' => __('Belarusian Ruble', 'invoicing'),
359
+        'BZD' => __('Belize Dollar', 'invoicing'),
360
+        'CAD' => __('Canadian Dollar', 'invoicing'),
361
+        'CDF' => __('Congolese Franc', 'invoicing'),
362
+        'CHF' => __('Swiss Franc', 'invoicing'),
363
+        'CLP' => __('Chilean Peso', 'invoicing'),
364
+        'CNY' => __('Chinese Yuan', 'invoicing'),
365
+        'COP' => __('Colombian Peso', 'invoicing'),
366
+        'CRC' => __('Costa Rican Colon', 'invoicing'),
367
+        'CUC' => __('Cuban Convertible Peso', 'invoicing'),
368
+        'CUP' => __('Cuban Peso', 'invoicing'),
369
+        'CVE' => __('Cape Verdean escudo', 'invoicing'),
370
+        'CZK' => __('Czech Koruna', 'invoicing'),
371
+        'DJF' => __('Djiboutian Franc', 'invoicing'),
372
+        'DKK' => __('Danish Krone', 'invoicing'),
373
+        'DOP' => __('Dominican Peso', 'invoicing'),
374
+        'DZD' => __('Algerian Dinar', 'invoicing'),
375
+        'EGP' => __('Egyptian Pound', 'invoicing'),
376
+        'ERN' => __('Eritrean Nakfa', 'invoicing'),
377
+        'ETB' => __('Ethiopian Irr', 'invoicing'),
378
+        'FJD' => __('Fijian Dollar', 'invoicing'),
379
+        'FKP' => __('Falkland Islands Pound', 'invoicing'),
380
+        'GEL' => __('Georgian Lari', 'invoicing'),
381
+        'GGP' => __('Guernsey Pound', 'invoicing'),
382
+        'GHS' => __('Ghana Cedi', 'invoicing'),
383
+        'GIP' => __('Gibraltar Pound', 'invoicing'),
384
+        'GMD' => __('Gambian Dalasi', 'invoicing'),
385
+        'GNF' => __('Guinean Franc', 'invoicing'),
386
+        'GTQ' => __('Guatemalan Quetzal', 'invoicing'),
387
+        'GYD' => __('Guyanese Dollar', 'invoicing'),
388
+        'HKD' => __('Hong Kong Dollar', 'invoicing'),
389
+        'HNL' => __('Honduran Lempira', 'invoicing'),
390
+        'HRK' => __('Croatian Kuna', 'invoicing'),
391
+        'HTG' => __('Haitian Gourde', 'invoicing'),
392
+        'HUF' => __('Hungarian Forint', 'invoicing'),
393
+        'IDR' => __('Indonesian Rupiah', 'invoicing'),
394
+        'ILS' => __('Israeli New Shekel', 'invoicing'),
395
+        'IMP' => __('Manx Pound', 'invoicing'),
396
+        'INR' => __('Indian Rupee', 'invoicing'),
397
+        'IQD' => __('Iraqi Dinar', 'invoicing'),
398
+        'IRR' => __('Iranian Rial', 'invoicing'),
399
+        'IRT' => __('Iranian Toman', 'invoicing'),
400
+        'ISK' => __('Icelandic Krona', 'invoicing'),
401
+        'JEP' => __('Jersey Pound', 'invoicing'),
402
+        'JMD' => __('Jamaican Dollar', 'invoicing'),
403
+        'JOD' => __('Jordanian Dinar', 'invoicing'),
404
+        'JPY' => __('Japanese Yen', 'invoicing'),
405
+        'KES' => __('Kenyan Shilling', 'invoicing'),
406
+        'KGS' => __('Kyrgyzstani Som', 'invoicing'),
407
+        'KHR' => __('Cambodian Riel', 'invoicing'),
408
+        'KMF' => __('Comorian Franc', 'invoicing'),
409
+        'KPW' => __('North Korean Won', 'invoicing'),
410
+        'KRW' => __('South Korean Won', 'invoicing'),
411
+        'KWD' => __('Kuwaiti Dinar', 'invoicing'),
412
+        'KYD' => __('Cayman Islands Dollar', 'invoicing'),
413
+        'KZT' => __('Kazakhstani Tenge', 'invoicing'),
414
+        'LAK' => __('Lao Kip', 'invoicing'),
415
+        'LBP' => __('Lebanese Pound', 'invoicing'),
416
+        'LKR' => __('Sri Lankan Rupee', 'invoicing'),
417
+        'LRD' => __('Liberian Dollar', 'invoicing'),
418
+        'LSL' => __('Lesotho Loti', 'invoicing'),
419
+        'LYD' => __('Libyan Dinar', 'invoicing'),
420
+        'MAD' => __('Moroccan Dirham', 'invoicing'),
421
+        'MDL' => __('Moldovan Leu', 'invoicing'),
422
+        'MGA' => __('Malagasy Ariary', 'invoicing'),
423
+        'MKD' => __('Macedonian Denar', 'invoicing'),
424
+        'MMK' => __('Burmese Kyat', 'invoicing'),
425
+        'MNT' => __('Mongolian Tughrik', 'invoicing'),
426
+        'MOP' => __('Macanese Pataca', 'invoicing'),
427
+        'MRO' => __('Mauritanian Ouguiya', 'invoicing'),
428
+        'MUR' => __('Mauritian Rupee', 'invoicing'),
429
+        'MVR' => __('Maldivian Rufiyaa', 'invoicing'),
430
+        'MWK' => __('Malawian Kwacha', 'invoicing'),
431
+        'MXN' => __('Mexican Peso', 'invoicing'),
432
+        'MYR' => __('Malaysian Ringgit', 'invoicing'),
433
+        'MZN' => __('Mozambican Metical', 'invoicing'),
434
+        'NAD' => __('Namibian Dollar', 'invoicing'),
435
+        'NGN' => __('Nigerian Naira', 'invoicing'),
436
+        'NIO' => __('Nicaraguan Cordoba', 'invoicing'),
437
+        'NOK' => __('Norwegian Krone', 'invoicing'),
438
+        'NPR' => __('Nepalese Rupee', 'invoicing'),
439
+        'NZD' => __('New Zealand Dollar', 'invoicing'),
440
+        'OMR' => __('Omani Rial', 'invoicing'),
441
+        'PAB' => __('Panamanian Balboa', 'invoicing'),
442
+        'PEN' => __('Peruvian Nuevo Sol', 'invoicing'),
443
+        'PGK' => __('Papua New Guinean Kina', 'invoicing'),
444
+        'PHP' => __('Philippine Peso', 'invoicing'),
445
+        'PKR' => __('Pakistani Rupee', 'invoicing'),
446
+        'PLN' => __('Polish Zloty', 'invoicing'),
447
+        'PRB' => __('Transnistrian Ruble', 'invoicing'),
448
+        'PYG' => __('Paraguayan Guarani', 'invoicing'),
449
+        'QAR' => __('Qatari Riyal', 'invoicing'),
450
+        'RON' => __('Romanian Leu', 'invoicing'),
451
+        'RSD' => __('Serbian Dinar', 'invoicing'),
452
+        'RUB' => __('Russian Ruble', 'invoicing'),
453
+        'RWF' => __('Rwandan Franc', 'invoicing'),
454
+        'SAR' => __('Saudi Riyal', 'invoicing'),
455
+        'SBD' => __('Solomon Islands Dollar', 'invoicing'),
456
+        'SCR' => __('Seychellois Rupee', 'invoicing'),
457
+        'SDG' => __('Sudanese Pound', 'invoicing'),
458
+        'SEK' => __('Swedish Krona', 'invoicing'),
459
+        'SGD' => __('Singapore Dollar', 'invoicing'),
460
+        'SHP' => __('Saint Helena Pound', 'invoicing'),
461
+        'SLL' => __('Sierra Leonean Leone', 'invoicing'),
462
+        'SOS' => __('Somali Shilling', 'invoicing'),
463
+        'SRD' => __('Surinamese Dollar', 'invoicing'),
464
+        'SSP' => __('South Sudanese Pound', 'invoicing'),
465
+        'STD' => __('Sao Tomean Dobra', 'invoicing'),
466
+        'SYP' => __('Syrian Pound', 'invoicing'),
467
+        'SZL' => __('Swazi Lilangeni', 'invoicing'),
468
+        'THB' => __('Thai Baht', 'invoicing'),
469
+        'TJS' => __('Tajikistani Somoni', 'invoicing'),
470
+        'TMT' => __('Turkmenistan Manat', 'invoicing'),
471
+        'TND' => __('Tunisian Dinar', 'invoicing'),
472
+        'TOP' => __('Tongan Pa&#x2bb;anga', 'invoicing'),
473
+        'TRY' => __('Turkish Lira', 'invoicing'),
474
+        'TTD' => __('Trinidad and Tobago Dollar', 'invoicing'),
475
+        'TWD' => __('New Taiwan Dollar', 'invoicing'),
476
+        'TZS' => __('Tanzanian Shilling', 'invoicing'),
477
+        'UAH' => __('Ukrainian Hryvnia', 'invoicing'),
478
+        'UGX' => __('Ugandan Shilling', 'invoicing'),
479
+        'UYU' => __('Uruguayan Peso', 'invoicing'),
480
+        'UZS' => __('Uzbekistani Som', 'invoicing'),
481
+        'VEF' => __('Venezuelan Bol&iacute;var', 'invoicing'),
482
+        'VND' => __('Vietnamese Dong', 'invoicing'),
483
+        'VUV' => __('Vanuatu Vatu', 'invoicing'),
484
+        'WST' => __('Samoan Tala', 'invoicing'),
485
+        'XAF' => __('Central African CFA Franc', 'invoicing'),
486
+        'XCD' => __('East Caribbean Dollar', 'invoicing'),
487
+        'XOF' => __('West African CFA Franc', 'invoicing'),
488
+        'XPF' => __('CFP Franc', 'invoicing'),
489
+        'YER' => __('Yemeni Rial', 'invoicing'),
490
+        'ZAR' => __('South African Rand', 'invoicing'),
491
+        'ZMW' => __('Zambian Kwacha', 'invoicing'),
492 492
     );
493 493
     
494 494
     //asort( $currencies ); // this
495 495
 
496
-    return apply_filters( 'wpinv_currencies', $currencies );
496
+    return apply_filters('wpinv_currencies', $currencies);
497 497
 }
498 498
 
499
-function wpinv_price( $amount = '', $currency = '' ) {
500
-    if( empty( $currency ) ) {
499
+function wpinv_price($amount = '', $currency = '') {
500
+    if (empty($currency)) {
501 501
         $currency = wpinv_get_currency();
502 502
     }
503 503
 
@@ -505,14 +505,14 @@  discard block
 block discarded – undo
505 505
 
506 506
     $negative = $amount < 0;
507 507
 
508
-    if ( $negative ) {
509
-        $amount = substr( $amount, 1 );
508
+    if ($negative) {
509
+        $amount = substr($amount, 1);
510 510
     }
511 511
 
512
-    $symbol = wpinv_currency_symbol( $currency );
512
+    $symbol = wpinv_currency_symbol($currency);
513 513
 
514
-    if ( $position == 'left' || $position == 'left_space' ) {
515
-        switch ( $currency ) {
514
+    if ($position == 'left' || $position == 'left_space') {
515
+        switch ($currency) {
516 516
             case "GBP" :
517 517
             case "BRL" :
518 518
             case "EUR" :
@@ -524,15 +524,15 @@  discard block
 block discarded – undo
524 524
             case "NZD" :
525 525
             case "SGD" :
526 526
             case "JPY" :
527
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
527
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
528 528
                 break;
529 529
             default :
530 530
                 //$price = $currency . ' ' . $amount;
531
-                $price = $position == 'left_space' ? $symbol . ' ' .  $amount : $symbol . $amount;
531
+                $price = $position == 'left_space' ? $symbol . ' ' . $amount : $symbol . $amount;
532 532
                 break;
533 533
         }
534 534
     } else {
535
-        switch ( $currency ) {
535
+        switch ($currency) {
536 536
             case "GBP" :
537 537
             case "BRL" :
538 538
             case "EUR" :
@@ -543,83 +543,83 @@  discard block
 block discarded – undo
543 543
             case "MXN" :
544 544
             case "SGD" :
545 545
             case "JPY" :
546
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
546
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
547 547
                 break;
548 548
             default :
549 549
                 //$price = $amount . ' ' . $currency;
550
-                $price = $position == 'right_space' ? $amount . ' ' .  $symbol : $amount . $symbol;
550
+                $price = $position == 'right_space' ? $amount . ' ' . $symbol : $amount . $symbol;
551 551
                 break;
552 552
         }
553 553
     }
554 554
     
555
-    if ( $negative ) {
555
+    if ($negative) {
556 556
         $price = '-' . $price;
557 557
     }
558 558
     
559
-    $price = apply_filters( 'wpinv_' . strtolower( $currency ) . '_currency_filter_' . $position, $price, $currency, $amount );
559
+    $price = apply_filters('wpinv_' . strtolower($currency) . '_currency_filter_' . $position, $price, $currency, $amount);
560 560
 
561 561
     return $price;
562 562
 }
563 563
 
564
-function wpinv_format_amount( $amount, $decimals = NULL, $calculate = false ) {
564
+function wpinv_format_amount($amount, $decimals = NULL, $calculate = false) {
565 565
     $thousands_sep = wpinv_thousands_separator();
566 566
     $decimal_sep   = wpinv_decimal_separator();
567 567
 
568
-    if ( $decimals === NULL ) {
568
+    if ($decimals === NULL) {
569 569
         $decimals = wpinv_decimals();
570 570
     }
571 571
 
572
-    if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) {
573
-        $whole = substr( $amount, 0, $sep_found );
574
-        $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
572
+    if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) {
573
+        $whole = substr($amount, 0, $sep_found);
574
+        $part = substr($amount, $sep_found + 1, (strlen($amount) - 1));
575 575
         $amount = $whole . '.' . $part;
576 576
     }
577 577
 
578
-    if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
579
-        $amount = str_replace( ',', '', $amount );
578
+    if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) {
579
+        $amount = str_replace(',', '', $amount);
580 580
     }
581 581
 
582
-    if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) {
583
-        $amount = str_replace( ' ', '', $amount );
582
+    if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) {
583
+        $amount = str_replace(' ', '', $amount);
584 584
     }
585 585
 
586
-    if ( empty( $amount ) ) {
586
+    if (empty($amount)) {
587 587
         $amount = 0;
588 588
     }
589 589
     
590
-    $decimals  = apply_filters( 'wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate );
591
-    $formatted = number_format( (float)$amount, $decimals, $decimal_sep, $thousands_sep );
590
+    $decimals  = apply_filters('wpinv_amount_format_decimals', $decimals ? $decimals : 0, $amount, $calculate);
591
+    $formatted = number_format((float)$amount, $decimals, $decimal_sep, $thousands_sep);
592 592
     
593
-    if ( $calculate ) {
594
-        if ( $thousands_sep === "," ) {
595
-            $formatted = str_replace( ",", "", $formatted );
593
+    if ($calculate) {
594
+        if ($thousands_sep === ",") {
595
+            $formatted = str_replace(",", "", $formatted);
596 596
         }
597 597
         
598
-        if ( $decimal_sep === "," ) {
599
-            $formatted = str_replace( ",", ".", $formatted );
598
+        if ($decimal_sep === ",") {
599
+            $formatted = str_replace(",", ".", $formatted);
600 600
         }
601 601
     }
602 602
 
603
-    return apply_filters( 'wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate );
603
+    return apply_filters('wpinv_amount_format', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $calculate);
604 604
 }
605
-add_filter( 'wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1 );
605
+add_filter('wpinv_amount_format_decimals', 'wpinv_currency_decimal_filter', 10, 1);
606 606
 
607
-function wpinv_sanitize_key( $key ) {
607
+function wpinv_sanitize_key($key) {
608 608
     $raw_key = $key;
609
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
609
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
610 610
 
611
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
611
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
612 612
 }
613 613
 
614
-function wpinv_get_file_extension( $str ) {
615
-    $parts = explode( '.', $str );
616
-    return end( $parts );
614
+function wpinv_get_file_extension($str) {
615
+    $parts = explode('.', $str);
616
+    return end($parts);
617 617
 }
618 618
 
619
-function wpinv_string_is_image_url( $str ) {
620
-    $ext = wpinv_get_file_extension( $str );
619
+function wpinv_string_is_image_url($str) {
620
+    $ext = wpinv_get_file_extension($str);
621 621
 
622
-    switch ( strtolower( $ext ) ) {
622
+    switch (strtolower($ext)) {
623 623
         case 'jpeg';
624 624
         case 'jpg';
625 625
             $return = true;
@@ -635,32 +635,32 @@  discard block
 block discarded – undo
635 635
             break;
636 636
     }
637 637
 
638
-    return (bool)apply_filters( 'wpinv_string_is_image', $return, $str );
638
+    return (bool)apply_filters('wpinv_string_is_image', $return, $str);
639 639
 }
640 640
 
641
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
642
-    $should_log = apply_filters( 'wpinv_log_errors', WP_DEBUG );
641
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
642
+    $should_log = apply_filters('wpinv_log_errors', WP_DEBUG);
643 643
     
644
-    if ( true === $should_log ) {
644
+    if (true === $should_log) {
645 645
         $label = '';
646
-        if ( $file && $file !== '' ) {
647
-            $label .= basename( $file ) . ( $line ? '(' . $line . ')' : '' );
646
+        if ($file && $file !== '') {
647
+            $label .= basename($file) . ($line ? '(' . $line . ')' : '');
648 648
         }
649 649
         
650
-        if ( $title && $title !== '' ) {
650
+        if ($title && $title !== '') {
651 651
             $label = $label !== '' ? $label . ' ' : '';
652 652
             $label .= $title . ' ';
653 653
         }
654 654
         
655
-        $label = $label !== '' ? trim( $label ) . ' : ' : '';
655
+        $label = $label !== '' ? trim($label) . ' : ' : '';
656 656
         
657
-        if ( is_array( $log ) || is_object( $log ) ) {
658
-            error_log( $label . print_r( $log, true ) );
657
+        if (is_array($log) || is_object($log)) {
658
+            error_log($label . print_r($log, true));
659 659
         } else {
660
-            error_log( $label . $log );
660
+            error_log($label . $log);
661 661
         }
662 662
         
663
-        if ( $exit ) {
663
+        if ($exit) {
664 664
             exit;
665 665
         }
666 666
     }
@@ -668,65 +668,65 @@  discard block
 block discarded – undo
668 668
 
669 669
 function wpinv_is_ajax_disabled() {
670 670
     $retval = false;
671
-    return apply_filters( 'wpinv_is_ajax_disabled', $retval );
671
+    return apply_filters('wpinv_is_ajax_disabled', $retval);
672 672
 }
673 673
 
674
-function wpinv_get_current_page_url( $nocache = false ) {
674
+function wpinv_get_current_page_url($nocache = false) {
675 675
     global $wp;
676 676
 
677
-    if ( get_option( 'permalink_structure' ) ) {
678
-        $base = trailingslashit( home_url( $wp->request ) );
677
+    if (get_option('permalink_structure')) {
678
+        $base = trailingslashit(home_url($wp->request));
679 679
     } else {
680
-        $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
681
-        $base = remove_query_arg( array( 'post_type', 'name' ), $base );
680
+        $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
681
+        $base = remove_query_arg(array('post_type', 'name'), $base);
682 682
     }
683 683
 
684 684
     $scheme = is_ssl() ? 'https' : 'http';
685
-    $uri    = set_url_scheme( $base, $scheme );
685
+    $uri    = set_url_scheme($base, $scheme);
686 686
 
687
-    if ( is_front_page() ) {
688
-        $uri = home_url( '/' );
689
-    } elseif ( wpinv_is_checkout( array(), false ) ) {
687
+    if (is_front_page()) {
688
+        $uri = home_url('/');
689
+    } elseif (wpinv_is_checkout(array(), false)) {
690 690
         $uri = wpinv_get_checkout_uri();
691 691
     }
692 692
 
693
-    $uri = apply_filters( 'wpinv_get_current_page_url', $uri );
693
+    $uri = apply_filters('wpinv_get_current_page_url', $uri);
694 694
 
695
-    if ( $nocache ) {
696
-        $uri = wpinv_add_cache_busting( $uri );
695
+    if ($nocache) {
696
+        $uri = wpinv_add_cache_busting($uri);
697 697
     }
698 698
 
699 699
     return $uri;
700 700
 }
701 701
 
702 702
 function wpinv_get_php_arg_separator_output() {
703
-	return ini_get( 'arg_separator.output' );
703
+	return ini_get('arg_separator.output');
704 704
 }
705 705
 
706
-function wpinv_rgb_from_hex( $color ) {
707
-    $color = str_replace( '#', '', $color );
706
+function wpinv_rgb_from_hex($color) {
707
+    $color = str_replace('#', '', $color);
708 708
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
709
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
709
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
710 710
 
711 711
     $rgb      = array();
712
-    $rgb['R'] = hexdec( $color{0}.$color{1} );
713
-    $rgb['G'] = hexdec( $color{2}.$color{3} );
714
-    $rgb['B'] = hexdec( $color{4}.$color{5} );
712
+    $rgb['R'] = hexdec($color{0} . $color{1} );
713
+    $rgb['G'] = hexdec($color{2} . $color{3} );
714
+    $rgb['B'] = hexdec($color{4} . $color{5} );
715 715
 
716 716
     return $rgb;
717 717
 }
718 718
 
719
-function wpinv_hex_darker( $color, $factor = 30 ) {
720
-    $base  = wpinv_rgb_from_hex( $color );
719
+function wpinv_hex_darker($color, $factor = 30) {
720
+    $base  = wpinv_rgb_from_hex($color);
721 721
     $color = '#';
722 722
 
723
-    foreach ( $base as $k => $v ) {
723
+    foreach ($base as $k => $v) {
724 724
         $amount      = $v / 100;
725
-        $amount      = round( $amount * $factor );
725
+        $amount      = round($amount * $factor);
726 726
         $new_decimal = $v - $amount;
727 727
 
728
-        $new_hex_component = dechex( $new_decimal );
729
-        if ( strlen( $new_hex_component ) < 2 ) {
728
+        $new_hex_component = dechex($new_decimal);
729
+        if (strlen($new_hex_component) < 2) {
730 730
             $new_hex_component = "0" . $new_hex_component;
731 731
         }
732 732
         $color .= $new_hex_component;
@@ -735,18 +735,18 @@  discard block
 block discarded – undo
735 735
     return $color;
736 736
 }
737 737
 
738
-function wpinv_hex_lighter( $color, $factor = 30 ) {
739
-    $base  = wpinv_rgb_from_hex( $color );
738
+function wpinv_hex_lighter($color, $factor = 30) {
739
+    $base  = wpinv_rgb_from_hex($color);
740 740
     $color = '#';
741 741
 
742
-    foreach ( $base as $k => $v ) {
742
+    foreach ($base as $k => $v) {
743 743
         $amount      = 255 - $v;
744 744
         $amount      = $amount / 100;
745
-        $amount      = round( $amount * $factor );
745
+        $amount      = round($amount * $factor);
746 746
         $new_decimal = $v + $amount;
747 747
 
748
-        $new_hex_component = dechex( $new_decimal );
749
-        if ( strlen( $new_hex_component ) < 2 ) {
748
+        $new_hex_component = dechex($new_decimal);
749
+        if (strlen($new_hex_component) < 2) {
750 750
             $new_hex_component = "0" . $new_hex_component;
751 751
         }
752 752
         $color .= $new_hex_component;
@@ -755,22 +755,22 @@  discard block
 block discarded – undo
755 755
     return $color;
756 756
 }
757 757
 
758
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
759
-    $hex = str_replace( '#', '', $color );
758
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
759
+    $hex = str_replace('#', '', $color);
760 760
 
761
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
762
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
763
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
761
+    $c_r = hexdec(substr($hex, 0, 2));
762
+    $c_g = hexdec(substr($hex, 2, 2));
763
+    $c_b = hexdec(substr($hex, 4, 2));
764 764
 
765
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
765
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
766 766
 
767 767
     return $brightness > 155 ? $dark : $light;
768 768
 }
769 769
 
770
-function wpinv_format_hex( $hex ) {
771
-    $hex = trim( str_replace( '#', '', $hex ) );
770
+function wpinv_format_hex($hex) {
771
+    $hex = trim(str_replace('#', '', $hex));
772 772
 
773
-    if ( strlen( $hex ) == 3 ) {
773
+    if (strlen($hex) == 3) {
774 774
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
775 775
     }
776 776
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
791 791
  * @return string
792 792
  */
793
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
794
-    if ( function_exists( 'mb_strimwidth' ) ) {
795
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
793
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
794
+    if (function_exists('mb_strimwidth')) {
795
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
796 796
     }
797 797
     
798
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
798
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
799 799
 }
800 800
 
801 801
 /**
@@ -807,28 +807,28 @@  discard block
 block discarded – undo
807 807
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
808 808
  * @return int Returns the number of characters in string.
809 809
  */
810
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
811
-    if ( function_exists( 'mb_strlen' ) ) {
812
-        return mb_strlen( $str, $encoding );
810
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
811
+    if (function_exists('mb_strlen')) {
812
+        return mb_strlen($str, $encoding);
813 813
     }
814 814
         
815
-    return strlen( $str );
815
+    return strlen($str);
816 816
 }
817 817
 
818
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
819
-    if ( function_exists( 'mb_strtolower' ) ) {
820
-        return mb_strtolower( $str, $encoding );
818
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
819
+    if (function_exists('mb_strtolower')) {
820
+        return mb_strtolower($str, $encoding);
821 821
     }
822 822
     
823
-    return strtolower( $str );
823
+    return strtolower($str);
824 824
 }
825 825
 
826
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
827
-    if ( function_exists( 'mb_strtoupper' ) ) {
828
-        return mb_strtoupper( $str, $encoding );
826
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
827
+    if (function_exists('mb_strtoupper')) {
828
+        return mb_strtoupper($str, $encoding);
829 829
     }
830 830
     
831
-    return strtoupper( $str );
831
+    return strtoupper($str);
832 832
 }
833 833
 
834 834
 /**
@@ -842,12 +842,12 @@  discard block
 block discarded – undo
842 842
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
843 843
  * @return int Returns the position of the first occurrence of search in the string.
844 844
  */
845
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
846
-    if ( function_exists( 'mb_strpos' ) ) {
847
-        return mb_strpos( $str, $find, $offset, $encoding );
845
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
846
+    if (function_exists('mb_strpos')) {
847
+        return mb_strpos($str, $find, $offset, $encoding);
848 848
     }
849 849
         
850
-    return strpos( $str, $find, $offset );
850
+    return strpos($str, $find, $offset);
851 851
 }
852 852
 
853 853
 /**
@@ -861,12 +861,12 @@  discard block
 block discarded – undo
861 861
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
862 862
  * @return int Returns the position of the last occurrence of search.
863 863
  */
864
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
865
-    if ( function_exists( 'mb_strrpos' ) ) {
866
-        return mb_strrpos( $str, $find, $offset, $encoding );
864
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
865
+    if (function_exists('mb_strrpos')) {
866
+        return mb_strrpos($str, $find, $offset, $encoding);
867 867
     }
868 868
         
869
-    return strrpos( $str, $find, $offset );
869
+    return strrpos($str, $find, $offset);
870 870
 }
871 871
 
872 872
 /**
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
882 882
  * @return string
883 883
  */
884
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
885
-    if ( function_exists( 'mb_substr' ) ) {
886
-        if ( $length === null ) {
887
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
884
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
885
+    if (function_exists('mb_substr')) {
886
+        if ($length === null) {
887
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
888 888
         } else {
889
-            return mb_substr( $str, $start, $length, $encoding );
889
+            return mb_substr($str, $start, $length, $encoding);
890 890
         }
891 891
     }
892 892
         
893
-    return substr( $str, $start, $length );
893
+    return substr($str, $start, $length);
894 894
 }
895 895
 
896 896
 /**
@@ -902,48 +902,48 @@  discard block
 block discarded – undo
902 902
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
903 903
  * @return string The width of string.
904 904
  */
905
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
906
-    if ( function_exists( 'mb_strwidth' ) ) {
907
-        return mb_strwidth( $str, $encoding );
905
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
906
+    if (function_exists('mb_strwidth')) {
907
+        return mb_strwidth($str, $encoding);
908 908
     }
909 909
     
910
-    return wpinv_utf8_strlen( $str, $encoding );
910
+    return wpinv_utf8_strlen($str, $encoding);
911 911
 }
912 912
 
913
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
914
-    if ( function_exists( 'mb_strlen' ) ) {
915
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
913
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
914
+    if (function_exists('mb_strlen')) {
915
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
916 916
         $str_end = "";
917 917
         
918
-        if ( $lower_str_end ) {
919
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
918
+        if ($lower_str_end) {
919
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
920 920
         } else {
921
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
921
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
922 922
         }
923 923
 
924 924
         return $first_letter . $str_end;
925 925
     }
926 926
     
927
-    return ucfirst( $str );
927
+    return ucfirst($str);
928 928
 }
929 929
 
930
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
931
-    if ( function_exists( 'mb_convert_case' ) ) {
932
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
930
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
931
+    if (function_exists('mb_convert_case')) {
932
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
933 933
     }
934 934
     
935
-    return ucwords( $str );
935
+    return ucwords($str);
936 936
 }
937 937
 
938
-function wpinv_period_in_days( $period, $unit ) {
939
-    $period = absint( $period );
938
+function wpinv_period_in_days($period, $unit) {
939
+    $period = absint($period);
940 940
     
941
-    if ( $period > 0 ) {
942
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
941
+    if ($period > 0) {
942
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
943 943
             $period = $period * 7;
944
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
944
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
945 945
             $period = $period * 30;
946
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
946
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
947 947
             $period = $period * 365;
948 948
         }
949 949
     }
@@ -951,14 +951,14 @@  discard block
 block discarded – undo
951 951
     return $period;
952 952
 }
953 953
 
954
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
955
-    if ( function_exists( 'cal_days_in_month' ) ) {
956
-        return cal_days_in_month( $calendar, $month, $year );
954
+function wpinv_cal_days_in_month($calendar, $month, $year) {
955
+    if (function_exists('cal_days_in_month')) {
956
+        return cal_days_in_month($calendar, $month, $year);
957 957
     }
958 958
 
959 959
     // Fallback in case the calendar extension is not loaded in PHP
960 960
     // Only supports Gregorian calendar
961
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
961
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
962 962
 }
963 963
 
964 964
 /**
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
  *
970 970
  * @return string
971 971
  */
972
-function wpi_help_tip( $tip, $allow_html = false ) {
973
-    if ( $allow_html ) {
974
-        $tip = wpi_sanitize_tooltip( $tip );
972
+function wpi_help_tip($tip, $allow_html = false) {
973
+    if ($allow_html) {
974
+        $tip = wpi_sanitize_tooltip($tip);
975 975
     } else {
976
-        $tip = esc_attr( $tip );
976
+        $tip = esc_attr($tip);
977 977
     }
978 978
 
979 979
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
  * @param string $var
988 988
  * @return string
989 989
  */
990
-function wpi_sanitize_tooltip( $var ) {
991
-    return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
990
+function wpi_sanitize_tooltip($var) {
991
+    return htmlspecialchars(wp_kses(html_entity_decode($var), array(
992 992
         'br'     => array(),
993 993
         'em'     => array(),
994 994
         'strong' => array(),
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
         'li'     => array(),
999 999
         'ol'     => array(),
1000 1000
         'p'      => array(),
1001
-    ) ) );
1001
+    )));
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
  */
1009 1009
 function wpinv_get_screen_ids() {
1010 1010
 
1011
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
1011
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
1012 1012
 
1013 1013
     $screen_ids = array(
1014 1014
         'toplevel_page_' . $screen_id,
@@ -1026,5 +1026,5 @@  discard block
 block discarded – undo
1026 1026
         'invoicing_page_wpi-addons',
1027 1027
     );
1028 1028
 
1029
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
1029
+    return apply_filters('wpinv_screen_ids', $screen_ids);
1030 1030
 }
1031 1031
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +582 added lines, -582 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -30,381 +30,381 @@  discard block
 block discarded – undo
30 30
         'wpinv_fully_refunded',
31 31
         'wpinv_partially_refunded',
32 32
         'wpinv_new_invoice_note'
33
-    ) );
33
+    ));
34 34
 
35
-    foreach ( $email_actions as $action ) {
36
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
35
+    foreach ($email_actions as $action) {
36
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
37 37
     }
38 38
 }
39
-add_action( 'init', 'wpinv_init_transactional_emails' );
39
+add_action('init', 'wpinv_init_transactional_emails');
40 40
 
41 41
 // New invoice email
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
46
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
47
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
42
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
46
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
47
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
48 48
 
49 49
 // Cancelled invoice email
50
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
51
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
50
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
51
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
52 52
 
53 53
 // Failed invoice email
54
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
55
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
54
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
55
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
56 56
 
57 57
 // On hold invoice email
58
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
59
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
58
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
59
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
60 60
 
61 61
 // Processing invoice email
62
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
62
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
63 63
 
64 64
 // Paid invoice email
65
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
65
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
66 66
 
67 67
 // Refunded invoice email
68
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
69
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
70
-add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
71
-add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' );
68
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
69
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
70
+add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
71
+add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification');
72 72
 
73 73
 // Invoice note
74
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
74
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
75 75
 
76
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
77
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
78
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
79
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
80
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
76
+add_action('wpinv_email_header', 'wpinv_email_header');
77
+add_action('wpinv_email_footer', 'wpinv_email_footer');
78
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
79
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
80
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
81 81
 
82 82
 function wpinv_send_transactional_email() {
83 83
     $args       = func_get_args();
84 84
     $function   = current_filter() . '_notification';
85
-    do_action_ref_array( $function, $args );
85
+    do_action_ref_array($function, $args);
86 86
 }
87 87
 
88
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
88
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
89 89
     $email_type = 'new_invoice';
90
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
90
+    if (!wpinv_email_is_enabled($email_type)) {
91 91
         return false;
92 92
     }
93 93
 
94
-    $invoice = wpinv_get_invoice( $invoice_id );
95
-    if ( empty( $invoice ) ) {
94
+    $invoice = wpinv_get_invoice($invoice_id);
95
+    if (empty($invoice)) {
96 96
         return false;
97 97
     }
98 98
 
99
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
99
+    if (!("wpi_invoice" === $invoice->post_type)) {
100 100
         return false;
101 101
     }
102 102
 
103
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
104
-    if ( !is_email( $recipient ) ) {
103
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
104
+    if (!is_email($recipient)) {
105 105
         return false;
106 106
     }
107 107
 
108
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
108
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
109 109
 
110
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
111
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
112
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
113
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
114
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
110
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
111
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
112
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
113
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
114
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
115 115
 
116
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
116
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
117 117
             'invoice'       => $invoice,
118 118
             'email_type'    => $email_type,
119 119
             'email_heading' => $email_heading,
120 120
             'sent_to_admin' => true,
121 121
             'plain_text'    => false,
122 122
             'message_body'  => $message_body,
123
-        ) );
123
+        ));
124 124
 
125
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
125
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
126 126
 
127
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
127
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
128 128
 
129 129
     return $sent;
130 130
 }
131 131
 
132
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
132
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
133 133
     $email_type = 'cancelled_invoice';
134
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
134
+    if (!wpinv_email_is_enabled($email_type)) {
135 135
         return false;
136 136
     }
137 137
 
138
-    $invoice = wpinv_get_invoice( $invoice_id );
139
-    if ( empty( $invoice ) ) {
138
+    $invoice = wpinv_get_invoice($invoice_id);
139
+    if (empty($invoice)) {
140 140
         return false;
141 141
     }
142 142
 
143
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
143
+    if (!("wpi_invoice" === $invoice->post_type)) {
144 144
         return false;
145 145
     }
146 146
 
147
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
148
-    if ( !is_email( $recipient ) ) {
147
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
148
+    if (!is_email($recipient)) {
149 149
         return false;
150 150
     }
151 151
 
152
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
152
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
153 153
 
154
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
155
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
156
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
157
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
158
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
154
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
155
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
156
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
157
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
158
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
159 159
 
160
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
160
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
161 161
             'invoice'       => $invoice,
162 162
             'email_type'    => $email_type,
163 163
             'email_heading' => $email_heading,
164 164
             'sent_to_admin' => true,
165 165
             'plain_text'    => false,
166 166
             'message_body'  => $message_body,
167
-        ) );
167
+        ));
168 168
 
169
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
169
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
170 170
 
171
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
171
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
172 172
 
173 173
     return $sent;
174 174
 }
175 175
 
176
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
176
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
177 177
     $email_type = 'failed_invoice';
178
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
178
+    if (!wpinv_email_is_enabled($email_type)) {
179 179
         return false;
180 180
     }
181 181
     
182
-    $invoice = wpinv_get_invoice( $invoice_id );
183
-    if ( empty( $invoice ) ) {
182
+    $invoice = wpinv_get_invoice($invoice_id);
183
+    if (empty($invoice)) {
184 184
         return false;
185 185
     }
186 186
 
187
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
187
+    if (!("wpi_invoice" === $invoice->post_type)) {
188 188
         return false;
189 189
     }
190 190
 
191
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
192
-    if ( !is_email( $recipient ) ) {
191
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
192
+    if (!is_email($recipient)) {
193 193
         return false;
194 194
     }
195 195
 
196
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true );
196
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true);
197 197
 
198
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
199
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
200
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
201
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
202
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
198
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
199
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
200
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
201
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
202
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
203 203
     
204
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
204
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
205 205
             'invoice'       => $invoice,
206 206
             'email_type'    => $email_type,
207 207
             'email_heading' => $email_heading,
208 208
             'sent_to_admin' => true,
209 209
             'plain_text'    => false,
210 210
             'message_body'  => $message_body,
211
-        ) );
211
+        ));
212 212
 
213
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
213
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
214 214
 
215
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true );
215
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true);
216 216
 
217 217
     return $sent;
218 218
 }
219 219
 
220
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
220
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
221 221
     $email_type = 'onhold_invoice';
222
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
222
+    if (!wpinv_email_is_enabled($email_type)) {
223 223
         return false;
224 224
     }
225 225
 
226
-    $invoice = wpinv_get_invoice( $invoice_id );
227
-    if ( empty( $invoice ) ) {
226
+    $invoice = wpinv_get_invoice($invoice_id);
227
+    if (empty($invoice)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
231
+    if (!("wpi_invoice" === $invoice->post_type)) {
232 232
         return false;
233 233
     }
234 234
 
235
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
236
-    if ( !is_email( $recipient ) ) {
235
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
236
+    if (!is_email($recipient)) {
237 237
         return false;
238 238
     }
239 239
 
240
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
240
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
241 241
 
242
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
243
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
244
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
245
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
246
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
242
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
243
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
244
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
245
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
246
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
247 247
     
248
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
248
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
249 249
             'invoice'       => $invoice,
250 250
             'email_type'    => $email_type,
251 251
             'email_heading' => $email_heading,
252 252
             'sent_to_admin' => false,
253 253
             'plain_text'    => false,
254 254
             'message_body'  => $message_body,
255
-        ) );
255
+        ));
256 256
     
257
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
257
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
258 258
     
259
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
260
-        $recipient  = wpinv_get_admin_email();
261
-        $subject    .= ' - ADMIN BCC COPY';
262
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
259
+    if (wpinv_mail_admin_bcc_active($email_type)) {
260
+        $recipient = wpinv_get_admin_email();
261
+        $subject .= ' - ADMIN BCC COPY';
262
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
263 263
     }
264 264
 
265
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
265
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
266 266
 
267 267
     return $sent;
268 268
 }
269 269
 
270
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
270
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
271 271
     $email_type = 'processing_invoice';
272
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
272
+    if (!wpinv_email_is_enabled($email_type)) {
273 273
         return false;
274 274
     }
275 275
 
276
-    $invoice = wpinv_get_invoice( $invoice_id );
277
-    if ( empty( $invoice ) ) {
276
+    $invoice = wpinv_get_invoice($invoice_id);
277
+    if (empty($invoice)) {
278 278
         return false;
279 279
     }
280 280
 
281
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
281
+    if (!("wpi_invoice" === $invoice->post_type)) {
282 282
         return false;
283 283
     }
284 284
 
285
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
286
-    if ( !is_email( $recipient ) ) {
285
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
286
+    if (!is_email($recipient)) {
287 287
         return false;
288 288
     }
289 289
 
290
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
290
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
291 291
 
292 292
     $search                     = array();
293 293
     $search['invoice_number']   = '{invoice_number}';
294 294
     $search['invoice_date']     = '{invoice_date}';
295 295
     $search['name']             = '{name}';
296 296
 
297
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
298
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
299
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
300
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
301
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
297
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
298
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
299
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
300
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
301
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
302 302
     
303
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
303
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
304 304
             'invoice'       => $invoice,
305 305
             'email_type'    => $email_type,
306 306
             'email_heading' => $email_heading,
307 307
             'sent_to_admin' => false,
308 308
             'plain_text'    => false,
309 309
             'message_body'  => $message_body,
310
-        ) );
310
+        ));
311 311
 
312
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
312
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
313 313
 
314
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
315
-        $recipient  = wpinv_get_admin_email();
316
-        $subject    .= ' - ADMIN BCC COPY';
317
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
314
+    if (wpinv_mail_admin_bcc_active($email_type)) {
315
+        $recipient = wpinv_get_admin_email();
316
+        $subject .= ' - ADMIN BCC COPY';
317
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
318 318
     }
319 319
 
320
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
320
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
321 321
 
322 322
     return $sent;
323 323
 }
324 324
 
325
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
325
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
326 326
     $email_type = 'completed_invoice';
327
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
327
+    if (!wpinv_email_is_enabled($email_type)) {
328 328
         return false;
329 329
     }
330 330
 
331
-    $invoice = wpinv_get_invoice( $invoice_id );
332
-    if ( empty( $invoice ) ) {
331
+    $invoice = wpinv_get_invoice($invoice_id);
332
+    if (empty($invoice)) {
333 333
         return false;
334 334
     }
335 335
 
336
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
336
+    if (!("wpi_invoice" === $invoice->post_type)) {
337 337
         return false;
338 338
     }
339 339
 
340
-    if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){
340
+    if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) {
341 341
         return false;
342 342
     }
343 343
 
344
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
345
-    if ( !is_email( $recipient ) ) {
344
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
345
+    if (!is_email($recipient)) {
346 346
         return false;
347 347
     }
348 348
 
349
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
349
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
350 350
 
351
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
352
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
353
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
354
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
355
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
351
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
352
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
353
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
354
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
355
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
356 356
 
357
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
357
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
358 358
             'invoice'       => $invoice,
359 359
             'email_type'    => $email_type,
360 360
             'email_heading' => $email_heading,
361 361
             'sent_to_admin' => false,
362 362
             'plain_text'    => false,
363 363
             'message_body'  => $message_body,
364
-        ) );
364
+        ));
365 365
 
366
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
366
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
367 367
 
368
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
369
-        $recipient  = wpinv_get_admin_email();
370
-        $subject    .= ' - ADMIN BCC COPY';
371
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
368
+    if (wpinv_mail_admin_bcc_active($email_type)) {
369
+        $recipient = wpinv_get_admin_email();
370
+        $subject .= ' - ADMIN BCC COPY';
371
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
372 372
     }
373 373
 
374
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
374
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
375 375
 
376 376
     return $sent;
377 377
 }
378 378
 
379
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
379
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
380 380
     $email_type = 'refunded_invoice';
381
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
381
+    if (!wpinv_email_is_enabled($email_type)) {
382 382
         return false;
383 383
     }
384 384
 
385
-    $invoice = wpinv_get_invoice( $invoice_id );
386
-    if ( empty( $invoice ) ) {
385
+    $invoice = wpinv_get_invoice($invoice_id);
386
+    if (empty($invoice)) {
387 387
         return false;
388 388
     }
389 389
 
390
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
390
+    if (!("wpi_invoice" === $invoice->post_type)) {
391 391
         return false;
392 392
     }
393 393
 
394
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
395
-    if ( !is_email( $recipient ) ) {
394
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
395
+    if (!is_email($recipient)) {
396 396
         return false;
397 397
     }
398 398
 
399
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
399
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
400 400
 
401
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
402
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
403
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
404
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
405
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
401
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
402
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
403
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
404
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
405
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
406 406
 
407
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
407
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
408 408
             'invoice'           => $invoice,
409 409
             'email_type'        => $email_type,
410 410
             'email_heading'     => $email_heading,
@@ -412,50 +412,50 @@  discard block
 block discarded – undo
412 412
             'plain_text'        => false,
413 413
             'partial_refund'    => false,
414 414
             'message_body'      => $message_body,
415
-        ) );
415
+        ));
416 416
 
417
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
417
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
418 418
 
419
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
420
-        $recipient  = wpinv_get_admin_email();
421
-        $subject    .= ' - ADMIN BCC COPY';
422
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
419
+    if (wpinv_mail_admin_bcc_active($email_type)) {
420
+        $recipient = wpinv_get_admin_email();
421
+        $subject .= ' - ADMIN BCC COPY';
422
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
423 423
     }
424 424
 
425
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
425
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
426 426
 
427 427
     return $sent;
428 428
 }
429 429
 
430
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
430
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
431 431
     $email_type = 'refunded_invoice';
432
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
432
+    if (!wpinv_email_is_enabled($email_type)) {
433 433
         return false;
434 434
     }
435 435
 
436
-    $invoice = wpinv_get_invoice( $invoice_id );
437
-    if ( empty( $invoice ) ) {
436
+    $invoice = wpinv_get_invoice($invoice_id);
437
+    if (empty($invoice)) {
438 438
         return false;
439 439
     }
440 440
 
441
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
441
+    if (!("wpi_invoice" === $invoice->post_type)) {
442 442
         return false;
443 443
     }
444 444
 
445
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
446
-    if ( !is_email( $recipient ) ) {
445
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
446
+    if (!is_email($recipient)) {
447 447
         return false;
448 448
     }
449 449
 
450
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
450
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
451 451
 
452
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
453
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
454
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
455
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
456
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
452
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
453
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
454
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
455
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
456
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
457 457
 
458
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
458
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
459 459
             'invoice'           => $invoice,
460 460
             'email_type'        => $email_type,
461 461
             'email_heading'     => $email_heading,
@@ -463,95 +463,95 @@  discard block
 block discarded – undo
463 463
             'plain_text'        => false,
464 464
             'partial_refund'    => true,
465 465
             'message_body'      => $message_body,
466
-        ) );
466
+        ));
467 467
 
468
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
468
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
469 469
 
470
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
471
-        $recipient  = wpinv_get_admin_email();
472
-        $subject    .= ' - ADMIN BCC COPY';
473
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
470
+    if (wpinv_mail_admin_bcc_active($email_type)) {
471
+        $recipient = wpinv_get_admin_email();
472
+        $subject .= ' - ADMIN BCC COPY';
473
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
474 474
     }
475 475
 
476
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
476
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
477 477
 
478 478
     return $sent;
479 479
 }
480 480
 
481
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
481
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
482 482
 }
483 483
 
484
-function wpinv_user_invoice_notification( $invoice_id ) {
484
+function wpinv_user_invoice_notification($invoice_id) {
485 485
     $email_type = 'user_invoice';
486
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
486
+    if (!wpinv_email_is_enabled($email_type)) {
487 487
         return -1;
488 488
     }
489 489
 
490
-    $invoice = wpinv_get_invoice( $invoice_id );
491
-    if ( empty( $invoice ) ) {
490
+    $invoice = wpinv_get_invoice($invoice_id);
491
+    if (empty($invoice)) {
492 492
         return false;
493 493
     }
494 494
 
495
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
495
+    if (!("wpi_invoice" === $invoice->post_type)) {
496 496
         return false;
497 497
     }
498 498
 
499
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
500
-    if ( !is_email( $recipient ) ) {
499
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
500
+    if (!is_email($recipient)) {
501 501
         return false;
502 502
     }
503 503
 
504
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
504
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
505 505
 
506
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
507
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
508
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
509
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
510
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
506
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
507
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
508
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
509
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
510
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
511 511
     
512
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
512
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
513 513
             'invoice'       => $invoice,
514 514
             'email_type'    => $email_type,
515 515
             'email_heading' => $email_heading,
516 516
             'sent_to_admin' => false,
517 517
             'plain_text'    => false,
518 518
             'message_body'  => $message_body,
519
-        ) );
519
+        ));
520 520
 
521
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
521
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
522 522
 
523
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
524
-        $recipient  = wpinv_get_admin_email();
525
-        $subject    .= ' - ADMIN BCC COPY';
526
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
523
+    if (wpinv_mail_admin_bcc_active($email_type)) {
524
+        $recipient = wpinv_get_admin_email();
525
+        $subject .= ' - ADMIN BCC COPY';
526
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
527 527
     }
528 528
 
529
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
529
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
530 530
 
531
-    if ( $sent ) {
532
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
531
+    if ($sent) {
532
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
533 533
     } else {
534
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
534
+        $note = __('Fail to send invoice to the user!', 'invoicing');
535 535
     }
536 536
 
537
-    $invoice->add_note( $note, '', '', true ); // Add system note.
537
+    $invoice->add_note($note, '', '', true); // Add system note.
538 538
 
539 539
     return $sent;
540 540
 }
541 541
 
542
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
542
+function wpinv_user_note_notification($invoice_id, $args = array()) {
543 543
     $email_type = 'user_note';
544
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
544
+    if (!wpinv_email_is_enabled($email_type)) {
545 545
         return false;
546 546
     }
547 547
 
548
-    $invoice = wpinv_get_invoice( $invoice_id );
549
-    if ( empty( $invoice ) ) {
548
+    $invoice = wpinv_get_invoice($invoice_id);
549
+    if (empty($invoice)) {
550 550
         return false;
551 551
     }
552 552
 
553
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
554
-    if ( !is_email( $recipient ) ) {
553
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
554
+    if (!is_email($recipient)) {
555 555
         return false;
556 556
     }
557 557
 
@@ -559,19 +559,19 @@  discard block
 block discarded – undo
559 559
         'user_note' => ''
560 560
     );
561 561
 
562
-    $args = wp_parse_args( $args, $defaults );
562
+    $args = wp_parse_args($args, $defaults);
563 563
 
564
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
564
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
565 565
 
566
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
567
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
568
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
569
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
570
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
566
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
567
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
568
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
569
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
570
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
571 571
 
572
-    $message_body   = str_replace( '{customer_note}', $args['user_note'], $message_body );
572
+    $message_body   = str_replace('{customer_note}', $args['user_note'], $message_body);
573 573
 
574
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
574
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
575 575
             'invoice'       => $invoice,
576 576
             'email_type'    => $email_type,
577 577
             'email_heading' => $email_heading,
@@ -579,36 +579,36 @@  discard block
 block discarded – undo
579 579
             'plain_text'    => false,
580 580
             'message_body'  => $message_body,
581 581
             'customer_note' => $args['user_note']
582
-        ) );
582
+        ));
583 583
 
584
-    $content        = wpinv_email_format_text( $content, $invoice );
584
+    $content = wpinv_email_format_text($content, $invoice);
585 585
 
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
 
588
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
588
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
589 589
 
590 590
     return $sent;
591 591
 }
592 592
 
593 593
 function wpinv_mail_get_from_address() {
594
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
595
-    return sanitize_email( $from_address );
594
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
595
+    return sanitize_email($from_address);
596 596
 }
597 597
 
598 598
 function wpinv_mail_get_from_name() {
599
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
600
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
599
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
600
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
601 601
 }
602 602
 
603
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
604
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
605
-    return ( $active ? true : false );
603
+function wpinv_mail_admin_bcc_active($mail_type = '') {
604
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
605
+    return ($active ? true : false);
606 606
 }
607 607
     
608
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
609
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
608
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
609
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
610 610
 
611
-    switch ( $email_type ) {
611
+    switch ($email_type) {
612 612
         case 'html' :
613 613
             $content_type = 'text/html';
614 614
             break;
@@ -623,35 +623,35 @@  discard block
 block discarded – undo
623 623
     return $content_type;
624 624
 }
625 625
     
626
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
627
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
628
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
629
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
626
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
627
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
628
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
629
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
630 630
 
631
-    $message = wpinv_email_style_body( $message );
632
-    $message = apply_filters( 'wpinv_mail_content', $message );
631
+    $message = wpinv_email_style_body($message);
632
+    $message = apply_filters('wpinv_mail_content', $message);
633 633
 
634
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
634
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
635 635
 
636
-    if ( !$sent ) {
637
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
638
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
636
+    if (!$sent) {
637
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
638
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
639 639
     }
640 640
 
641
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
642
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
643
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
641
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
642
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
643
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
644 644
 
645 645
     return $sent;
646 646
 }
647 647
     
648 648
 function wpinv_get_emails() {
649 649
     $overdue_days_options       = array();
650
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
651
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
650
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
651
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
652 652
 
653
-    for ( $i = 2; $i <= 10; $i++ ) {
654
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
653
+    for ($i = 2; $i <= 10; $i++) {
654
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
655 655
     }
656 656
 
657 657
     // Default, built-in gateways
@@ -659,39 +659,39 @@  discard block
 block discarded – undo
659 659
             'new_invoice' => array(
660 660
             'email_new_invoice_header' => array(
661 661
                 'id'   => 'email_new_invoice_header',
662
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
663
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
662
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
663
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
664 664
                 'type' => 'header',
665 665
             ),
666 666
             'email_new_invoice_active' => array(
667 667
                 'id'   => 'email_new_invoice_active',
668
-                'name' => __( 'Enable/Disable', 'invoicing' ),
669
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
668
+                'name' => __('Enable/Disable', 'invoicing'),
669
+                'desc' => __('Enable this email notification', 'invoicing'),
670 670
                 'type' => 'checkbox',
671 671
                 'std'  => 1
672 672
             ),
673 673
             'email_new_invoice_subject' => array(
674 674
                 'id'   => 'email_new_invoice_subject',
675
-                'name' => __( 'Subject', 'invoicing' ),
676
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
675
+                'name' => __('Subject', 'invoicing'),
676
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
677 677
                 'type' => 'text',
678
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
678
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
679 679
                 'size' => 'large'
680 680
             ),
681 681
             'email_new_invoice_heading' => array(
682 682
                 'id'   => 'email_new_invoice_heading',
683
-                'name' => __( 'Email Heading', 'invoicing' ),
684
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
683
+                'name' => __('Email Heading', 'invoicing'),
684
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
685 685
                 'type' => 'text',
686
-                'std'  => __( 'New payment invoice', 'invoicing' ),
686
+                'std'  => __('New payment invoice', 'invoicing'),
687 687
                 'size' => 'large'
688 688
             ),
689 689
             'email_new_invoice_body' => array(
690 690
                 'id'   => 'email_new_invoice_body',
691
-                'name' => __( 'Email Content', 'invoicing' ),
692
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
691
+                'name' => __('Email Content', 'invoicing'),
692
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
693 693
                 'type' => 'rich_editor',
694
-                'std'  => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
694
+                'std'  => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
695 695
                 'class' => 'large',
696 696
                 'size' => '10'
697 697
             ),
@@ -699,39 +699,39 @@  discard block
 block discarded – undo
699 699
         'cancelled_invoice' => array(
700 700
             'email_cancelled_invoice_header' => array(
701 701
                 'id'   => 'email_cancelled_invoice_header',
702
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
703
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
702
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
703
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
704 704
                 'type' => 'header',
705 705
             ),
706 706
             'email_cancelled_invoice_active' => array(
707 707
                 'id'   => 'email_cancelled_invoice_active',
708
-                'name' => __( 'Enable/Disable', 'invoicing' ),
709
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
708
+                'name' => __('Enable/Disable', 'invoicing'),
709
+                'desc' => __('Enable this email notification', 'invoicing'),
710 710
                 'type' => 'checkbox',
711 711
                 'std'  => 1
712 712
             ),
713 713
             'email_cancelled_invoice_subject' => array(
714 714
                 'id'   => 'email_cancelled_invoice_subject',
715
-                'name' => __( 'Subject', 'invoicing' ),
716
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
715
+                'name' => __('Subject', 'invoicing'),
716
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
717 717
                 'type' => 'text',
718
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
718
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
719 719
                 'size' => 'large'
720 720
             ),
721 721
             'email_cancelled_invoice_heading' => array(
722 722
                 'id'   => 'email_cancelled_invoice_heading',
723
-                'name' => __( 'Email Heading', 'invoicing' ),
724
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
723
+                'name' => __('Email Heading', 'invoicing'),
724
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
725 725
                 'type' => 'text',
726
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
726
+                'std'  => __('Cancelled invoice', 'invoicing'),
727 727
                 'size' => 'large'
728 728
             ),
729 729
             'email_cancelled_invoice_body' => array(
730 730
                 'id'   => 'email_cancelled_invoice_body',
731
-                'name' => __( 'Email Content', 'invoicing' ),
732
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
731
+                'name' => __('Email Content', 'invoicing'),
732
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
733 733
                 'type' => 'rich_editor',
734
-                'std'  => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
734
+                'std'  => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
735 735
                 'class' => 'large',
736 736
                 'size' => '10'
737 737
             ),
@@ -739,39 +739,39 @@  discard block
 block discarded – undo
739 739
         'failed_invoice' => array(
740 740
             'email_failed_invoice_header' => array(
741 741
                 'id'   => 'email_failed_invoice_header',
742
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
743
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
742
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
743
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
744 744
                 'type' => 'header',
745 745
             ),
746 746
             'email_failed_invoice_active' => array(
747 747
                 'id'   => 'email_failed_invoice_active',
748
-                'name' => __( 'Enable/Disable', 'invoicing' ),
749
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
748
+                'name' => __('Enable/Disable', 'invoicing'),
749
+                'desc' => __('Enable this email notification', 'invoicing'),
750 750
                 'type' => 'checkbox',
751 751
                 'std'  => 1
752 752
             ),
753 753
             'email_failed_invoice_subject' => array(
754 754
                 'id'   => 'email_failed_invoice_subject',
755
-                'name' => __( 'Subject', 'invoicing' ),
756
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
755
+                'name' => __('Subject', 'invoicing'),
756
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
757 757
                 'type' => 'text',
758
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
758
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
759 759
                 'size' => 'large'
760 760
             ),
761 761
             'email_failed_invoice_heading' => array(
762 762
                 'id'   => 'email_failed_invoice_heading',
763
-                'name' => __( 'Email Heading', 'invoicing' ),
764
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
763
+                'name' => __('Email Heading', 'invoicing'),
764
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
765 765
                 'type' => 'text',
766
-                'std'  => __( 'Failed invoice', 'invoicing' ),
766
+                'std'  => __('Failed invoice', 'invoicing'),
767 767
                 'size' => 'large'
768 768
             ),
769 769
             'email_failed_invoice_body' => array(
770 770
                 'id'   => 'email_failed_invoice_body',
771
-                'name' => __( 'Email Content', 'invoicing' ),
772
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
771
+                'name' => __('Email Content', 'invoicing'),
772
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
773 773
                 'type' => 'rich_editor',
774
-                'std'  => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
774
+                'std'  => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
775 775
                 'class' => 'large',
776 776
                 'size' => '10'
777 777
             ),
@@ -779,46 +779,46 @@  discard block
 block discarded – undo
779 779
         'onhold_invoice' => array(
780 780
             'email_onhold_invoice_header' => array(
781 781
                 'id'   => 'email_onhold_invoice_header',
782
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
783
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
782
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
783
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
784 784
                 'type' => 'header',
785 785
             ),
786 786
             'email_onhold_invoice_active' => array(
787 787
                 'id'   => 'email_onhold_invoice_active',
788
-                'name' => __( 'Enable/Disable', 'invoicing' ),
789
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
788
+                'name' => __('Enable/Disable', 'invoicing'),
789
+                'desc' => __('Enable this email notification', 'invoicing'),
790 790
                 'type' => 'checkbox',
791 791
                 'std'  => 1
792 792
             ),
793 793
             'email_onhold_invoice_subject' => array(
794 794
                 'id'   => 'email_onhold_invoice_subject',
795
-                'name' => __( 'Subject', 'invoicing' ),
796
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
795
+                'name' => __('Subject', 'invoicing'),
796
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
797 797
                 'type' => 'text',
798
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
798
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
799 799
                 'size' => 'large'
800 800
             ),
801 801
             'email_onhold_invoice_heading' => array(
802 802
                 'id'   => 'email_onhold_invoice_heading',
803
-                'name' => __( 'Email Heading', 'invoicing' ),
804
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
803
+                'name' => __('Email Heading', 'invoicing'),
804
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
805 805
                 'type' => 'text',
806
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
806
+                'std'  => __('Thank you for your invoice', 'invoicing'),
807 807
                 'size' => 'large'
808 808
             ),
809 809
             'email_onhold_invoice_admin_bcc' => array(
810 810
                 'id'   => 'email_onhold_invoice_admin_bcc',
811
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
812
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
811
+                'name' => __('Enable Admin BCC', 'invoicing'),
812
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
813 813
                 'type' => 'checkbox',
814 814
                 'std'  => 1
815 815
             ),
816 816
             'email_onhold_invoice_body' => array(
817 817
                 'id'   => 'email_onhold_invoice_body',
818
-                'name' => __( 'Email Content', 'invoicing' ),
819
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
818
+                'name' => __('Email Content', 'invoicing'),
819
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
820 820
                 'type' => 'rich_editor',
821
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
821
+                'std'  => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
822 822
                 'class' => 'large',
823 823
                 'size' => '10'
824 824
             ),
@@ -826,46 +826,46 @@  discard block
 block discarded – undo
826 826
         'processing_invoice' => array(
827 827
             'email_processing_invoice_header' => array(
828 828
                 'id'   => 'email_processing_invoice_header',
829
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
829
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_processing_invoice_active' => array(
834 834
                 'id'   => 'email_processing_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_processing_invoice_subject' => array(
841 841
                 'id'   => 'email_processing_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_processing_invoice_heading' => array(
849 849
                 'id'   => 'email_processing_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_processing_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_processing_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
863 863
             'email_processing_invoice_body' => array(
864 864
                 'id'   => 'email_processing_invoice_body',
865
-                'name' => __( 'Email Content', 'invoicing' ),
866
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
865
+                'name' => __('Email Content', 'invoicing'),
866
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
867 867
                 'type' => 'rich_editor',
868
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
868
+                'std'  => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
869 869
                 'class' => 'large',
870 870
                 'size' => '10'
871 871
             ),
@@ -873,52 +873,52 @@  discard block
 block discarded – undo
873 873
         'completed_invoice' => array(
874 874
             'email_completed_invoice_header' => array(
875 875
                 'id'   => 'email_completed_invoice_header',
876
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
877
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
876
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
877
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
878 878
                 'type' => 'header',
879 879
             ),
880 880
             'email_completed_invoice_active' => array(
881 881
                 'id'   => 'email_completed_invoice_active',
882
-                'name' => __( 'Enable/Disable', 'invoicing' ),
883
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
882
+                'name' => __('Enable/Disable', 'invoicing'),
883
+                'desc' => __('Enable this email notification', 'invoicing'),
884 884
                 'type' => 'checkbox',
885 885
                 'std'  => 1
886 886
             ),
887 887
             'email_completed_invoice_renewal_active' => array(
888 888
                 'id'   => 'email_completed_invoice_renewal_active',
889
-                'name' => __( 'Enable renewal notification', 'invoicing' ),
890
-                'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ),
889
+                'name' => __('Enable renewal notification', 'invoicing'),
890
+                'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'),
891 891
                 'type' => 'checkbox',
892 892
                 'std'  => 0
893 893
             ),
894 894
             'email_completed_invoice_subject' => array(
895 895
                 'id'   => 'email_completed_invoice_subject',
896
-                'name' => __( 'Subject', 'invoicing' ),
897
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
896
+                'name' => __('Subject', 'invoicing'),
897
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
898 898
                 'type' => 'text',
899
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
899
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
900 900
                 'size' => 'large'
901 901
             ),
902 902
             'email_completed_invoice_heading' => array(
903 903
                 'id'   => 'email_completed_invoice_heading',
904
-                'name' => __( 'Email Heading', 'invoicing' ),
905
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
904
+                'name' => __('Email Heading', 'invoicing'),
905
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
906 906
                 'type' => 'text',
907
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
907
+                'std'  => __('Your invoice has been paid', 'invoicing'),
908 908
                 'size' => 'large'
909 909
             ),
910 910
             'email_completed_invoice_admin_bcc' => array(
911 911
                 'id'   => 'email_completed_invoice_admin_bcc',
912
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
913
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
912
+                'name' => __('Enable Admin BCC', 'invoicing'),
913
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
914 914
                 'type' => 'checkbox',
915 915
             ),
916 916
             'email_completed_invoice_body' => array(
917 917
                 'id'   => 'email_completed_invoice_body',
918
-                'name' => __( 'Email Content', 'invoicing' ),
919
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
918
+                'name' => __('Email Content', 'invoicing'),
919
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
920 920
                 'type' => 'rich_editor',
921
-                'std'  => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ),
921
+                'std'  => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'),
922 922
                 'class' => 'large',
923 923
                 'size' => '10'
924 924
             ),
@@ -927,46 +927,46 @@  discard block
 block discarded – undo
927 927
         'refunded_invoice' => array(
928 928
             'email_refunded_invoice_header' => array(
929 929
                 'id'   => 'email_refunded_invoice_header',
930
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
931
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
930
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
931
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
932 932
                 'type' => 'header',
933 933
             ),
934 934
             'email_refunded_invoice_active' => array(
935 935
                 'id'   => 'email_refunded_invoice_active',
936
-                'name' => __( 'Enable/Disable', 'invoicing' ),
937
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
936
+                'name' => __('Enable/Disable', 'invoicing'),
937
+                'desc' => __('Enable this email notification', 'invoicing'),
938 938
                 'type' => 'checkbox',
939 939
                 'std'  => 1
940 940
             ),
941 941
             'email_refunded_invoice_subject' => array(
942 942
                 'id'   => 'email_refunded_invoice_subject',
943
-                'name' => __( 'Subject', 'invoicing' ),
944
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
943
+                'name' => __('Subject', 'invoicing'),
944
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
945 945
                 'type' => 'text',
946
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
946
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
947 947
                 'size' => 'large'
948 948
             ),
949 949
             'email_refunded_invoice_heading' => array(
950 950
                 'id'   => 'email_refunded_invoice_heading',
951
-                'name' => __( 'Email Heading', 'invoicing' ),
952
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
951
+                'name' => __('Email Heading', 'invoicing'),
952
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
953 953
                 'type' => 'text',
954
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
954
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
955 955
                 'size' => 'large'
956 956
             ),
957 957
             'email_refunded_invoice_admin_bcc' => array(
958 958
                 'id'   => 'email_refunded_invoice_admin_bcc',
959
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
960
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
959
+                'name' => __('Enable Admin BCC', 'invoicing'),
960
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
961 961
                 'type' => 'checkbox',
962 962
                 'std'  => 1
963 963
             ),
964 964
             'email_refunded_invoice_body' => array(
965 965
                 'id'   => 'email_refunded_invoice_body',
966
-                'name' => __( 'Email Content', 'invoicing' ),
967
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
966
+                'name' => __('Email Content', 'invoicing'),
967
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
968 968
                 'type' => 'rich_editor',
969
-                'std'  => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
969
+                'std'  => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
970 970
                 'class' => 'large',
971 971
                 'size' => '10'
972 972
             ),
@@ -974,46 +974,46 @@  discard block
 block discarded – undo
974 974
         'user_invoice' => array(
975 975
             'email_user_invoice_header' => array(
976 976
                 'id'   => 'email_user_invoice_header',
977
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
978
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
977
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
978
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
979 979
                 'type' => 'header',
980 980
             ),
981 981
             'email_user_invoice_active' => array(
982 982
                 'id'   => 'email_user_invoice_active',
983
-                'name' => __( 'Enable/Disable', 'invoicing' ),
984
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
983
+                'name' => __('Enable/Disable', 'invoicing'),
984
+                'desc' => __('Enable this email notification', 'invoicing'),
985 985
                 'type' => 'checkbox',
986 986
                 'std'  => 1
987 987
             ),
988 988
             'email_user_invoice_subject' => array(
989 989
                 'id'   => 'email_user_invoice_subject',
990
-                'name' => __( 'Subject', 'invoicing' ),
991
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
990
+                'name' => __('Subject', 'invoicing'),
991
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
992 992
                 'type' => 'text',
993
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
993
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
994 994
                 'size' => 'large'
995 995
             ),
996 996
             'email_user_invoice_heading' => array(
997 997
                 'id'   => 'email_user_invoice_heading',
998
-                'name' => __( 'Email Heading', 'invoicing' ),
999
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
998
+                'name' => __('Email Heading', 'invoicing'),
999
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1000 1000
                 'type' => 'text',
1001
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1001
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1002 1002
                 'size' => 'large'
1003 1003
             ),
1004 1004
             'email_user_invoice_admin_bcc' => array(
1005 1005
                 'id'   => 'email_user_invoice_admin_bcc',
1006
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1007
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1006
+                'name' => __('Enable Admin BCC', 'invoicing'),
1007
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1008 1008
                 'type' => 'checkbox',
1009 1009
                 'std'  => 1
1010 1010
             ),
1011 1011
             'email_user_invoice_body' => array(
1012 1012
                 'id'   => 'email_user_invoice_body',
1013
-                'name' => __( 'Email Content', 'invoicing' ),
1014
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1013
+                'name' => __('Email Content', 'invoicing'),
1014
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1015 1015
                 'type' => 'rich_editor',
1016
-                'std'  => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1016
+                'std'  => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1017 1017
                 'class' => 'large',
1018 1018
                 'size' => '10'
1019 1019
             ),
@@ -1021,39 +1021,39 @@  discard block
 block discarded – undo
1021 1021
         'user_note' => array(
1022 1022
             'email_user_note_header' => array(
1023 1023
                 'id'   => 'email_user_note_header',
1024
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1025
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1024
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1025
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1026 1026
                 'type' => 'header',
1027 1027
             ),
1028 1028
             'email_user_note_active' => array(
1029 1029
                 'id'   => 'email_user_note_active',
1030
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1031
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1030
+                'name' => __('Enable/Disable', 'invoicing'),
1031
+                'desc' => __('Enable this email notification', 'invoicing'),
1032 1032
                 'type' => 'checkbox',
1033 1033
                 'std'  => 1
1034 1034
             ),
1035 1035
             'email_user_note_subject' => array(
1036 1036
                 'id'   => 'email_user_note_subject',
1037
-                'name' => __( 'Subject', 'invoicing' ),
1038
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1037
+                'name' => __('Subject', 'invoicing'),
1038
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1039 1039
                 'type' => 'text',
1040
-                'std'  => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ),
1040
+                'std'  => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'),
1041 1041
                 'size' => 'large'
1042 1042
             ),
1043 1043
             'email_user_note_heading' => array(
1044 1044
                 'id'   => 'email_user_note_heading',
1045
-                'name' => __( 'Email Heading', 'invoicing' ),
1046
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1045
+                'name' => __('Email Heading', 'invoicing'),
1046
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1047 1047
                 'type' => 'text',
1048
-                'std'  => __( 'A note has been added to your {invoice_label}', 'invoicing' ),
1048
+                'std'  => __('A note has been added to your {invoice_label}', 'invoicing'),
1049 1049
                 'size' => 'large'
1050 1050
             ),
1051 1051
             'email_user_note_body' => array(
1052 1052
                 'id'   => 'email_user_note_body',
1053
-                'name' => __( 'Email Content', 'invoicing' ),
1054
-                'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ),
1053
+                'name' => __('Email Content', 'invoicing'),
1054
+                'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'),
1055 1055
                 'type' => 'rich_editor',
1056
-                'std'  => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
1056
+                'std'  => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
1057 1057
                 'class' => 'large',
1058 1058
                 'size' => '10'
1059 1059
             ),
@@ -1061,158 +1061,158 @@  discard block
 block discarded – undo
1061 1061
         'overdue' => array(
1062 1062
             'email_overdue_header' => array(
1063 1063
                 'id'   => 'email_overdue_header',
1064
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1065
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1064
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1065
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1066 1066
                 'type' => 'header',
1067 1067
             ),
1068 1068
             'email_overdue_active' => array(
1069 1069
                 'id'   => 'email_overdue_active',
1070
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1071
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1070
+                'name' => __('Enable/Disable', 'invoicing'),
1071
+                'desc' => __('Enable this email notification', 'invoicing'),
1072 1072
                 'type' => 'checkbox',
1073 1073
                 'std'  => 1
1074 1074
             ),
1075 1075
             'email_due_reminder_days' => array(
1076 1076
                 'id'        => 'email_due_reminder_days',
1077
-                'name'      => __( 'When to Send', 'invoicing' ),
1078
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1077
+                'name'      => __('When to Send', 'invoicing'),
1078
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1079 1079
                 'default'   => '',
1080 1080
                 'type'      => 'multicheck',
1081 1081
                 'options'   => $overdue_days_options,
1082 1082
             ),
1083 1083
             'email_overdue_subject' => array(
1084 1084
                 'id'   => 'email_overdue_subject',
1085
-                'name' => __( 'Subject', 'invoicing' ),
1086
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1085
+                'name' => __('Subject', 'invoicing'),
1086
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1087 1087
                 'type' => 'text',
1088
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1088
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1089 1089
                 'size' => 'large'
1090 1090
             ),
1091 1091
             'email_overdue_heading' => array(
1092 1092
                 'id'   => 'email_overdue_heading',
1093
-                'name' => __( 'Email Heading', 'invoicing' ),
1094
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1093
+                'name' => __('Email Heading', 'invoicing'),
1094
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1095 1095
                 'type' => 'text',
1096
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1096
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1097 1097
                 'size' => 'large'
1098 1098
             ),
1099 1099
             'email_overdue_body' => array(
1100 1100
                 'id'   => 'email_overdue_body',
1101
-                'name' => __( 'Email Content', 'invoicing' ),
1102
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1101
+                'name' => __('Email Content', 'invoicing'),
1102
+                'desc' => __('The content of the email.', 'invoicing'),
1103 1103
                 'type' => 'rich_editor',
1104
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
1104
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
1105 1105
                 'class' => 'large',
1106 1106
                 'size'  => 10,
1107 1107
             ),
1108 1108
         ),
1109 1109
     );
1110 1110
 
1111
-    return apply_filters( 'wpinv_get_emails', $emails );
1111
+    return apply_filters('wpinv_get_emails', $emails);
1112 1112
 }
1113 1113
 
1114
-function wpinv_settings_emails( $settings = array() ) {
1114
+function wpinv_settings_emails($settings = array()) {
1115 1115
     $emails = wpinv_get_emails();
1116 1116
 
1117
-    if ( !empty( $emails ) ) {
1118
-        foreach ( $emails as $key => $email ) {
1117
+    if (!empty($emails)) {
1118
+        foreach ($emails as $key => $email) {
1119 1119
             $settings[$key] = $email;
1120 1120
         }
1121 1121
     }
1122 1122
 
1123
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1123
+    return apply_filters('wpinv_settings_get_emails', $settings);
1124 1124
 }
1125
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1125
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1126 1126
 
1127
-function wpinv_settings_sections_emails( $settings ) {
1127
+function wpinv_settings_sections_emails($settings) {
1128 1128
     $emails = wpinv_get_emails();
1129 1129
 
1130 1130
     if (!empty($emails)) {
1131
-        foreach  ($emails as $key => $email) {
1132
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1131
+        foreach ($emails as $key => $email) {
1132
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1133 1133
         }
1134 1134
     }
1135 1135
 
1136 1136
     return $settings;    
1137 1137
 }
1138
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1138
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1139 1139
 
1140
-function wpinv_email_is_enabled( $email_type ) {
1140
+function wpinv_email_is_enabled($email_type) {
1141 1141
     $emails = wpinv_get_emails();
1142
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1142
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1143 1143
 
1144
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1144
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1145 1145
 }
1146 1146
 
1147
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1148
-    switch ( $email_type ) {
1147
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1148
+    switch ($email_type) {
1149 1149
         case 'new_invoice':
1150 1150
         case 'cancelled_invoice':
1151 1151
         case 'failed_invoice':
1152 1152
             $recipient  = wpinv_get_admin_email();
1153 1153
         break;
1154 1154
         default:
1155
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1156
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1155
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1156
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1157 1157
         break;
1158 1158
     }
1159 1159
 
1160
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1160
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1161 1161
 }
1162 1162
 
1163
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1164
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1165
-    $subject    = __( $subject, 'invoicing' );
1163
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1164
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1165
+    $subject    = __($subject, 'invoicing');
1166 1166
 
1167
-    $subject    = wpinv_email_format_text( $subject, $invoice );
1167
+    $subject    = wpinv_email_format_text($subject, $invoice);
1168 1168
 
1169
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1169
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1170 1170
 }
1171 1171
 
1172
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1174
-    $email_heading = __( $email_heading, 'invoicing' );
1172
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1173
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1174
+    $email_heading = __($email_heading, 'invoicing');
1175 1175
 
1176
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
1176
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
1177 1177
 
1178
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1178
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1179 1179
 }
1180 1180
 
1181
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1182
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1183
-    $content    = __( $content, 'invoicing' );
1181
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1182
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1183
+    $content    = __($content, 'invoicing');
1184 1184
 
1185
-    $content    = wpinv_email_format_text( $content, $invoice );
1185
+    $content    = wpinv_email_format_text($content, $invoice);
1186 1186
 
1187
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1187
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1188 1188
 }
1189 1189
 
1190
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1190
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1191 1191
     $from_name = wpinv_mail_get_from_address();
1192 1192
     $from_email = wpinv_mail_get_from_address();
1193 1193
     
1194
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1194
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1195 1195
     
1196
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1197
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1196
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1197
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1198 1198
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1199 1199
     
1200
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1200
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1201 1201
 }
1202 1202
 
1203
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1203
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1204 1204
     $attachments = array();
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1206
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content, $invoice ) {
1209
+function wpinv_email_format_text($content, $invoice) {
1210 1210
     $replace_array = array(
1211 1211
         '{site_title}'      => wpinv_get_blogname(),
1212
-        '{date}'            => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ),
1212
+        '{date}'            => date_i18n(get_option('date_format'), (int)current_time('timestamp')),
1213 1213
     );
1214 1214
     
1215
-    if ( !empty( $invoice->ID ) ) {
1215
+    if (!empty($invoice->ID)) {
1216 1216
         $replace_array = array_merge(
1217 1217
             $replace_array, 
1218 1218
             array(
@@ -1222,65 +1222,65 @@  discard block
 block discarded – undo
1222 1222
                 '{last_name}'       => $invoice->get_last_name(),
1223 1223
                 '{email}'           => $invoice->get_email(),
1224 1224
                 '{invoice_number}'  => $invoice->get_number(),
1225
-                '{invoice_total}'   => $invoice->get_total( true ),
1226
-                '{invoice_link}'    => $invoice->get_view_url( true ),
1227
-                '{invoice_pay_link}'=> $invoice->get_view_url( true ),
1228
-                '{invoice_date}'    => $invoice->get_invoice_date( true ),
1229
-                '{invoice_due_date}'=> $invoice->get_due_date( true ),
1230
-                '{invoice_quote}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1231
-                '{invoice_label}'   => $invoice->get_invoice_quote_type( $invoice->ID ),
1232
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
1225
+                '{invoice_total}'   => $invoice->get_total(true),
1226
+                '{invoice_link}'    => $invoice->get_view_url(true),
1227
+                '{invoice_pay_link}'=> $invoice->get_view_url(true),
1228
+                '{invoice_date}'    => $invoice->get_invoice_date(true),
1229
+                '{invoice_due_date}'=> $invoice->get_due_date(true),
1230
+                '{invoice_quote}'   => $invoice->get_invoice_quote_type($invoice->ID),
1231
+                '{invoice_label}'   => $invoice->get_invoice_quote_type($invoice->ID),
1232
+                '{is_was}'          => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'),
1233 1233
             )
1234 1234
         );
1235 1235
     }
1236 1236
 
1237
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
1237
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
1238 1238
 
1239
-    foreach ( $replace_array as $key => $value ) {
1240
-        $content = str_replace( $key, $value, $content );
1239
+    foreach ($replace_array as $key => $value) {
1240
+        $content = str_replace($key, $value, $content);
1241 1241
     }
1242 1242
 
1243
-    return apply_filters( 'wpinv_email_content_replace', $content );
1243
+    return apply_filters('wpinv_email_content_replace', $content);
1244 1244
 }
1245 1245
 
1246
-function wpinv_email_style_body( $content ) {
1246
+function wpinv_email_style_body($content) {
1247 1247
     // make sure we only inline CSS for html emails
1248
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1248
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1249 1249
         ob_start();
1250
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1251
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1250
+        wpinv_get_template('emails/wpinv-email-styles.php');
1251
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1252 1252
 
1253 1253
         // apply CSS styles inline for picky email clients
1254 1254
         try {
1255
-            $emogrifier = new Emogrifier( $content, $css );
1255
+            $emogrifier = new Emogrifier($content, $css);
1256 1256
             $content    = $emogrifier->emogrify();
1257
-        } catch ( Exception $e ) {
1258
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1257
+        } catch (Exception $e) {
1258
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1259 1259
         }
1260 1260
     }
1261 1261
     return $content;
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1265
-    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 ) );
1264
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1265
+    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));
1266 1266
 }
1267 1267
 
1268 1268
 /**
1269 1269
  * Get the email footer.
1270 1270
  */
1271
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1272
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1271
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1272
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1273 1273
 }
1274 1274
 
1275
-function wpinv_email_wrap_message( $message ) {
1275
+function wpinv_email_wrap_message($message) {
1276 1276
     // Buffer
1277 1277
     ob_start();
1278 1278
 
1279
-    do_action( 'wpinv_email_header' );
1279
+    do_action('wpinv_email_header');
1280 1280
 
1281
-    echo wpautop( wptexturize( $message ) );
1281
+    echo wpautop(wptexturize($message));
1282 1282
 
1283
-    do_action( 'wpinv_email_footer' );
1283
+    do_action('wpinv_email_footer');
1284 1284
 
1285 1285
     // Get contents
1286 1286
     $message = ob_get_clean();
@@ -1288,92 +1288,92 @@  discard block
 block discarded – undo
1288 1288
     return $message;
1289 1289
 }
1290 1290
 
1291
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1292
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1291
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1292
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1293 1293
 }
1294 1294
 
1295
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1296
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1295
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1296
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1297 1297
 }
1298 1298
 
1299
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1300
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1299
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1300
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1301 1301
 }
1302 1302
 
1303
-function wpinv_send_customer_invoice( $data = array() ) {
1304
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1303
+function wpinv_send_customer_invoice($data = array()) {
1304
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1305 1305
 
1306
-    if ( empty( $invoice_id ) ) {
1306
+    if (empty($invoice_id)) {
1307 1307
         return;
1308 1308
     }
1309 1309
 
1310
-    if ( !current_user_can( 'manage_options' ) ) {
1311
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1310
+    if (!current_user_can('manage_options')) {
1311
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1312 1312
     }
1313 1313
     
1314
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1314
+    $sent = wpinv_user_invoice_notification($invoice_id);
1315 1315
 
1316 1316
     if ( -1 === $sent ) {
1317 1317
         $status = 'email_disabled';
1318
-    } elseif ( $sent ) {
1318
+    } elseif ($sent) {
1319 1319
         $status = 'email_sent';
1320 1320
     } else {
1321 1321
         $status = 'email_fail';
1322 1322
     }
1323 1323
 
1324
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1325
-    wp_redirect( $redirect );
1324
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1325
+    wp_redirect($redirect);
1326 1326
     exit;
1327 1327
 }
1328
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1328
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1329 1329
 
1330
-function wpinv_send_overdue_reminder( $data = array() ) {
1331
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1330
+function wpinv_send_overdue_reminder($data = array()) {
1331
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1332 1332
 
1333
-    if ( empty( $invoice_id ) ) {
1333
+    if (empty($invoice_id)) {
1334 1334
         return;
1335 1335
     }
1336 1336
 
1337
-    if ( !current_user_can( 'manage_options' ) ) {
1338
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1337
+    if (!current_user_can('manage_options')) {
1338
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1339 1339
     }
1340 1340
 
1341
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1341
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1342 1342
     
1343 1343
     $status = $sent ? 'email_sent' : 'email_fail';
1344 1344
 
1345
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1346
-    wp_redirect( $redirect );
1345
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1346
+    wp_redirect($redirect);
1347 1347
     exit;
1348 1348
 }
1349
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1349
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1350 1350
 
1351
-function wpinv_send_customer_note_email( $data ) {
1352
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1351
+function wpinv_send_customer_note_email($data) {
1352
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1353 1353
 
1354
-    if ( empty( $invoice_id ) ) {
1354
+    if (empty($invoice_id)) {
1355 1355
         return;
1356 1356
     }
1357 1357
 
1358
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1358
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1359 1359
 }
1360
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1360
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1361 1361
 
1362
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1363
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1364
-        $date_format = get_option( 'date_format' );
1365
-        $time_format = get_option( 'time_format' );
1362
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1363
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1364
+        $date_format = get_option('date_format');
1365
+        $time_format = get_option('time_format');
1366 1366
         ?>
1367 1367
         <div id="wpinv-email-notes">
1368
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1368
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1369 1369
             <ol class="wpinv-notes-lists">
1370 1370
         <?php
1371
-        foreach ( $invoice_notes as $note ) {
1372
-            $note_time = strtotime( $note->comment_date );
1371
+        foreach ($invoice_notes as $note) {
1372
+            $note_time = strtotime($note->comment_date);
1373 1373
             ?>
1374 1374
             <li class="comment wpinv-note">
1375
-            <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>
1376
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1375
+            <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>
1376
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1377 1377
             </li>
1378 1378
             <?php
1379 1379
         }
@@ -1382,21 +1382,21 @@  discard block
 block discarded – undo
1382 1382
         <?php
1383 1383
     }
1384 1384
 }
1385
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1385
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1386 1386
 
1387 1387
 function wpinv_email_payment_reminders() {
1388 1388
     global $wpi_auto_reminder;
1389
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1389
+    if (!wpinv_get_option('email_overdue_active')) {
1390 1390
         return;
1391 1391
     }
1392 1392
 
1393
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1394
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1393
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1394
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1395 1395
 
1396
-        if ( empty( $reminder_days ) ) {
1396
+        if (empty($reminder_days)) {
1397 1397
             return;
1398 1398
         }
1399
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1399
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1400 1400
 
1401 1401
         $args = array(
1402 1402
             'post_type'     => 'wpi_invoice',
@@ -1406,7 +1406,7 @@  discard block
 block discarded – undo
1406 1406
             'meta_query'    => array(
1407 1407
                 array(
1408 1408
                     'key'       =>  '_wpinv_due_date',
1409
-                    'value'     =>  array( '', 'none' ),
1409
+                    'value'     =>  array('', 'none'),
1410 1410
                     'compare'   =>  'NOT IN',
1411 1411
                 )
1412 1412
             ),
@@ -1415,143 +1415,143 @@  discard block
 block discarded – undo
1415 1415
             'order'         => 'ASC',
1416 1416
         );
1417 1417
 
1418
-        $invoices = get_posts( $args );
1418
+        $invoices = get_posts($args);
1419 1419
 
1420
-        if ( empty( $invoices ) ) {
1420
+        if (empty($invoices)) {
1421 1421
             return;
1422 1422
         }
1423 1423
 
1424
-        $date_to_send   = array();
1424
+        $date_to_send = array();
1425 1425
 
1426
-        foreach ( $invoices as $id ) {
1427
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1426
+        foreach ($invoices as $id) {
1427
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1428 1428
 
1429
-            foreach ( $reminder_days as $key => $days ) {
1430
-                if ( $days !== '' ) {
1431
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1429
+            foreach ($reminder_days as $key => $days) {
1430
+                if ($days !== '') {
1431
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
 
1436
-        $today              = date_i18n( 'Y-m-d' );
1436
+        $today              = date_i18n('Y-m-d');
1437 1437
         $wpi_auto_reminder  = true;
1438 1438
 
1439
-        foreach ( $date_to_send as $id => $values ) {
1440
-            if ( in_array( $today, $values ) ) {
1441
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1439
+        foreach ($date_to_send as $id => $values) {
1440
+            if (in_array($today, $values)) {
1441
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1442 1442
 
1443
-                if ( isset( $sent ) && !empty( $sent ) ) {
1444
-                    if ( !in_array( $today, $sent ) ) {
1445
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1443
+                if (isset($sent) && !empty($sent)) {
1444
+                    if (!in_array($today, $sent)) {
1445
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1446 1446
                     }
1447 1447
                 } else {
1448
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1448
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1449 1449
                 }
1450 1450
             }
1451 1451
         }
1452 1452
 
1453
-        $wpi_auto_reminder  = false;
1453
+        $wpi_auto_reminder = false;
1454 1454
     }
1455 1455
 }
1456 1456
 
1457
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1457
+function wpinv_send_payment_reminder_notification($invoice_id) {
1458 1458
     $email_type = 'overdue';
1459
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1459
+    if (!wpinv_email_is_enabled($email_type)) {
1460 1460
         return false;
1461 1461
     }
1462 1462
 
1463
-    $invoice    = wpinv_get_invoice( $invoice_id );
1464
-    if ( empty( $invoice ) ) {
1463
+    $invoice = wpinv_get_invoice($invoice_id);
1464
+    if (empty($invoice)) {
1465 1465
         return false;
1466 1466
     }
1467 1467
 
1468
-    if ( !$invoice->needs_payment() ) {
1468
+    if (!$invoice->needs_payment()) {
1469 1469
         return false;
1470 1470
     }
1471 1471
 
1472
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1473
-    if ( !is_email( $recipient ) ) {
1472
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1473
+    if (!is_email($recipient)) {
1474 1474
         return false;
1475 1475
     }
1476 1476
 
1477
-    do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type );
1477
+    do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type);
1478 1478
 
1479
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1480
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1481
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1482
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1483
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1479
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1480
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1481
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1482
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1483
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1484 1484
 
1485
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1485
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1486 1486
             'invoice'       => $invoice,
1487 1487
             'email_type'    => $email_type,
1488 1488
             'email_heading' => $email_heading,
1489 1489
             'sent_to_admin' => false,
1490 1490
             'plain_text'    => false,
1491 1491
             'message_body'  => $message_body
1492
-        ) );
1492
+        ));
1493 1493
 
1494
-    $content        = wpinv_email_format_text( $content, $invoice );
1494
+    $content = wpinv_email_format_text($content, $invoice);
1495 1495
 
1496
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1497
-    if ( $sent ) {
1498
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1496
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1497
+    if ($sent) {
1498
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1499 1499
     }
1500 1500
 
1501
-    do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type );
1501
+    do_action('wpinv_post_send_invoice_notification', $invoice, $email_type);
1502 1502
 
1503 1503
     return $sent;
1504 1504
 }
1505
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1505
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1506 1506
 
1507
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1507
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1508 1508
     global $wpi_auto_reminder;
1509 1509
 
1510
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1510
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1511 1511
 
1512
-    if ( empty( $sent ) ) {
1512
+    if (empty($sent)) {
1513 1513
         $sent = array();
1514 1514
     }
1515
-    $sent[] = date_i18n( 'Y-m-d' );
1515
+    $sent[] = date_i18n('Y-m-d');
1516 1516
 
1517
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1517
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1518 1518
 
1519
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1520
-        $note = __( 'Automated reminder sent to the user.', 'invoicing' );
1521
-        $invoice->add_note( $note, false, false, true );
1519
+    if ($wpi_auto_reminder) { // Auto reminder note.
1520
+        $note = __('Automated reminder sent to the user.', 'invoicing');
1521
+        $invoice->add_note($note, false, false, true);
1522 1522
     } else { // Menual reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note );
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note);
1525 1525
     }
1526 1526
 }
1527
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1527
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1528 1528
 
1529
-function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) {
1530
-    if ( empty( $invoice ) ) {
1529
+function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) {
1530
+    if (empty($invoice)) {
1531 1531
         return;
1532 1532
     }
1533 1533
 
1534
-    if ( is_int( $invoice ) ) {
1535
-        $invoice = new wpinv_get_invoice( $invoice );
1534
+    if (is_int($invoice)) {
1535
+        $invoice = new wpinv_get_invoice($invoice);
1536 1536
     }
1537 1537
 
1538
-    if ( ! empty( $invoice ) && is_object( $invoice ) ) {
1539
-        if ( ! $site && function_exists( 'get_user_locale' ) ) {
1540
-            $locale = get_user_locale( $invoice->get_user_id() );
1538
+    if (!empty($invoice) && is_object($invoice)) {
1539
+        if (!$site && function_exists('get_user_locale')) {
1540
+            $locale = get_user_locale($invoice->get_user_id());
1541 1541
         } else {
1542 1542
             $locale = get_locale();
1543 1543
         }
1544 1544
 
1545
-        wpinv_switch_to_locale( $locale );
1545
+        wpinv_switch_to_locale($locale);
1546 1546
     }
1547 1547
 }
1548
-add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 );
1548
+add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3);
1549 1549
 
1550
-function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) {
1551
-    if ( empty( $invoice ) ) {
1550
+function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) {
1551
+    if (empty($invoice)) {
1552 1552
         return;
1553 1553
     }
1554 1554
 
1555 1555
     wpinv_restore_locale();
1556 1556
 }
1557
-add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 );
1557
+add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3);
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
@@ -12,19 +12,19 @@
 block discarded – undo
12 12
 */
13 13
 
14 14
 // MUST have WordPress.
15
-if ( !defined( 'WPINC' ) ) {
16
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
15
+if (!defined('WPINC')) {
16
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
17 17
 }
18 18
 
19
-if ( !defined( 'WPINV_VERSION' ) ) {
20
-    define( 'WPINV_VERSION', '1.0.10' );
19
+if (!defined('WPINV_VERSION')) {
20
+    define('WPINV_VERSION', '1.0.10');
21 21
 }
22 22
 
23
-if ( !defined( 'WPINV_PLUGIN_FILE' ) ) {
24
-    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23
+if (!defined('WPINV_PLUGIN_FILE')) {
24
+    define('WPINV_PLUGIN_FILE', __FILE__);
25 25
 }
26 26
 
27
-require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php';
27
+require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php';
28 28
 
29 29
 function wpinv_run() {
30 30
     global $invoicing;
Please login to merge, or discard this patch.
includes/class-wpinv-bp-core.php 1 patch
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit; // Exit if accessed directly
4 4
 }
5 5
 
@@ -9,42 +9,42 @@  discard block
 block discarded – undo
9 9
     
10 10
     public function __construct() {
11 11
 
12
-        if ( !defined( 'WPINV_BP_SLUG' ) ) {
13
-            define( 'WPINV_BP_SLUG', 'invoices' );
12
+        if (!defined('WPINV_BP_SLUG')) {
13
+            define('WPINV_BP_SLUG', 'invoices');
14 14
         }
15 15
 
16
-        add_action( 'wp_ajax_invoicing_filter', array( $this, 'invoices_content' ) );
17
-        add_action( 'wp_ajax_nopriv_invoicing_filter', array( $this, 'invoices_content' ) );
18
-        add_filter( 'wpinv_settings_sections_general', array( $this, 'bp_section' ), 10, 1 );
19
-        add_filter( 'wpinv_settings_general', array( $this, 'bp_settings' ), 10, 1 );
20
-        add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
16
+        add_action('wp_ajax_invoicing_filter', array($this, 'invoices_content'));
17
+        add_action('wp_ajax_nopriv_invoicing_filter', array($this, 'invoices_content'));
18
+        add_filter('wpinv_settings_sections_general', array($this, 'bp_section'), 10, 1);
19
+        add_filter('wpinv_settings_general', array($this, 'bp_settings'), 10, 1);
20
+        add_filter('wp_nav_menu_objects', array($this, 'wp_nav_menu_objects'), 10, 2);
21 21
         add_action('bp_setup_nav', array($this, 'setup_nav'), 15);
22 22
         
23
-        $position       = wpinv_get_option( 'wpinv_menu_position' );
23
+        $position       = wpinv_get_option('wpinv_menu_position');
24 24
         $position       = $position !== '' && $position !== false ? $position : 91;
25
-        $this->position = apply_filters( 'wpinv_bp_nav_position', $position );
26
-        $this->id     = WPINV_BP_SLUG;
25
+        $this->position = apply_filters('wpinv_bp_nav_position', $position);
26
+        $this->id = WPINV_BP_SLUG;
27 27
     }
28 28
 
29 29
     public function setup_nav() {
30 30
 
31
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) || !is_user_logged_in()) {
31
+        if (wpinv_get_option('wpinv_bp_hide_menu') || !is_user_logged_in()) {
32 32
             return;
33 33
         }
34 34
 
35
-        if(bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')){
35
+        if (bp_displayed_user_id() != bp_loggedin_user_id() && !current_user_can('administrator')) {
36 36
             return;
37 37
         }
38 38
 
39 39
         $count = $this->get_invoice_count();
40
-        $class = ( 0 === $count ) ? 'no-count' : 'count';
40
+        $class = (0 === $count) ? 'no-count' : 'count';
41 41
 
42 42
         $main_nav_name = sprintf(
43
-            __( 'My Invoices %s', 'invoicing' ),
43
+            __('My Invoices %s', 'invoicing'),
44 44
             sprintf(
45 45
                 '<span class="%s">%s</span>',
46
-                esc_attr( $class ),
47
-                bp_core_number_format( $count )
46
+                esc_attr($class),
47
+                bp_core_number_format($count)
48 48
             )
49 49
         );
50 50
 
@@ -52,31 +52,31 @@  discard block
 block discarded – undo
52 52
             'name'                => $main_nav_name,
53 53
             'slug'                => WPINV_BP_SLUG,
54 54
             'position'            => $this->position,
55
-            'screen_function'     => array( $this, 'invoices_screen' ),
55
+            'screen_function'     => array($this, 'invoices_screen'),
56 56
             'default_subnav_slug' => 'invoices',
57 57
             'item_css_id'         => $this->id
58 58
         );
59 59
 
60
-        bp_core_new_nav_item( $main_nav );
60
+        bp_core_new_nav_item($main_nav);
61 61
     }
62 62
     
63 63
     public function invoices_screen() {
64
-        if ( wpinv_get_option( 'wpinv_bp_hide_menu' ) ) {
64
+        if (wpinv_get_option('wpinv_bp_hide_menu')) {
65 65
             return;
66 66
         }
67 67
         
68
-        add_action( 'bp_template_content', array( $this, 'invoices_content' ) );
68
+        add_action('bp_template_content', array($this, 'invoices_content'));
69 69
 
70
-        $template = apply_filters( 'bp_core_template_plugin', 'members/single/plugins' );
70
+        $template = apply_filters('bp_core_template_plugin', 'members/single/plugins');
71 71
         
72
-        bp_core_load_template( apply_filters( 'wpinv_bp_core_template_plugin', $template ) );
72
+        bp_core_load_template(apply_filters('wpinv_bp_core_template_plugin', $template));
73 73
     }
74 74
     
75 75
     public function invoices_content() {
76
-        if ( $this->has_invoices( bp_ajax_querystring( 'invoices' ) ) ) {
76
+        if ($this->has_invoices(bp_ajax_querystring('invoices'))) {
77 77
             global $invoices_template;
78 78
             
79
-            do_action( 'wpinv_bp_invoices_before_content' );
79
+            do_action('wpinv_bp_invoices_before_content');
80 80
             ?>
81 81
             <div class="wpi-g wpi-bp-invoices invoices invoicing" style="position:relative">
82 82
                 <div id="pag-top" class="pagination">
@@ -90,61 +90,61 @@  discard block
 block discarded – undo
90 90
                 <table class="table table-bordered table-hover table-responsive wpi-user-invoices" style="margin:0">
91 91
                     <thead>
92 92
                         <tr>
93
-                            <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
94
-                                <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th>
93
+                            <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
94
+                                <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th>
95 95
                             <?php endforeach; ?>
96 96
                         </tr>
97 97
                     </thead>
98 98
                     <tbody>
99
-                        <?php foreach ( $invoices_template->invoices as $invoice ) {
99
+                        <?php foreach ($invoices_template->invoices as $invoice) {
100 100
                             ?>
101 101
                             <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
102
-                                <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?>
103
-                                    <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>">
104
-                                        <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?>
105
-                                            <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?>
106
-
107
-                                        <?php elseif ( 'invoice-number' === $column_id ) : ?>
108
-                                            <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>">
109
-                                                <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?>
102
+                                <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?>
103
+                                    <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>">
104
+                                        <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?>
105
+                                            <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?>
106
+
107
+                                        <?php elseif ('invoice-number' === $column_id) : ?>
108
+                                            <a href="<?php echo esc_url($invoice->get_view_url()); ?>">
109
+                                                <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?>
110 110
                                             </a>
111 111
 
112
-                                        <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?>
113
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
112
+                                        <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?>
113
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
114 114
 
115
-                                        <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?>
116
-                                            <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
115
+                                        <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?>
116
+                                            <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time>
117 117
 
118
-                                        <?php elseif ( 'invoice-status' === $column_id ) : ?>
119
-                                            <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?>
118
+                                        <?php elseif ('invoice-status' === $column_id) : ?>
119
+                                            <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?>
120 120
 
121
-                                        <?php elseif ( 'invoice-total' === $column_id ) : ?>
122
-                                            <?php echo $invoice->get_total( true ); ?>
121
+                                        <?php elseif ('invoice-total' === $column_id) : ?>
122
+                                            <?php echo $invoice->get_total(true); ?>
123 123
 
124
-                                        <?php elseif ( 'invoice-actions' === $column_id ) : ?>
124
+                                        <?php elseif ('invoice-actions' === $column_id) : ?>
125 125
                                             <?php
126 126
                                                 $actions = array(
127 127
                                                     'pay'    => array(
128 128
                                                         'url'  => $invoice->get_checkout_payment_url(),
129
-                                                        'name' => __( 'Pay Now', 'invoicing' ),
129
+                                                        'name' => __('Pay Now', 'invoicing'),
130 130
                                                         'class' => 'btn-success'
131 131
                                                     ),
132 132
                                                     'print'   => array(
133 133
                                                         'url'  => $invoice->get_view_url(),
134
-                                                        'name' => __( 'Print', 'invoicing' ),
134
+                                                        'name' => __('Print', 'invoicing'),
135 135
                                                         'class' => 'btn-primary',
136 136
                                                         'attrs' => 'target="_blank"'
137 137
                                                     )
138 138
                                                 );
139 139
 
140
-                                                if ( ! $invoice->needs_payment() ) {
141
-                                                    unset( $actions['pay'] );
140
+                                                if (!$invoice->needs_payment()) {
141
+                                                    unset($actions['pay']);
142 142
                                                 }
143 143
 
144
-                                                if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) {
145
-                                                    foreach ( $actions as $key => $action ) {
144
+                                                if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) {
145
+                                                    foreach ($actions as $key => $action) {
146 146
                                                         $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
147
-                                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
147
+                                                        echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>';
148 148
                                                     }
149 149
                                                 }
150 150
                                             ?>
@@ -172,64 +172,64 @@  discard block
 block discarded – undo
172 172
             </div>
173 173
             <?php
174 174
         
175
-            do_action( 'wpinv_bp_invoices_after_content' );
175
+            do_action('wpinv_bp_invoices_after_content');
176 176
         } else {
177 177
             ?>
178 178
             <div id="message" class="info">
179
-                <p><?php _e( 'No invoice has been made yet.', 'invoicing' ); ?></p>
179
+                <p><?php _e('No invoice has been made yet.', 'invoicing'); ?></p>
180 180
             </div>
181 181
             <?php
182 182
         }
183 183
         
184
-        if ( defined( 'DOING_AJAX' ) ) {
184
+        if (defined('DOING_AJAX')) {
185 185
             exit;
186 186
         }
187 187
     }
188 188
     
189
-    public function has_invoices( $args = '' ) {
189
+    public function has_invoices($args = '') {
190 190
         global $invoices_template;
191 191
 
192
-        $per_page = absint( wpinv_get_option( 'wpinv_bp_per_page' ) );
192
+        $per_page = absint(wpinv_get_option('wpinv_bp_per_page'));
193 193
         // Parse arguments.
194
-        $r = bp_parse_args( $args, array(
194
+        $r = bp_parse_args($args, array(
195 195
             'status'            => 'all',
196 196
             'page_arg'          => 'bpage',
197 197
             'page'              => 1,
198 198
             'per_page'          => $per_page > 0 ? $per_page : 20,
199 199
             'max'               => false,
200 200
             'user_id'           => bp_displayed_user_id(),
201
-        ), 'has_invoices' );
201
+        ), 'has_invoices');
202 202
 
203 203
 
204
-        if ( ! empty( $r['max'] ) && ( (int)$r['per_page'] > (int)$r['max'] ) ) {
204
+        if (!empty($r['max']) && ((int)$r['per_page'] > (int)$r['max'])) {
205 205
             $r['per_page'] = (int)$r['max'];
206 206
         }
207 207
 
208 208
         // Get the invoices.
209
-        $invoices_template = new WPInv_BP_Invoices_Template( $r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg'] );
209
+        $invoices_template = new WPInv_BP_Invoices_Template($r['status'], $r['page'], $r['per_page'], $r['max'], $r['user_id'], $r['page_arg']);
210 210
 
211
-        return apply_filters( 'wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r );
211
+        return apply_filters('wpinv_bp_has_invoices', $invoices_template->has_invoices(), $invoices_template, $r);
212 212
     }
213 213
     
214 214
     public function get_invoice_count() {
215
-        $query      = apply_filters( 'wpinv_user_invoices_count_query', array( 'status' => 'all','user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false ) );
216
-        $invoices   = wpinv_get_invoices( $query );
215
+        $query      = apply_filters('wpinv_user_invoices_count_query', array('status' => 'all', 'user' => bp_displayed_user_id(), 'limit' => '-1', 'return' => 'ids', 'paginate' => false));
216
+        $invoices   = wpinv_get_invoices($query);
217 217
         
218
-        return !empty( $invoices ) ? count( $invoices ) : 0;
218
+        return !empty($invoices) ? count($invoices) : 0;
219 219
     }
220 220
     
221 221
     public function pagination_count() {
222 222
         global $invoices_template;
223 223
 
224
-        $start_num = intval( ( $invoices_template->pag_page - 1 ) * $invoices_template->pag_num ) + 1;
225
-        $from_num  = bp_core_number_format( $start_num );
226
-        $to_num    = bp_core_number_format( ( $start_num + ( $invoices_template->pag_num - 1 ) > $invoices_template->total_invoice_count ) ? $invoices_template->total_invoice_count : $start_num + ( $invoices_template->pag_num - 1 ) );
227
-        $total     = bp_core_number_format( $invoices_template->total_invoice_count );
224
+        $start_num = intval(($invoices_template->pag_page - 1) * $invoices_template->pag_num) + 1;
225
+        $from_num  = bp_core_number_format($start_num);
226
+        $to_num    = bp_core_number_format(($start_num + ($invoices_template->pag_num - 1) > $invoices_template->total_invoice_count) ? $invoices_template->total_invoice_count : $start_num + ($invoices_template->pag_num - 1));
227
+        $total     = bp_core_number_format($invoices_template->total_invoice_count);
228 228
 
229
-        if ( 1 == $invoices_template->total_invoice_count ) {
230
-            $message = __( 'Viewing 1 invoice', 'invoicing' );
229
+        if (1 == $invoices_template->total_invoice_count) {
230
+            $message = __('Viewing 1 invoice', 'invoicing');
231 231
         } else {
232
-            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing' ), $from_num, $to_num, $total );
232
+            $message = sprintf(_n('Viewing %1$s - %2$s of %3$s invoice', 'Viewing %1$s - %2$s of %3$s invoices', $invoices_template->total_invoice_count, 'invoicing'), $from_num, $to_num, $total);
233 233
         }
234 234
 
235 235
         return $message;
@@ -238,32 +238,32 @@  discard block
 block discarded – undo
238 238
     function pagination_links() {
239 239
         global $invoices_template;
240 240
 
241
-        return apply_filters( 'wpinv_bp_get_pagination_links', $invoices_template->pag_links );
241
+        return apply_filters('wpinv_bp_get_pagination_links', $invoices_template->pag_links);
242 242
     }
243 243
     
244
-    public function bp_section( $settings = array() ) {
245
-        $settings['wpinv_bp'] = __( 'BuddyPress Integration', 'invoicing' );
244
+    public function bp_section($settings = array()) {
245
+        $settings['wpinv_bp'] = __('BuddyPress Integration', 'invoicing');
246 246
         return $settings;
247 247
     }
248 248
     
249
-    public function bp_settings( $settings = array() ) {
249
+    public function bp_settings($settings = array()) {
250 250
         $settings['wpinv_bp'] = array(
251 251
             'wpinv_bp_labels' => array(
252 252
                 'id'   => 'wpinv_bp_settings',
253
-                'name' => '<h3>' . __( 'BuddyPress Integration', 'invoicing' ) . '</h3>',
253
+                'name' => '<h3>' . __('BuddyPress Integration', 'invoicing') . '</h3>',
254 254
                 'desc' => '',
255 255
                 'type' => 'header',
256 256
             ),
257 257
             'wpinv_bp_hide_menu' => array(
258 258
                 'id'   => 'wpinv_bp_hide_menu',
259
-                'name' => __( 'Hide Invoices link', 'invoicing' ),
260
-                'desc' => __( 'Hide Invoices link from BP Profile menu.', 'invoicing' ),
259
+                'name' => __('Hide Invoices link', 'invoicing'),
260
+                'desc' => __('Hide Invoices link from BP Profile menu.', 'invoicing'),
261 261
                 'type' => 'checkbox',
262 262
             ),
263 263
             'wpinv_menu_position' => array(
264 264
                 'id'   => 'wpinv_menu_position',
265
-                'name' => __( 'Menu position', 'invoicing' ),
266
-                'desc' => __( 'Menu position for the Invoices link in BP Profile menu.', 'invoicing' ),
265
+                'name' => __('Menu position', 'invoicing'),
266
+                'desc' => __('Menu position for the Invoices link in BP Profile menu.', 'invoicing'),
267 267
                 'type' => 'number',
268 268
                 'size' => 'small',
269 269
                 'min'  => '1',
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
             ),
274 274
             'wpinv_bp_per_page' => array(
275 275
                 'id'   => 'wpinv_bp_per_page',
276
-                'name' => __( 'Max invoices per page', 'invoicing' ),
277
-                'desc' => __( 'Enter a number to lists the invoices for each page.', 'invoicing' ),
276
+                'name' => __('Max invoices per page', 'invoicing'),
277
+                'desc' => __('Enter a number to lists the invoices for each page.', 'invoicing'),
278 278
                 'type' => 'number',
279 279
                 'size' => 'small',
280 280
                 'min'  => '1',
@@ -287,20 +287,20 @@  discard block
 block discarded – undo
287 287
         return $settings;
288 288
     }
289 289
 
290
-    public function wp_nav_menu_objects($items, $args){
291
-        if(!is_user_logged_in()){
290
+    public function wp_nav_menu_objects($items, $args) {
291
+        if (!is_user_logged_in()) {
292 292
             return $items;
293 293
         }
294 294
 
295
-        if(!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)){
295
+        if (!apply_filters('wpinv_bp_invoice_history_redirect', true, $items, $args)) {
296 296
             return $items;
297 297
         }
298 298
 
299 299
         $user_id = get_current_user_id();
300
-        $link = bp_core_get_user_domain( $user_id ).WPINV_BP_SLUG;
300
+        $link = bp_core_get_user_domain($user_id) . WPINV_BP_SLUG;
301 301
         $history_link = wpinv_get_history_page_uri();
302
-        foreach ( $items as $item ) {
303
-            $item->url = str_replace( $history_link, $link, $item->url );
302
+        foreach ($items as $item) {
303
+            $item->url = str_replace($history_link, $link, $item->url);
304 304
         }
305 305
 
306 306
         return $items;
@@ -318,25 +318,25 @@  discard block
 block discarded – undo
318 318
     public $pag_links = '';
319 319
     public $total_invoice_count = 0;
320 320
     
321
-    public function __construct( $status, $page, $per_page, $max, $user_id, $page_arg = 'bpage' ) {
322
-        $this->invoices = array( 'invoices' => array(), 'total' => 0 );
321
+    public function __construct($status, $page, $per_page, $max, $user_id, $page_arg = 'bpage') {
322
+        $this->invoices = array('invoices' => array(), 'total' => 0);
323 323
         
324
-        $this->pag_arg  = sanitize_key( $page_arg );
325
-        $this->pag_page = bp_sanitize_pagination_arg( $this->pag_arg, $page );
326
-        $this->pag_num  = bp_sanitize_pagination_arg( 'num', $per_page );
324
+        $this->pag_arg  = sanitize_key($page_arg);
325
+        $this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page);
326
+        $this->pag_num  = bp_sanitize_pagination_arg('num', $per_page);
327 327
 
328
-        $query_args     = array( 'user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true );
329
-        if ( !empty( $status ) && $status != 'all' ) {
328
+        $query_args     = array('user' => $user_id, 'page' => $this->pag_page, 'limit' => $this->pag_num, 'return' => 'self', 'paginate' => true);
329
+        if (!empty($status) && $status != 'all') {
330 330
            $query_args['status'] = $status;
331 331
         }
332
-        $invoices  = wpinv_get_invoices( apply_filters( 'wpinv_bp_user_invoices_query', $query_args ) );
332
+        $invoices = wpinv_get_invoices(apply_filters('wpinv_bp_user_invoices_query', $query_args));
333 333
         
334
-        if ( !empty( $invoices ) && !empty( $invoices->found_posts ) ) {
335
-            $this->invoices['invoices'] = array_map( 'wpinv_get_invoice', $invoices->posts );
334
+        if (!empty($invoices) && !empty($invoices->found_posts)) {
335
+            $this->invoices['invoices'] = array_map('wpinv_get_invoice', $invoices->posts);
336 336
             $this->invoices['total']    = $invoices->found_posts;
337 337
         }
338 338
 
339
-        if ( empty( $max ) || ( $max >= (int)$this->invoices['total'] ) ) {
339
+        if (empty($max) || ($max >= (int)$this->invoices['total'])) {
340 340
             $this->total_invoice_count = (int)$this->invoices['total'];
341 341
         } else {
342 342
             $this->total_invoice_count = (int)$max;
@@ -344,52 +344,52 @@  discard block
 block discarded – undo
344 344
 
345 345
         $this->invoices = $this->invoices['invoices'];
346 346
 
347
-        $invoice_count = count( $this->invoices );
347
+        $invoice_count = count($this->invoices);
348 348
 
349
-        if ( empty( $max ) || ( $max >= (int)$invoice_count ) ) {
349
+        if (empty($max) || ($max >= (int)$invoice_count)) {
350 350
             $this->invoice_count = (int)$invoice_count;
351 351
         } else {
352 352
             $this->invoice_count = (int)$max;
353 353
         }
354 354
         
355
-        if ( ! empty( $this->total_invoice_count ) && ! empty( $this->pag_num ) ) {
356
-            $this->pag_links = paginate_links( array(
357
-                'base'      => add_query_arg( $this->pag_arg, '%#%' ),
355
+        if (!empty($this->total_invoice_count) && !empty($this->pag_num)) {
356
+            $this->pag_links = paginate_links(array(
357
+                'base'      => add_query_arg($this->pag_arg, '%#%'),
358 358
                 'format'    => '',
359
-                'total'     => ceil( (int)$this->total_invoice_count / (int)$this->pag_num ),
359
+                'total'     => ceil((int)$this->total_invoice_count / (int)$this->pag_num),
360 360
                 'current'   => (int)$this->pag_page,
361
-                'prev_text' => _x( '&larr;', 'Invoice pagination previous text', 'invoicing' ),
362
-                'next_text' => _x( '&rarr;', 'Invoice pagination next text',     'invoicing' ),
361
+                'prev_text' => _x('&larr;', 'Invoice pagination previous text', 'invoicing'),
362
+                'next_text' => _x('&rarr;', 'Invoice pagination next text', 'invoicing'),
363 363
                 'mid_size'  => 1,
364 364
                 'add_args'  => array(),
365
-            ) );
365
+            ));
366 366
         }
367 367
     }
368 368
 
369 369
     public function has_invoices() {
370
-        return (bool) ! empty( $this->invoice_count );
370
+        return (bool)!empty($this->invoice_count);
371 371
     }
372 372
 
373 373
     public function next_invoice() {
374 374
         $this->current_invoice++;
375
-        $this->invoice = $this->invoices[ $this->current_invoice ];
375
+        $this->invoice = $this->invoices[$this->current_invoice];
376 376
 
377 377
         return $this->invoice;
378 378
     }
379 379
 
380 380
     public function rewind_invoices() {
381 381
         $this->current_invoice = -1;
382
-        if ( $this->invoice_count > 0 ) {
382
+        if ($this->invoice_count > 0) {
383 383
             $this->invoice = $this->invoices[0];
384 384
         }
385 385
     }
386 386
 
387 387
     public function invoices() {
388
-        if ( ( $this->current_invoice + 1 ) < $this->invoice_count ) {
388
+        if (($this->current_invoice + 1) < $this->invoice_count) {
389 389
             return true;
390
-        } elseif ( ( $this->current_invoice + 1 ) === $this->invoice_count ) {
390
+        } elseif (($this->current_invoice + 1) === $this->invoice_count) {
391 391
 
392
-            do_action( 'wpinv_bp_invoice_loop_end' );
392
+            do_action('wpinv_bp_invoice_loop_end');
393 393
             
394 394
             $this->rewind_invoices();
395 395
         }
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
         $this->in_the_loop = true;
404 404
         $this->invoice     = $this->next_invoice();
405 405
 
406
-        if ( 0 === $this->current_invoice ) {
407
-            do_action( 'wpinv_bp_invoice_loop_start' );
406
+        if (0 === $this->current_invoice) {
407
+            do_action('wpinv_bp_invoice_loop_start');
408 408
         }
409 409
     }
410 410
 }
411 411
 
412 412
 function wpinv_bp_setup_component() {
413 413
 
414
-    if(!class_exists( 'BuddyPress' )){
414
+    if (!class_exists('BuddyPress')) {
415 415
         return;
416 416
     }
417 417
 
418 418
     new WPInv_BP_Component();
419 419
 
420 420
 }
421
-add_action( 'bp_loaded', 'wpinv_bp_setup_component' );
422 421
\ No newline at end of file
422
+add_action('bp_loaded', 'wpinv_bp_setup_component');
423 423
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 <div class="wrap wpi_addons_wrap">
12 12
 	<h1><?php echo get_admin_page_title(); ?></h1>
13 13
 
14
-	<?php if ( $tabs ){ ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if(defined('WP_EASY_UPDATES_ACTIVE')){?>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?>
36 36
 					<h2>Have a membership key?</h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108));
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php }?>
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 						<div class="testimonial-content">
90 90
 							<div class="t-image">
91 91
 								<?php
92
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
92
+									echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > ';
93 93
 								?>
94 94
 							</div>
95 95
 							<div class="t-content">
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 						<div class="testimonial-content">
110 110
 							<div class="t-image">
111 111
 								<?php
112
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
112
+									echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > ';
113 113
 								?>
114 114
 							</div>
115 115
 							<div class="t-content">
@@ -134,44 +134,44 @@  discard block
 block discarded – undo
134 134
 			</div>
135 135
 		</div>
136 136
 			<?php
137
-		}else{
137
+		} else {
138 138
 			$installed_plugins = get_plugins();
139 139
             $addon_obj = new WPInv_Admin_Addons();
140
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
140
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
141 141
 				?>
142
-				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
143
-                        if(965==$addon->info->id){continue;}// don't show quote add on
142
+				<ul class="wpi-products"><?php foreach ($addons as $addon) :
143
+                        if (965 == $addon->info->id) {continue; }// don't show quote add on
144 144
 						?><li class="wpi-product">
145 145
 								<div class="wpi-product-title">
146 146
 									<h3><?php
147
-										if ( ! empty( $addon->info->excerpt) ){
148
-											echo wpi_help_tip( $addon->info->excerpt );
147
+										if (!empty($addon->info->excerpt)) {
148
+											echo wpi_help_tip($addon->info->excerpt);
149 149
 										}
150
-										echo esc_html( $addon->info->title ); ?></h3>
150
+										echo esc_html($addon->info->title); ?></h3>
151 151
 								</div>
152 152
 
153 153
 								<span class="wpi-product-image">
154
-									<?php if ( ! empty( $addon->info->thumbnail) ) : ?>
155
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
154
+									<?php if (!empty($addon->info->thumbnail)) : ?>
155
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
156 156
 									<?php endif;
157 157
 
158
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
159
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
158
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") {
159
+										echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
161 161
 										echo '</a>';
162
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
163
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
164
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com');
165
-										}else{
162
+									}elseif (isset($addon->info->link) && substr($addon->info->link, 0, 23) === "https://wpinvoicing.com") {
163
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
164
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&TB_iframe=true&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpinvoicing.com');
165
+										} else {
166 166
 											// if installed show activation link
167
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
167
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
169
-											}else{
169
+											} else {
170 170
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
171 171
 											}
172 172
 										}
173
-										echo '<a href="'.$url.'" class="thickbox">';
174
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+										echo '<a href="' . $url . '" class="thickbox">';
174
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
175 175
 										echo '</a>';
176 176
 									}
177 177
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 								<span class="wpi-product-button">
184 184
 									<?php
185
-                                    $addon_obj->output_button( $addon );
185
+                                    $addon_obj->output_button($addon);
186 186
 									?>
187 187
 								</span>
188 188
 
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
 
197 197
 	<div class="clearfix" ></div>
198 198
 
199
-	<?php if($current_tab =='addons'){ ?>
200
-	<p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p>
201
-	<?php } if($current_tab =='gateways'){  ?>
202
-    <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p>
199
+	<?php if ($current_tab == 'addons') { ?>
200
+	<p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p>
201
+	<?php } if ($current_tab == 'gateways') {  ?>
202
+    <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p>
203 203
     <?php } ?>
204 204
 
205
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div>
206
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(  __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div>
205
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div>
206
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div>
207 207
 	<div id="wpeu-licence-popup" style="display:none;">
208 208
 		<span class="wpi-notification noti-white">
209
-			<h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3>
210
-			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209
+			<h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3>
210
+			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button>
211 211
 			<br>
212 212
 			<?php
213
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
213
+			echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
214 214
 			?>
215 215
 		</span>
216 216
 	</div>
Please login to merge, or discard this patch.
templates/wpinv-checkout-cart.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -5,138 +5,138 @@
 block discarded – undo
5 5
 
6 6
 global $wpinv_euvat, $post, $ajax_cart_details, $wpi_cart_columns;
7 7
 $invoice            = wpinv_get_invoice_cart();
8
-$cart_items         = !empty( $ajax_cart_details ) ? $ajax_cart_details : wpinv_get_cart_content_details();
8
+$cart_items         = !empty($ajax_cart_details) ? $ajax_cart_details : wpinv_get_cart_content_details();
9 9
 $quantities_enabled = wpinv_item_quantities_enabled();
10 10
 $use_taxes          = wpinv_use_taxes();
11 11
 $tax_label          = $wpinv_euvat->tax_label();
12
-$tax_title          = $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
12
+$tax_title          = $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
13 13
 ?>
14 14
 <table id="wpinv_checkout_cart" class="table table-bordered table-hover">
15 15
     <thead>
16 16
         <tr class="wpinv_cart_header_row">
17
-            <?php do_action( 'wpinv_checkout_table_header_first' ); ?>
18
-            <th class="wpinv_cart_item_name text-left"><?php _e( 'Item Name', 'invoicing' ); ?></th>
19
-            <th class="wpinv_cart_item_price text-right"><?php _e( 'Item Price', 'invoicing' ); ?></th>
20
-            <?php if ( $quantities_enabled ) { ?>
21
-            <th class="wpinv_cart_item_qty text-right"><?php _e( 'Qty', 'invoicing' ); ?></th>
17
+            <?php do_action('wpinv_checkout_table_header_first'); ?>
18
+            <th class="wpinv_cart_item_name text-left"><?php _e('Item Name', 'invoicing'); ?></th>
19
+            <th class="wpinv_cart_item_price text-right"><?php _e('Item Price', 'invoicing'); ?></th>
20
+            <?php if ($quantities_enabled) { ?>
21
+            <th class="wpinv_cart_item_qty text-right"><?php _e('Qty', 'invoicing'); ?></th>
22 22
             <?php } ?>
23
-            <?php if ( $use_taxes ) { ?>
23
+            <?php if ($use_taxes) { ?>
24 24
             <th class="wpinv_cart_item_tax text-right"><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></th>
25 25
             <?php } ?>
26
-            <th class="wpinv_cart_item_subtotal text-right"><?php echo __( 'Item Total', 'invoicing' ) . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
27
-            <?php do_action( 'wpinv_checkout_table_header_last' ); ?>
26
+            <th class="wpinv_cart_item_subtotal text-right"><?php echo __('Item Total', 'invoicing') . ' <span class="normal small">' . $tax_title . '<span>'; ?></th>
27
+            <?php do_action('wpinv_checkout_table_header_last'); ?>
28 28
         </tr>
29 29
     </thead>
30 30
     <tbody>
31 31
         <?php
32
-            do_action( 'wpinv_cart_items_before' );
32
+            do_action('wpinv_cart_items_before');
33 33
             
34
-            if ( $cart_items ) {
35
-                foreach ( $cart_items as $key => $item ) {
36
-                    $wpi_item = !empty( $item['id'] ) ? new WPInv_Item( $item['id'] ) : NULL;
34
+            if ($cart_items) {
35
+                foreach ($cart_items as $key => $item) {
36
+                    $wpi_item = !empty($item['id']) ? new WPInv_Item($item['id']) : NULL;
37 37
                 ?>
38
-                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr( $key ) . '_' . esc_attr( $item['id'] ); ?>" data-item-id="<?php echo esc_attr( $item['id'] ); ?>">
39
-                    <?php do_action( 'wpinv_checkout_table_body_first', $item ); ?>
38
+                <tr class="wpinv_cart_item" id="wpinv_cart_item_<?php echo esc_attr($key) . '_' . esc_attr($item['id']); ?>" data-item-id="<?php echo esc_attr($item['id']); ?>">
39
+                    <?php do_action('wpinv_checkout_table_body_first', $item); ?>
40 40
                     <td class="wpinv_cart_item_name text-left">
41 41
                         <?php
42
-                            if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $item['id'] ) ) {
42
+                            if (current_theme_supports('post-thumbnails') && has_post_thumbnail($item['id'])) {
43 43
                                 echo '<div class="wpinv_cart_item_image">';
44
-                                    echo get_the_post_thumbnail( $item['id'], apply_filters( 'wpinv_checkout_image_size', array( 25,25 ) ) );
44
+                                    echo get_the_post_thumbnail($item['id'], apply_filters('wpinv_checkout_image_size', array(25, 25)));
45 45
                                 echo '</div>';
46 46
                             }
47
-                            $item_title = esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $wpi_item );
47
+                            $item_title = esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($wpi_item);
48 48
                             echo '<span class="wpinv_checkout_cart_item_title">' . $item_title . '</span>';
49
-                            $summary = apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice );
50
-                            if ( !empty( $summary ) ) {
49
+                            $summary = apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $wpi_item, $invoice);
50
+                            if (!empty($summary)) {
51 51
                                 echo $summary;
52 52
                             }
53 53
                         ?>
54 54
                     </td>
55 55
                     <td class="wpinv_cart_item_price text-right">
56 56
                         <?php 
57
-                        echo wpinv_cart_item_price( $item );
58
-                        do_action( 'wpinv_checkout_cart_item_price_after', $item, $key );
57
+                        echo wpinv_cart_item_price($item);
58
+                        do_action('wpinv_checkout_cart_item_price_after', $item, $key);
59 59
                         ?>
60 60
                     </td>
61
-                    <?php if ( $quantities_enabled ) { ?>
61
+                    <?php if ($quantities_enabled) { ?>
62 62
                     <td class="wpinv_cart_item_qty text-right">
63 63
                         <?php
64
-                        echo wpinv_get_cart_item_quantity( $item );
65
-                        do_action( 'wpinv_cart_item_quantitiy', $item, $key );
64
+                        echo wpinv_get_cart_item_quantity($item);
65
+                        do_action('wpinv_cart_item_quantitiy', $item, $key);
66 66
                         ?>
67 67
                     </td>
68 68
                     <?php } ?>
69
-                    <?php if ( $use_taxes ) { ?>
69
+                    <?php if ($use_taxes) { ?>
70 70
                     <td class="wpinv_cart_item_tax text-right">
71 71
                         <?php
72
-                        echo wpinv_cart_item_tax( $item );
72
+                        echo wpinv_cart_item_tax($item);
73 73
                         //echo wpinv_get_cart_item_tax( $wpi_item->ID, $subtotal = '', $options = array() );
74
-                        do_action( 'wpinv_cart_item_tax', $item, $key );
74
+                        do_action('wpinv_cart_item_tax', $item, $key);
75 75
                         ?>
76 76
                     </td>
77 77
                     <?php } ?>
78 78
                     <td class="wpinv_cart_item_subtotal text-right">
79 79
                         <?php
80
-                        echo wpinv_cart_item_subtotal( $item );
81
-                        do_action( 'wpinv_cart_item_subtotal', $item, $key );
80
+                        echo wpinv_cart_item_subtotal($item);
81
+                        do_action('wpinv_cart_item_subtotal', $item, $key);
82 82
                         ?>
83 83
                     </td>
84
-                    <?php do_action( 'wpinv_checkout_table_body_last', $item, $key ); ?>
84
+                    <?php do_action('wpinv_checkout_table_body_last', $item, $key); ?>
85 85
                 </tr>
86 86
             <?php } ?>
87 87
         <?php } ?>
88
-        <?php do_action( 'wpinv_cart_items_middle' ); ?>
89
-        <?php do_action( 'wpinv_cart_items_after' ); ?>
88
+        <?php do_action('wpinv_cart_items_middle'); ?>
89
+        <?php do_action('wpinv_cart_items_after'); ?>
90 90
     </tbody>
91 91
     <tfoot>
92 92
         <?php $cart_columns = wpinv_checkout_cart_columns(); ?>
93
-        <?php if ( has_action( 'wpinv_cart_footer_buttons' ) ) { ?>
93
+        <?php if (has_action('wpinv_cart_footer_buttons')) { ?>
94 94
             <tr class="wpinv_cart_footer_row">
95
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
96
-                <td colspan="<?php echo ( $cart_columns ); ?>">
97
-                    <?php do_action( 'wpinv_cart_footer_buttons' ); ?>
95
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
96
+                <td colspan="<?php echo ($cart_columns); ?>">
97
+                    <?php do_action('wpinv_cart_footer_buttons'); ?>
98 98
                 </td>
99
-                <?php do_action( 'wpinv_checkout_table_buttons_first', $cart_items ); ?>
99
+                <?php do_action('wpinv_checkout_table_buttons_first', $cart_items); ?>
100 100
             </tr>
101 101
         <?php } ?>
102 102
 
103
-        <?php if ( $use_taxes && !wpinv_prices_include_tax() ) { ?>
104
-            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if ( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
105
-                <?php do_action( 'wpinv_checkout_table_subtotal_first', $cart_items ); ?>
106
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_subtotal_label text-right">
107
-                    <strong><?php _e( 'Sub-Total', 'invoicing' ); ?>:</strong>
103
+        <?php if ($use_taxes && !wpinv_prices_include_tax()) { ?>
104
+            <tr class="wpinv_cart_footer_row wpinv_cart_subtotal_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
105
+                <?php do_action('wpinv_checkout_table_subtotal_first', $cart_items); ?>
106
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_subtotal_label text-right">
107
+                    <strong><?php _e('Sub-Total', 'invoicing'); ?>:</strong>
108 108
                 </td>
109 109
                 <td class="wpinv_cart_subtotal text-right">
110
-                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal( $cart_items ); ?></span>
110
+                    <span class="wpinv_cart_subtotal_amount bold"><?php echo wpinv_cart_subtotal($cart_items); ?></span>
111 111
                 </td>
112
-                <?php do_action( 'wpinv_checkout_table_subtotal_last', $cart_items ); ?>
112
+                <?php do_action('wpinv_checkout_table_subtotal_last', $cart_items); ?>
113 113
             </tr>
114 114
         <?php } ?>
115 115
         
116
-        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html( $cart_items ); ?>
116
+        <?php $wpi_cart_columns = $cart_columns - 1; wpinv_cart_discounts_html($cart_items); ?>
117 117
 
118
-        <?php if ( $use_taxes ) { ?>
119
-            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if( !wpinv_is_cart_taxed() ) echo ' style="display:none;"'; ?>>
120
-                <?php do_action( 'wpinv_checkout_table_tax_first' ); ?>
121
-                <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_tax_label text-right">
118
+        <?php if ($use_taxes) { ?>
119
+            <tr class="wpinv_cart_footer_row wpinv_cart_tax_row"<?php if (!wpinv_is_cart_taxed()) echo ' style="display:none;"'; ?>>
120
+                <?php do_action('wpinv_checkout_table_tax_first'); ?>
121
+                <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_tax_label text-right">
122 122
                     <strong><?php echo $tax_label; ?>:</strong>
123 123
                 </td>
124 124
                 <td class="wpinv_cart_tax text-right">
125
-                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax( $cart_items ); ?>"><?php echo esc_html( wpinv_cart_tax( $cart_items ) ); ?></span>
125
+                    <span class="wpinv_cart_tax_amount" data-tax="<?php echo wpinv_get_cart_tax($cart_items); ?>"><?php echo esc_html(wpinv_cart_tax($cart_items)); ?></span>
126 126
                 </td>
127
-                <?php do_action( 'wpinv_checkout_table_tax_last' ); ?>
127
+                <?php do_action('wpinv_checkout_table_tax_last'); ?>
128 128
             </tr>
129 129
         <?php } ?>
130 130
 
131 131
         <tr class="wpinv_cart_footer_row wpinv_cart_total_row">
132
-            <?php do_action( 'wpinv_checkout_table_footer_first' ); ?>
133
-            <td colspan="<?php echo ( $cart_columns - 1 ); ?>" class="wpinv_cart_total_label text-right">
134
-                <?php echo apply_filters( 'wpinv_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?>
132
+            <?php do_action('wpinv_checkout_table_footer_first'); ?>
133
+            <td colspan="<?php echo ($cart_columns - 1); ?>" class="wpinv_cart_total_label text-right">
134
+                <?php echo apply_filters('wpinv_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?>
135 135
             </td>
136 136
             <td class="wpinv_cart_total text-right">
137
-                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total( $cart_items ); ?>" data-total="<?php echo wpinv_get_cart_total( NULL, NULL, $invoice ); ?>"><?php wpinv_cart_total( $cart_items, true, $invoice ); ?></span>
137
+                <span class="wpinv_cart_amount bold" data-subtotal="<?php echo wpinv_get_cart_total($cart_items); ?>" data-total="<?php echo wpinv_get_cart_total(NULL, NULL, $invoice); ?>"><?php wpinv_cart_total($cart_items, true, $invoice); ?></span>
138 138
             </td>
139
-            <?php do_action( 'wpinv_checkout_table_footer_last' ); ?>
139
+            <?php do_action('wpinv_checkout_table_footer_last'); ?>
140 140
         </tr>
141 141
     </tfoot>
142 142
 </table>
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +281 added lines, -281 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
6
-    if( empty( $field ) || empty( $value ) ) {
5
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
6
+    if (empty($field) || empty($value)) {
7 7
         return false;
8 8
     }
9 9
     
10 10
     $posts = array();
11 11
 
12
-    switch( strtolower( $field ) ) {
12
+    switch (strtolower($field)) {
13 13
         case 'id':
14
-            $item = new WPInv_Item( $value );
14
+            $item = new WPInv_Item($value);
15 15
 
16
-            if ( !empty( $item ) && $item->post_type == 'wpi_item' ) {
16
+            if (!empty($item) && $item->post_type == 'wpi_item') {
17 17
                 return $item;
18 18
             }
19 19
             return false;
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
 
23 23
         case 'slug':
24 24
         case 'name':
25
-            $posts = get_posts( array(
25
+            $posts = get_posts(array(
26 26
                 'post_type'      => 'wpi_item',
27 27
                 'name'           => $value,
28 28
                 'posts_per_page' => 1,
29 29
                 'post_status'    => 'any'
30
-            ) );
30
+            ));
31 31
 
32 32
             break;
33 33
         case 'custom_id':
34
-            if ( empty( $value ) || empty( $type ) ) {
34
+            if (empty($value) || empty($type)) {
35 35
                 return false;
36 36
             }
37 37
             
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
                 'post_status'    => 'any',
52 52
                 'orderby'        => 'ID',
53 53
                 'order'          => 'ASC',
54
-                'meta_query'     => array( $meta_query )
54
+                'meta_query'     => array($meta_query)
55 55
             );
56 56
             
57
-            $posts = get_posts( $args );
57
+            $posts = get_posts($args);
58 58
 
59 59
             break;
60 60
 
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
             return false;
63 63
     }
64 64
     
65
-    if ( !empty( $posts[0] ) ) {
66
-        $item = new WPInv_Item( $posts[0]->ID );
65
+    if (!empty($posts[0])) {
66
+        $item = new WPInv_Item($posts[0]->ID);
67 67
 
68
-        if ( !empty( $item ) && $item->post_type == 'wpi_item' ) {
68
+        if (!empty($item) && $item->post_type == 'wpi_item') {
69 69
             return $item;
70 70
         }
71 71
     }
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
     return false;
74 74
 }
75 75
 
76
-function wpinv_get_item( $item = 0 ) {
77
-    if ( is_numeric( $item ) ) {
78
-        $item = get_post( $item );
79
-        if ( ! $item || 'wpi_item' !== $item->post_type )
76
+function wpinv_get_item($item = 0) {
77
+    if (is_numeric($item)) {
78
+        $item = get_post($item);
79
+        if (!$item || 'wpi_item' !== $item->post_type)
80 80
             return null;
81 81
         return $item;
82 82
     }
@@ -89,150 +89,150 @@  discard block
 block discarded – undo
89 89
 
90 90
     $item = get_posts($args);
91 91
 
92
-    if ( $item ) {
92
+    if ($item) {
93 93
         return $item[0];
94 94
     }
95 95
 
96 96
     return null;
97 97
 }
98 98
 
99
-function wpinv_is_free_item( $item_id = 0 ) {
100
-    if( empty( $item_id ) ) {
99
+function wpinv_is_free_item($item_id = 0) {
100
+    if (empty($item_id)) {
101 101
         return false;
102 102
     }
103 103
 
104
-    $item = new WPInv_Item( $item_id );
104
+    $item = new WPInv_Item($item_id);
105 105
     
106 106
     return $item->is_free();
107 107
 }
108 108
 
109
-function wpinv_item_is_editable( $item = 0 ) {
110
-    if ( !empty( $item ) && is_a( $item, 'WP_Post' ) ) {
109
+function wpinv_item_is_editable($item = 0) {
110
+    if (!empty($item) && is_a($item, 'WP_Post')) {
111 111
         $item = $item->ID;
112 112
     }
113 113
         
114
-    if ( empty( $item ) ) {
114
+    if (empty($item)) {
115 115
         return true;
116 116
     }
117 117
 
118
-    $item = new WPInv_Item( $item );
118
+    $item = new WPInv_Item($item);
119 119
     
120
-    return (bool) $item->is_editable();
120
+    return (bool)$item->is_editable();
121 121
 }
122 122
 
123
-function wpinv_get_item_price( $item_id = 0 ) {
124
-    if( empty( $item_id ) ) {
123
+function wpinv_get_item_price($item_id = 0) {
124
+    if (empty($item_id)) {
125 125
         return false;
126 126
     }
127 127
 
128
-    $item = new WPInv_Item( $item_id );
128
+    $item = new WPInv_Item($item_id);
129 129
     
130 130
     return $item->get_price();
131 131
 }
132 132
 
133
-function wpinv_is_recurring_item( $item_id = 0 ) {
134
-    if( empty( $item_id ) ) {
133
+function wpinv_is_recurring_item($item_id = 0) {
134
+    if (empty($item_id)) {
135 135
         return false;
136 136
     }
137 137
 
138
-    $item = new WPInv_Item( $item_id );
138
+    $item = new WPInv_Item($item_id);
139 139
     
140 140
     return $item->is_recurring();
141 141
 }
142 142
 
143
-function wpinv_item_price( $item_id = 0 ) {
144
-    if( empty( $item_id ) ) {
143
+function wpinv_item_price($item_id = 0) {
144
+    if (empty($item_id)) {
145 145
         return false;
146 146
     }
147 147
 
148
-    $price = wpinv_get_item_price( $item_id );
149
-    $price = wpinv_price( wpinv_format_amount( $price ) );
148
+    $price = wpinv_get_item_price($item_id);
149
+    $price = wpinv_price(wpinv_format_amount($price));
150 150
     
151
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
151
+    return apply_filters('wpinv_item_price', $price, $item_id);
152 152
 }
153 153
 
154
-function wpinv_item_show_price( $item_id = 0, $echo = true ) {
155
-    if ( empty( $item_id ) ) {
154
+function wpinv_item_show_price($item_id = 0, $echo = true) {
155
+    if (empty($item_id)) {
156 156
         $item_id = get_the_ID();
157 157
     }
158 158
 
159
-    $price = wpinv_item_price( $item_id );
159
+    $price = wpinv_item_price($item_id);
160 160
 
161
-    $price           = apply_filters( 'wpinv_item_price', wpinv_sanitize_amount( $price ), $item_id );
161
+    $price           = apply_filters('wpinv_item_price', wpinv_sanitize_amount($price), $item_id);
162 162
     $formatted_price = '<span class="wpinv_price" id="wpinv_item_' . $item_id . '">' . $price . '</span>';
163
-    $formatted_price = apply_filters( 'wpinv_item_price_after_html', $formatted_price, $item_id, $price );
163
+    $formatted_price = apply_filters('wpinv_item_price_after_html', $formatted_price, $item_id, $price);
164 164
 
165
-    if ( $echo ) {
165
+    if ($echo) {
166 166
         echo $formatted_price;
167 167
     } else {
168 168
         return $formatted_price;
169 169
     }
170 170
 }
171 171
 
172
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
173
-    if ( is_null( $amount_override ) ) {
174
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
172
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
173
+    if (is_null($amount_override)) {
174
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
175 175
     } else {
176 176
         $original_price = $amount_override;
177 177
     }
178 178
     
179 179
     $price = $original_price;
180 180
 
181
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
181
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
182 182
 }
183 183
 
184
-function wpinv_item_custom_singular_name( $item_id ) {
185
-    if( empty( $item_id ) ) {
184
+function wpinv_item_custom_singular_name($item_id) {
185
+    if (empty($item_id)) {
186 186
         return false;
187 187
     }
188 188
 
189
-    $item = new WPInv_Item( $item_id );
189
+    $item = new WPInv_Item($item_id);
190 190
     
191 191
     return $item->get_custom_singular_name();
192 192
 }
193 193
 
194 194
 function wpinv_get_item_types() {
195 195
     $item_types = array(
196
-            'custom'    => __( 'Standard', 'invoicing' ),
197
-            'fee'       => __( 'Fee', 'invoicing' ),
196
+            'custom'    => __('Standard', 'invoicing'),
197
+            'fee'       => __('Fee', 'invoicing'),
198 198
         );
199
-    return apply_filters( 'wpinv_get_item_types', $item_types );
199
+    return apply_filters('wpinv_get_item_types', $item_types);
200 200
 }
201 201
 
202 202
 function wpinv_item_types() {
203 203
     $item_types = wpinv_get_item_types();
204 204
     
205
-    return ( !empty( $item_types ) ? array_keys( $item_types ) : array() );
205
+    return (!empty($item_types) ? array_keys($item_types) : array());
206 206
 }
207 207
 
208
-function wpinv_get_item_type( $item_id ) {
209
-    if( empty( $item_id ) ) {
208
+function wpinv_get_item_type($item_id) {
209
+    if (empty($item_id)) {
210 210
         return false;
211 211
     }
212 212
 
213
-    $item = new WPInv_Item( $item_id );
213
+    $item = new WPInv_Item($item_id);
214 214
     
215 215
     return $item->get_type();
216 216
 }
217 217
 
218
-function wpinv_item_type( $item_id ) {
218
+function wpinv_item_type($item_id) {
219 219
     $item_types = wpinv_get_item_types();
220 220
     
221
-    $item_type = wpinv_get_item_type( $item_id );
221
+    $item_type = wpinv_get_item_type($item_id);
222 222
     
223
-    if ( empty( $item_type ) ) {
223
+    if (empty($item_type)) {
224 224
         $item_type = '-';
225 225
     }
226 226
     
227
-    $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' );
227
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
228 228
 
229
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
229
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
230 230
 }
231 231
 
232
-function wpinv_record_item_in_log( $item_id = 0, $file_id, $user_info, $ip, $invoice_id ) {
232
+function wpinv_record_item_in_log($item_id = 0, $file_id, $user_info, $ip, $invoice_id) {
233 233
     global $wpinv_logs;
234 234
     
235
-    if ( empty( $wpinv_logs ) ) {
235
+    if (empty($wpinv_logs)) {
236 236
         return false;
237 237
     }
238 238
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         'log_type'		=> 'wpi_item'
242 242
     );
243 243
 
244
-    $user_id = isset( $user_info['user_id'] ) ? $user_info['user_id'] : (int) -1;
244
+    $user_id = isset($user_info['user_id']) ? $user_info['user_id'] : (int) -1;
245 245
 
246 246
     $log_meta = array(
247 247
         'user_info'	=> $user_info,
@@ -251,254 +251,254 @@  discard block
 block discarded – undo
251 251
         'invoice_id'=> $invoice_id,
252 252
     );
253 253
 
254
-    $wpinv_logs->insert_log( $log_data, $log_meta );
254
+    $wpinv_logs->insert_log($log_data, $log_meta);
255 255
 }
256 256
 
257
-function wpinv_remove_item_logs_on_delete( $item_id = 0 ) {
258
-    if ( 'wpi_item' !== get_post_type( $item_id ) )
257
+function wpinv_remove_item_logs_on_delete($item_id = 0) {
258
+    if ('wpi_item' !== get_post_type($item_id))
259 259
         return;
260 260
 
261 261
     global $wpinv_logs;
262 262
     
263
-    if ( empty( $wpinv_logs ) ) {
263
+    if (empty($wpinv_logs)) {
264 264
         return false;
265 265
     }
266 266
 
267 267
     // Remove all log entries related to this item
268
-    $wpinv_logs->delete_logs( $item_id );
268
+    $wpinv_logs->delete_logs($item_id);
269 269
 }
270
-add_action( 'delete_post', 'wpinv_remove_item_logs_on_delete' );
270
+add_action('delete_post', 'wpinv_remove_item_logs_on_delete');
271 271
 
272
-function wpinv_get_random_item( $post_ids = true ) {
273
-    wpinv_get_random_items( 1, $post_ids );
272
+function wpinv_get_random_item($post_ids = true) {
273
+    wpinv_get_random_items(1, $post_ids);
274 274
 }
275 275
 
276
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
277
-    if ( $post_ids ) {
278
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' );
276
+function wpinv_get_random_items($num = 3, $post_ids = true) {
277
+    if ($post_ids) {
278
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids');
279 279
     } else {
280
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num );
280
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num);
281 281
     }
282 282
     
283
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
283
+    $args = apply_filters('wpinv_get_random_items', $args);
284 284
     
285
-    return get_posts( $args );
285
+    return get_posts($args);
286 286
 }
287 287
 
288
-function wpinv_get_item_token( $url = '' ) {
288
+function wpinv_get_item_token($url = '') {
289 289
     $args    = array();
290
-    $hash    = apply_filters( 'wpinv_get_url_token_algorithm', 'sha256' );
291
-    $secret  = apply_filters( 'wpinv_get_url_token_secret', hash( $hash, wp_salt() ) );
290
+    $hash    = apply_filters('wpinv_get_url_token_algorithm', 'sha256');
291
+    $secret  = apply_filters('wpinv_get_url_token_secret', hash($hash, wp_salt()));
292 292
 
293
-    $parts   = parse_url( $url );
293
+    $parts   = parse_url($url);
294 294
     $options = array();
295 295
 
296
-    if ( isset( $parts['query'] ) ) {
297
-        wp_parse_str( $parts['query'], $query_args );
296
+    if (isset($parts['query'])) {
297
+        wp_parse_str($parts['query'], $query_args);
298 298
 
299
-        if ( ! empty( $query_args['o'] ) ) {
300
-            $options = explode( ':', rawurldecode( $query_args['o'] ) );
299
+        if (!empty($query_args['o'])) {
300
+            $options = explode(':', rawurldecode($query_args['o']));
301 301
 
302
-            if ( in_array( 'ip', $options ) ) {
302
+            if (in_array('ip', $options)) {
303 303
                 $args['ip'] = wpinv_get_ip();
304 304
             }
305 305
 
306
-            if ( in_array( 'ua', $options ) ) {
306
+            if (in_array('ua', $options)) {
307 307
                 $ua = wpinv_get_user_agent();
308
-                $args['user_agent'] = rawurlencode( $ua );
308
+                $args['user_agent'] = rawurlencode($ua);
309 309
             }
310 310
         }
311 311
     }
312 312
 
313
-    $args = apply_filters( 'wpinv_get_url_token_args', $args, $url, $options );
313
+    $args = apply_filters('wpinv_get_url_token_args', $args, $url, $options);
314 314
 
315 315
     $args['secret'] = $secret;
316 316
     $args['token']  = false;
317 317
 
318
-    $url   = add_query_arg( $args, $url );
319
-    $parts = parse_url( $url );
318
+    $url   = add_query_arg($args, $url);
319
+    $parts = parse_url($url);
320 320
 
321
-    if ( ! isset( $parts['path'] ) ) {
321
+    if (!isset($parts['path'])) {
322 322
         $parts['path'] = '';
323 323
     }
324 324
 
325
-    $token = md5( $parts['path'] . '?' . $parts['query'] );
325
+    $token = md5($parts['path'] . '?' . $parts['query']);
326 326
 
327 327
     return $token;
328 328
 }
329 329
 
330
-function wpinv_validate_url_token( $url = '' ) {
330
+function wpinv_validate_url_token($url = '') {
331 331
     $ret   = false;
332
-    $parts = parse_url( $url );
332
+    $parts = parse_url($url);
333 333
 
334
-    if ( isset( $parts['query'] ) ) {
335
-        wp_parse_str( $parts['query'], $query_args );
334
+    if (isset($parts['query'])) {
335
+        wp_parse_str($parts['query'], $query_args);
336 336
 
337
-        $allowed = apply_filters( 'wpinv_url_token_allowed_params', array(
337
+        $allowed = apply_filters('wpinv_url_token_allowed_params', array(
338 338
             'item',
339 339
             'ttl',
340 340
             'token'
341
-        ) );
341
+        ));
342 342
 
343 343
         $remove = array();
344 344
 
345
-        foreach( $query_args as $key => $value ) {
346
-            if( false === in_array( $key, $allowed ) ) {
345
+        foreach ($query_args as $key => $value) {
346
+            if (false === in_array($key, $allowed)) {
347 347
                 $remove[] = $key;
348 348
             }
349 349
         }
350 350
 
351
-        if( ! empty( $remove ) ) {
352
-            $url = remove_query_arg( $remove, $url );
351
+        if (!empty($remove)) {
352
+            $url = remove_query_arg($remove, $url);
353 353
         }
354 354
 
355
-        if ( isset( $query_args['ttl'] ) && current_time( 'timestamp' ) > $query_args['ttl'] ) {
356
-            wp_die( apply_filters( 'wpinv_item_link_expired_text', __( 'Sorry but your item link has expired.', 'invoicing' ) ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
355
+        if (isset($query_args['ttl']) && current_time('timestamp') > $query_args['ttl']) {
356
+            wp_die(apply_filters('wpinv_item_link_expired_text', __('Sorry but your item link has expired.', 'invoicing')), __('Error', 'invoicing'), array('response' => 403));
357 357
         }
358 358
 
359
-        if ( isset( $query_args['token'] ) && $query_args['token'] == wpinv_get_item_token( $url ) ) {
359
+        if (isset($query_args['token']) && $query_args['token'] == wpinv_get_item_token($url)) {
360 360
             $ret = true;
361 361
         }
362 362
 
363 363
     }
364 364
 
365
-    return apply_filters( 'wpinv_validate_url_token', $ret, $url, $query_args );
365
+    return apply_filters('wpinv_validate_url_token', $ret, $url, $query_args);
366 366
 }
367 367
 
368
-function wpinv_item_in_cart( $item_id = 0, $options = array() ) {
368
+function wpinv_item_in_cart($item_id = 0, $options = array()) {
369 369
     $cart_items = wpinv_get_cart_contents();
370 370
 
371 371
     $ret = false;
372 372
 
373
-    if ( is_array( $cart_items ) ) {
374
-        foreach ( $cart_items as $item ) {
375
-            if ( $item['id'] == $item_id ) {
373
+    if (is_array($cart_items)) {
374
+        foreach ($cart_items as $item) {
375
+            if ($item['id'] == $item_id) {
376 376
                 $ret = true;
377 377
                 break;
378 378
             }
379 379
         }
380 380
     }
381 381
 
382
-    return (bool) apply_filters( 'wpinv_item_in_cart', $ret, $item_id, $options );
382
+    return (bool)apply_filters('wpinv_item_in_cart', $ret, $item_id, $options);
383 383
 }
384 384
 
385
-function wpinv_get_cart_item_tax( $item_id = 0, $subtotal = '', $options = array() ) {
385
+function wpinv_get_cart_item_tax($item_id = 0, $subtotal = '', $options = array()) {
386 386
     $tax = 0;
387
-    if ( ! wpinv_item_is_tax_exclusive( $item_id ) ) {
388
-        $country = !empty( $_POST['country'] ) ? $_POST['country'] : false;
389
-        $state   = isset( $_POST['state'] ) ? $_POST['state'] : '';
387
+    if (!wpinv_item_is_tax_exclusive($item_id)) {
388
+        $country = !empty($_POST['country']) ? $_POST['country'] : false;
389
+        $state   = isset($_POST['state']) ? $_POST['state'] : '';
390 390
 
391
-        $tax = wpinv_calculate_tax( $subtotal, $country, $state, $item_id );
391
+        $tax = wpinv_calculate_tax($subtotal, $country, $state, $item_id);
392 392
     }
393 393
 
394
-    return apply_filters( 'wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options );
394
+    return apply_filters('wpinv_get_cart_item_tax', $tax, $item_id, $subtotal, $options);
395 395
 }
396 396
 
397
-function wpinv_cart_item_price( $item ) {
398
-    $item_id    = isset( $item['id'] ) ? $item['id'] : 0;
399
-    $price      = isset( $item['item_price'] ) ? wpinv_round_amount( $item['item_price'] ) : 0;
400
-    $tax        = wpinv_price( wpinv_format_amount( $item['tax'] ) );
397
+function wpinv_cart_item_price($item) {
398
+    $item_id    = isset($item['id']) ? $item['id'] : 0;
399
+    $price      = isset($item['item_price']) ? wpinv_round_amount($item['item_price']) : 0;
400
+    $tax        = wpinv_price(wpinv_format_amount($item['tax']));
401 401
     
402
-    if ( !wpinv_is_free_item( $item_id ) && !wpinv_item_is_tax_exclusive( $item_id ) ) {
403
-        if ( wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax() ) {
402
+    if (!wpinv_is_free_item($item_id) && !wpinv_item_is_tax_exclusive($item_id)) {
403
+        if (wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax()) {
404 404
             $price += $tax;
405 405
         }
406 406
         
407
-        if( !wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax() ) {
407
+        if (!wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax()) {
408 408
             $price -= $tax;
409 409
         }        
410 410
     }
411 411
 
412
-    $price = wpinv_price( wpinv_format_amount( $price ) );
412
+    $price = wpinv_price(wpinv_format_amount($price));
413 413
 
414
-    return apply_filters( 'wpinv_cart_item_price_label', $price, $item );
414
+    return apply_filters('wpinv_cart_item_price_label', $price, $item);
415 415
 }
416 416
 
417
-function wpinv_cart_item_subtotal( $item ) {
418
-    $subtotal   = isset( $item['subtotal'] ) ? $item['subtotal'] : 0;
419
-    $subtotal   = wpinv_price( wpinv_format_amount( $subtotal ) );
417
+function wpinv_cart_item_subtotal($item) {
418
+    $subtotal   = isset($item['subtotal']) ? $item['subtotal'] : 0;
419
+    $subtotal   = wpinv_price(wpinv_format_amount($subtotal));
420 420
 
421
-    return apply_filters( 'wpinv_cart_item_subtotal_label', $subtotal, $item );
421
+    return apply_filters('wpinv_cart_item_subtotal_label', $subtotal, $item);
422 422
 }
423 423
 
424
-function wpinv_cart_item_tax( $item ) {
424
+function wpinv_cart_item_tax($item) {
425 425
     $tax        = '';
426 426
     $tax_rate   = '';
427 427
     
428
-    if ( isset( $item['tax'] ) && $item['tax'] > 0 && $item['subtotal'] > 0 ) {
429
-        $tax      = wpinv_price( wpinv_format_amount( $item['tax'] ) );
430
-        $tax_rate = !empty( $item['vat_rate'] ) ? $item['vat_rate'] : ( $item['tax'] / $item['subtotal'] ) * 100;
431
-        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
428
+    if (isset($item['tax']) && $item['tax'] > 0 && $item['subtotal'] > 0) {
429
+        $tax      = wpinv_price(wpinv_format_amount($item['tax']));
430
+        $tax_rate = !empty($item['vat_rate']) ? $item['vat_rate'] : ($item['tax'] / $item['subtotal']) * 100;
431
+        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
432 432
         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate normal small">(' . $tax_rate . '%)</small>' : '';
433 433
     }
434 434
     
435
-    $tax        = $tax . $tax_rate;
435
+    $tax = $tax . $tax_rate;
436 436
     
437
-    if ( $tax === '' ) {
437
+    if ($tax === '') {
438 438
         $tax = 0; // Zero tax
439 439
     }
440 440
 
441
-    return apply_filters( 'wpinv_cart_item_tax_label', $tax, $item );
441
+    return apply_filters('wpinv_cart_item_tax_label', $tax, $item);
442 442
 }
443 443
 
444
-function wpinv_get_cart_item_price( $item_id = 0, $cart_item = array(), $options = array(), $remove_tax_from_inclusive = false ) {
444
+function wpinv_get_cart_item_price($item_id = 0, $cart_item = array(), $options = array(), $remove_tax_from_inclusive = false) {
445 445
     $price = 0;
446 446
     
447 447
     // Set custom price
448
-    if ( isset( $cart_item['custom_price'] ) && $cart_item['custom_price'] !== '' ) {
448
+    if (isset($cart_item['custom_price']) && $cart_item['custom_price'] !== '') {
449 449
         $price = $cart_item['custom_price'];
450 450
     } else {
451
-        $variable_prices = wpinv_has_variable_prices( $item_id );
451
+        $variable_prices = wpinv_has_variable_prices($item_id);
452 452
 
453
-        if ( $variable_prices ) {
454
-            $prices = wpinv_get_variable_prices( $item_id );
453
+        if ($variable_prices) {
454
+            $prices = wpinv_get_variable_prices($item_id);
455 455
 
456
-            if ( $prices ) {
457
-                if( ! empty( $options ) ) {
458
-                    $price = isset( $prices[ $options['price_id'] ] ) ? $prices[ $options['price_id'] ]['amount'] : false;
456
+            if ($prices) {
457
+                if (!empty($options)) {
458
+                    $price = isset($prices[$options['price_id']]) ? $prices[$options['price_id']]['amount'] : false;
459 459
                 } else {
460 460
                     $price = false;
461 461
                 }
462 462
             }
463 463
         }
464 464
 
465
-        if( ! $variable_prices || false === $price ) {
466
-            if($cart_item['item_price'] > 0){
465
+        if (!$variable_prices || false === $price) {
466
+            if ($cart_item['item_price'] > 0) {
467 467
                 $price = $cart_item['item_price'];
468 468
             } else {
469 469
                 // Get the standard Item price if not using variable prices
470
-                $price = wpinv_get_item_price( $item_id );
470
+                $price = wpinv_get_item_price($item_id);
471 471
             }
472 472
         }
473 473
     }
474 474
 
475
-    if ( $remove_tax_from_inclusive && wpinv_prices_include_tax() ) {
476
-        $price -= wpinv_get_cart_item_tax( $item_id, $price, $options );
475
+    if ($remove_tax_from_inclusive && wpinv_prices_include_tax()) {
476
+        $price -= wpinv_get_cart_item_tax($item_id, $price, $options);
477 477
     }
478 478
 
479
-    return apply_filters( 'wpinv_cart_item_price', $price, $item_id, $cart_item, $options, $remove_tax_from_inclusive );
479
+    return apply_filters('wpinv_cart_item_price', $price, $item_id, $cart_item, $options, $remove_tax_from_inclusive);
480 480
 }
481 481
 
482
-function wpinv_get_cart_item_price_id( $item = array() ) {
483
-    if( isset( $item['item_number'] ) ) {
484
-        $price_id = isset( $item['item_number']['options']['price_id'] ) ? $item['item_number']['options']['price_id'] : null;
482
+function wpinv_get_cart_item_price_id($item = array()) {
483
+    if (isset($item['item_number'])) {
484
+        $price_id = isset($item['item_number']['options']['price_id']) ? $item['item_number']['options']['price_id'] : null;
485 485
     } else {
486
-        $price_id = isset( $item['options']['price_id'] ) ? $item['options']['price_id'] : null;
486
+        $price_id = isset($item['options']['price_id']) ? $item['options']['price_id'] : null;
487 487
     }
488 488
     return $price_id;
489 489
 }
490 490
 
491
-function wpinv_get_cart_item_price_name( $item = array() ) {
492
-    $price_id = (int)wpinv_get_cart_item_price_id( $item );
493
-    $prices   = wpinv_get_variable_prices( $item['id'] );
494
-    $name     = ! empty( $prices[ $price_id ] ) ? $prices[ $price_id ]['name'] : '';
495
-    return apply_filters( 'wpinv_get_cart_item_price_name', $name, $item['id'], $price_id, $item );
491
+function wpinv_get_cart_item_price_name($item = array()) {
492
+    $price_id = (int)wpinv_get_cart_item_price_id($item);
493
+    $prices   = wpinv_get_variable_prices($item['id']);
494
+    $name     = !empty($prices[$price_id]) ? $prices[$price_id]['name'] : '';
495
+    return apply_filters('wpinv_get_cart_item_price_name', $name, $item['id'], $price_id, $item);
496 496
 }
497 497
 
498
-function wpinv_get_cart_item_name( $item = array() ) {
499
-    $item_title = !empty( $item['name'] ) ? $item['name'] : get_the_title( $item['id'] );
498
+function wpinv_get_cart_item_name($item = array()) {
499
+    $item_title = !empty($item['name']) ? $item['name'] : get_the_title($item['id']);
500 500
 
501
-    if ( empty( $item_title ) ) {
501
+    if (empty($item_title)) {
502 502
         $item_title = $item['id'];
503 503
     }
504 504
 
@@ -508,23 +508,23 @@  discard block
 block discarded – undo
508 508
     }
509 509
     */
510 510
 
511
-    return apply_filters( 'wpinv_get_cart_item_name', $item_title, $item['id'], $item );
511
+    return apply_filters('wpinv_get_cart_item_name', $item_title, $item['id'], $item);
512 512
 }
513 513
 
514
-function wpinv_has_variable_prices( $item_id = 0 ) {
514
+function wpinv_has_variable_prices($item_id = 0) {
515 515
     return false;
516 516
 }
517 517
 
518
-function wpinv_get_item_position_in_cart( $item_id = 0, $options = array() ) {
518
+function wpinv_get_item_position_in_cart($item_id = 0, $options = array()) {
519 519
     $cart_items = wpinv_get_cart_contents();
520 520
 
521
-    if ( !is_array( $cart_items ) ) {
521
+    if (!is_array($cart_items)) {
522 522
         return false; // Empty cart
523 523
     } else {
524
-        foreach ( $cart_items as $position => $item ) {
525
-            if ( $item['id'] == $item_id ) {
526
-                if ( isset( $options['price_id'] ) && isset( $item['options']['price_id'] ) ) {
527
-                    if ( (int) $options['price_id'] == (int) $item['options']['price_id'] ) {
524
+        foreach ($cart_items as $position => $item) {
525
+            if ($item['id'] == $item_id) {
526
+                if (isset($options['price_id']) && isset($item['options']['price_id'])) {
527
+                    if ((int)$options['price_id'] == (int)$item['options']['price_id']) {
528 528
                         return $position;
529 529
                     }
530 530
                 } else {
@@ -537,80 +537,80 @@  discard block
 block discarded – undo
537 537
     return false; // Not found
538 538
 }
539 539
 
540
-function wpinv_get_cart_item_quantity( $item ) {
541
-    if ( wpinv_item_quantities_enabled() ) {
542
-        $quantity = !empty( $item['quantity'] ) && (int)$item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
540
+function wpinv_get_cart_item_quantity($item) {
541
+    if (wpinv_item_quantities_enabled()) {
542
+        $quantity = !empty($item['quantity']) && (int)$item['quantity'] > 0 ? absint($item['quantity']) : 1;
543 543
     } else {
544 544
         $quantity = 1;
545 545
     }
546 546
     
547
-    if ( $quantity < 1 ) {
547
+    if ($quantity < 1) {
548 548
         $quantity = 1;
549 549
     }
550 550
     
551
-    return apply_filters( 'wpinv_get_cart_item_quantity', $quantity, $item );
551
+    return apply_filters('wpinv_get_cart_item_quantity', $quantity, $item);
552 552
 }
553 553
 
554
-function wpinv_get_item_suffix( $item, $html = true ) {
555
-    if ( empty( $item ) ) {
554
+function wpinv_get_item_suffix($item, $html = true) {
555
+    if (empty($item)) {
556 556
         return NULL;
557 557
     }
558 558
     
559
-    if ( is_int( $item ) ) {
560
-        $item = new WPInv_Item( $item );
559
+    if (is_int($item)) {
560
+        $item = new WPInv_Item($item);
561 561
     }
562 562
     
563
-    if ( !( is_object( $item ) && is_a( $item, 'WPInv_Item' ) ) ) {
563
+    if (!(is_object($item) && is_a($item, 'WPInv_Item'))) {
564 564
         return NULL;
565 565
     }
566 566
     
567
-    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '';
567
+    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '';
568 568
     
569
-    if ( !$html && $suffix ) {
570
-        $suffix = strip_tags( $suffix );
569
+    if (!$html && $suffix) {
570
+        $suffix = strip_tags($suffix);
571 571
     }
572 572
     
573
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
573
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
574 574
 }
575 575
 
576
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
577
-    if ( empty( $item ) ) {
576
+function wpinv_remove_item($item = 0, $force_delete = false) {
577
+    if (empty($item)) {
578 578
         return NULL;
579 579
     }
580 580
     
581
-    if ( is_int( $item ) ) {
582
-        $item = new WPInv_Item( $item );
581
+    if (is_int($item)) {
582
+        $item = new WPInv_Item($item);
583 583
     }
584 584
     
585
-    if ( !( is_object( $item ) && is_a( $item, 'WPInv_Item' ) ) ) {
585
+    if (!(is_object($item) && is_a($item, 'WPInv_Item'))) {
586 586
         return NULL;
587 587
     }
588 588
     
589
-    do_action( 'wpinv_pre_delete_item', $item );
589
+    do_action('wpinv_pre_delete_item', $item);
590 590
 
591
-    wp_delete_post( $item->ID, $force_delete );
591
+    wp_delete_post($item->ID, $force_delete);
592 592
 
593
-    do_action( 'wpinv_post_delete_item', $item );
593
+    do_action('wpinv_post_delete_item', $item);
594 594
 }
595 595
 
596
-function wpinv_can_delete_item( $post_id ) {
597
-    $return = current_user_can( 'manage_options' ) ? true : false;
596
+function wpinv_can_delete_item($post_id) {
597
+    $return = current_user_can('manage_options') ? true : false;
598 598
     
599
-    if ( $return && wpinv_item_in_use( $post_id ) ) {
599
+    if ($return && wpinv_item_in_use($post_id)) {
600 600
         $return = false; // Don't delete item already use in invoices.
601 601
     }
602 602
     
603
-    return apply_filters( 'wpinv_can_delete_item', $return, $post_id );
603
+    return apply_filters('wpinv_can_delete_item', $return, $post_id);
604 604
 }
605 605
 
606 606
 function wpinv_admin_action_delete() {
607 607
     $screen = get_current_screen();
608 608
     
609
-    if ( !empty( $screen->post_type ) && $screen->post_type == 'wpi_item' && !empty( $_REQUEST['post'] ) && is_array( $_REQUEST['post'] ) ) {
609
+    if (!empty($screen->post_type) && $screen->post_type == 'wpi_item' && !empty($_REQUEST['post']) && is_array($_REQUEST['post'])) {
610 610
         $post_ids = array();
611 611
         
612
-        foreach ( $_REQUEST['post'] as $post_id ) {
613
-            if ( !wpinv_can_delete_item( $post_id ) ) {
612
+        foreach ($_REQUEST['post'] as $post_id) {
613
+            if (!wpinv_can_delete_item($post_id)) {
614 614
                 continue;
615 615
             }
616 616
             
@@ -620,86 +620,86 @@  discard block
 block discarded – undo
620 620
         $_REQUEST['post'] = $post_ids;
621 621
     }
622 622
 }
623
-add_action( 'admin_action_trash', 'wpinv_admin_action_delete', -10 );
624
-add_action( 'admin_action_delete', 'wpinv_admin_action_delete', -10 );
623
+add_action('admin_action_trash', 'wpinv_admin_action_delete', -10);
624
+add_action('admin_action_delete', 'wpinv_admin_action_delete', -10);
625 625
 
626
-function wpinv_check_delete_item( $check, $post, $force_delete ) {
627
-    if ( $post->post_type == 'wpi_item' ) {
628
-        if ( $force_delete && !wpinv_can_delete_item( $post->ID ) ) {
626
+function wpinv_check_delete_item($check, $post, $force_delete) {
627
+    if ($post->post_type == 'wpi_item') {
628
+        if ($force_delete && !wpinv_can_delete_item($post->ID)) {
629 629
             return true;
630 630
         }
631 631
     }
632 632
     
633 633
     return $check;
634 634
 }
635
-add_filter( 'pre_delete_post', 'wpinv_check_delete_item', 10, 3 );
635
+add_filter('pre_delete_post', 'wpinv_check_delete_item', 10, 3);
636 636
 
637
-function wpinv_item_in_use( $item_id ) {
637
+function wpinv_item_in_use($item_id) {
638 638
     global $wpdb, $wpi_items_in_use;
639 639
     
640
-    if ( !$item_id > 0 ) {
640
+    if (!$item_id > 0) {
641 641
         return false;
642 642
     }
643 643
     
644
-    if ( !empty( $wpi_items_in_use ) ) {
645
-        if ( isset( $wpi_items_in_use[$item_id] ) ) {
644
+    if (!empty($wpi_items_in_use)) {
645
+        if (isset($wpi_items_in_use[$item_id])) {
646 646
             return $wpi_items_in_use[$item_id];
647 647
         }
648 648
     } else {
649 649
         $wpi_items_in_use = array();
650 650
     }
651 651
     
652
-    $statuses   = array_keys( wpinv_get_invoice_statuses( true, true ) );
652
+    $statuses = array_keys(wpinv_get_invoice_statuses(true, true));
653 653
     
654
-    $query  = "SELECT p.ID FROM " . $wpdb->posts . " AS p INNER JOIN " . $wpdb->postmeta . " AS pm ON p.ID = pm.post_id WHERE p.post_type = 'wpi_invoice' AND p.post_status IN( '" . implode( "','", $statuses ) . "' ) AND pm.meta_key = '_wpinv_item_ids' AND FIND_IN_SET( '" . (int)$item_id . "', pm.meta_value )";
655
-    $in_use = $wpdb->get_var( $query ) > 0 ? true : false;
654
+    $query  = "SELECT p.ID FROM " . $wpdb->posts . " AS p INNER JOIN " . $wpdb->postmeta . " AS pm ON p.ID = pm.post_id WHERE p.post_type = 'wpi_invoice' AND p.post_status IN( '" . implode("','", $statuses) . "' ) AND pm.meta_key = '_wpinv_item_ids' AND FIND_IN_SET( '" . (int)$item_id . "', pm.meta_value )";
655
+    $in_use = $wpdb->get_var($query) > 0 ? true : false;
656 656
     
657 657
     $wpi_items_in_use[$item_id] = $in_use;
658 658
     
659 659
     return $in_use;
660 660
 }
661 661
 
662
-function wpinv_create_item( $args = array(), $wp_error = false, $force_update = false ) {
662
+function wpinv_create_item($args = array(), $wp_error = false, $force_update = false) {
663 663
     // Set some defaults
664 664
     $defaults = array(
665
-        'type'                 => 'custom',                                                // Optional. Item type. Default 'custom'.
666
-        'title'                => '',                                                      // Required. Item title.
667
-        'custom_id'            => 0,                                                       // Optional. Any integer or non numeric id. Must be unique within item type.
668
-        'price'                => '0.00',                                                  // Optional. Item price. Default '0.00'.
669
-        'status'               => 'pending',                                               // Optional. pending, publish
670
-        'custom_name'          => '',                                                      // Optional. Plural sub title for item.
671
-        'custom_singular_name' => '',                                                      // Optional. Singular sub title for item.
672
-        'vat_rule'             => 'digital',                                               // Optional. digital => Digital item, physical => Physical item
673
-        'editable'             => true,                                                    // Optional. Item editable from Items list page? Default true.
674
-        'excerpt'              => '',                                                      // Optional. Item short description
665
+        'type'                 => 'custom', // Optional. Item type. Default 'custom'.
666
+        'title'                => '', // Required. Item title.
667
+        'custom_id'            => 0, // Optional. Any integer or non numeric id. Must be unique within item type.
668
+        'price'                => '0.00', // Optional. Item price. Default '0.00'.
669
+        'status'               => 'pending', // Optional. pending, publish
670
+        'custom_name'          => '', // Optional. Plural sub title for item.
671
+        'custom_singular_name' => '', // Optional. Singular sub title for item.
672
+        'vat_rule'             => 'digital', // Optional. digital => Digital item, physical => Physical item
673
+        'editable'             => true, // Optional. Item editable from Items list page? Default true.
674
+        'excerpt'              => '', // Optional. Item short description
675 675
         /* Recurring item fields */
676
-        'is_recurring'         => 0,                                                       // Optional. 1 => Allow recurring or 0 => Don't allow recurring
677
-        'recurring_period'     => 'M',                                                     // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
678
-        'recurring_interval'   => 0,                                                       // Optional. Integer value between 1 - 90.
679
-        'recurring_limit'      => 0,                                                       // Optional. Any integer number. 0 for recurring forever until cancelled.
680
-        'free_trial'           => 0,                                                       // Optional. 1 => Allow free trial or 0 => Don't free trial
681
-        'trial_period'         => 'M',                                                     // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
682
-        'trial_interval'       => 0,                                                       // Optional. Any integer number.
676
+        'is_recurring'         => 0, // Optional. 1 => Allow recurring or 0 => Don't allow recurring
677
+        'recurring_period'     => 'M', // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
678
+        'recurring_interval'   => 0, // Optional. Integer value between 1 - 90.
679
+        'recurring_limit'      => 0, // Optional. Any integer number. 0 for recurring forever until cancelled.
680
+        'free_trial'           => 0, // Optional. 1 => Allow free trial or 0 => Don't free trial
681
+        'trial_period'         => 'M', // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
682
+        'trial_interval'       => 0, // Optional. Any integer number.
683 683
     );
684 684
 
685
-    $data = wp_parse_args( $args, $defaults );
685
+    $data = wp_parse_args($args, $defaults);
686 686
 
687
-    if ( empty( $data['type'] ) ) {
687
+    if (empty($data['type'])) {
688 688
         $data['type'] = 'custom';
689 689
     }
690 690
 
691
-    if ( !empty( $data['custom_id'] ) ) {
692
-        $item = wpinv_get_item_by( 'custom_id', $data['custom_id'], $data['type'] );
691
+    if (!empty($data['custom_id'])) {
692
+        $item = wpinv_get_item_by('custom_id', $data['custom_id'], $data['type']);
693 693
     } else {
694 694
         $item = NULL;
695 695
     }
696 696
 
697
-    if ( !empty( $item ) ) {
698
-        if ( $force_update ) {
699
-            if ( empty( $args['ID'] ) ) {
697
+    if (!empty($item)) {
698
+        if ($force_update) {
699
+            if (empty($args['ID'])) {
700 700
                 $args['ID'] = $item->ID;
701 701
             }
702
-            return wpinv_update_item( $args, $wp_error );
702
+            return wpinv_update_item($args, $wp_error);
703 703
         }
704 704
 
705 705
         return $item;
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
     $meta['custom_id']              = $data['custom_id'];
711 711
     $meta['custom_singular_name']   = $data['custom_singular_name'];
712 712
     $meta['custom_name']            = $data['custom_name'];
713
-    $meta['price']                  = wpinv_round_amount( $data['price'] );
713
+    $meta['price']                  = wpinv_round_amount($data['price']);
714 714
     $meta['editable']               = (int)$data['editable'];
715 715
     $meta['vat_rule']               = $data['vat_rule'];
716 716
     $meta['vat_class']              = '_standard';
717 717
     
718
-    if ( !empty( $data['is_recurring'] ) ) {
718
+    if (!empty($data['is_recurring'])) {
719 719
         $meta['is_recurring']       = $data['is_recurring'];
720 720
         $meta['recurring_period']   = $data['recurring_period'];
721
-        $meta['recurring_interval'] = absint( $data['recurring_interval'] );
722
-        $meta['recurring_limit']    = absint( $data['recurring_limit'] );
721
+        $meta['recurring_interval'] = absint($data['recurring_interval']);
722
+        $meta['recurring_limit']    = absint($data['recurring_limit']);
723 723
         $meta['free_trial']         = $data['free_trial'];
724 724
         $meta['trial_period']       = $data['trial_period'];
725
-        $meta['trial_interval']     = absint( $data['trial_interval'] );
725
+        $meta['trial_interval']     = absint($data['trial_interval']);
726 726
     } else {
727 727
         $meta['is_recurring']       = 0;
728 728
         $meta['recurring_period']   = '';
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
         $meta['trial_interval']     = '';
734 734
     }
735 735
     
736
-    $post_data  = array( 
736
+    $post_data = array( 
737 737
         'post_title'    => $data['title'],
738 738
         'post_excerpt'  => $data['excerpt'],
739 739
         'post_status'   => $data['status'],
@@ -741,89 +741,89 @@  discard block
 block discarded – undo
741 741
     );
742 742
 
743 743
     $item = new WPInv_Item();
744
-    $return = $item->create( $post_data, $wp_error );
744
+    $return = $item->create($post_data, $wp_error);
745 745
 
746
-    if ( $return && !empty( $item ) && !is_wp_error( $return ) ) {
746
+    if ($return && !empty($item) && !is_wp_error($return)) {
747 747
         return $item;
748 748
     }
749 749
 
750
-    if ( $wp_error && is_wp_error( $return ) ) {
750
+    if ($wp_error && is_wp_error($return)) {
751 751
         return $return;
752 752
     }
753 753
     return 0;
754 754
 }
755 755
 
756
-function wpinv_update_item( $args = array(), $wp_error = false ) {
757
-    $item = !empty( $args['ID'] ) ? new WPInv_Item( $args['ID'] ) : NULL;
756
+function wpinv_update_item($args = array(), $wp_error = false) {
757
+    $item = !empty($args['ID']) ? new WPInv_Item($args['ID']) : NULL;
758 758
 
759
-    if ( empty( $item ) || !( !empty( $item->post_type ) && $item->post_type == 'wpi_item' ) ) {
760
-        if ( $wp_error ) {
761
-            return new WP_Error( 'wpinv_invalid_item', __( 'Invalid item.', 'invoicing' ) );
759
+    if (empty($item) || !(!empty($item->post_type) && $item->post_type == 'wpi_item')) {
760
+        if ($wp_error) {
761
+            return new WP_Error('wpinv_invalid_item', __('Invalid item.', 'invoicing'));
762 762
         }
763 763
         return 0;
764 764
     }
765 765
     
766
-    if ( !empty( $args['custom_id'] ) ) {
767
-        $item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) );
766
+    if (!empty($args['custom_id'])) {
767
+        $item_exists = wpinv_get_item_by('custom_id', $args['custom_id'], (!empty($args['type']) ? $args['type'] : $item->type));
768 768
         
769
-        if ( !empty( $item_exists ) && $item_exists->ID != $args['ID'] ) {
770
-            if ( $wp_error ) {
771
-                return new WP_Error( 'wpinv_invalid_custom_id', __( 'Item with custom id already exists.', 'invoicing' ) );
769
+        if (!empty($item_exists) && $item_exists->ID != $args['ID']) {
770
+            if ($wp_error) {
771
+                return new WP_Error('wpinv_invalid_custom_id', __('Item with custom id already exists.', 'invoicing'));
772 772
             }
773 773
             return 0;
774 774
         }
775 775
     }
776 776
 
777
-    $meta_fields = array( 'type', 'custom_id', 'custom_singular_name', 'custom_name', 'price', 'editable', 'vat_rule', 'vat_class', 'is_recurring', 'recurring_period', 'recurring_interval', 'recurring_limit', 'free_trial', 'trial_period', 'trial_interval' );
777
+    $meta_fields = array('type', 'custom_id', 'custom_singular_name', 'custom_name', 'price', 'editable', 'vat_rule', 'vat_class', 'is_recurring', 'recurring_period', 'recurring_interval', 'recurring_limit', 'free_trial', 'trial_period', 'trial_interval');
778 778
 
779 779
     $post_data = array();
780
-    if ( isset( $args['title'] ) ) { 
780
+    if (isset($args['title'])) { 
781 781
         $post_data['post_title'] = $args['title'];
782 782
     }
783
-    if ( isset( $args['excerpt'] ) ) { 
783
+    if (isset($args['excerpt'])) { 
784 784
         $post_data['post_excerpt'] = $args['excerpt'];
785 785
     }
786
-    if ( isset( $args['status'] ) ) { 
786
+    if (isset($args['status'])) { 
787 787
         $post_data['post_status'] = $args['status'];
788 788
     }
789 789
     
790
-    foreach ( $meta_fields as $meta_field ) {
791
-        if ( isset( $args[ $meta_field ] ) ) { 
792
-            $value = $args[ $meta_field ];
790
+    foreach ($meta_fields as $meta_field) {
791
+        if (isset($args[$meta_field])) { 
792
+            $value = $args[$meta_field];
793 793
 
794
-            switch ( $meta_field ) {
794
+            switch ($meta_field) {
795 795
                 case 'price':
796
-                    $value = wpinv_round_amount( $value );
796
+                    $value = wpinv_round_amount($value);
797 797
                 break;
798 798
                 case 'recurring_interval':
799 799
                 case 'recurring_limit':
800 800
                 case 'trial_interval':
801
-                    $value = absint( $value );
801
+                    $value = absint($value);
802 802
                 break;
803 803
 				case 'editable':
804
-                    $value = (int) $value;
804
+                    $value = (int)$value;
805 805
                 break;
806 806
             }
807 807
 
808
-            $post_data['meta'][ $meta_field ] = $value;
808
+            $post_data['meta'][$meta_field] = $value;
809 809
         };
810 810
     }
811 811
 
812
-    if ( empty( $post_data ) ) {
813
-        if ( $wp_error ) {
814
-            return new WP_Error( 'wpinv_invalid_item_data', __( 'Invalid item data.', 'invoicing' ) );
812
+    if (empty($post_data)) {
813
+        if ($wp_error) {
814
+            return new WP_Error('wpinv_invalid_item_data', __('Invalid item data.', 'invoicing'));
815 815
         }
816 816
         return 0;
817 817
     }
818 818
     $post_data['ID'] = $args['ID'];
819 819
 
820
-    $return = $item->update( $post_data, $wp_error );
820
+    $return = $item->update($post_data, $wp_error);
821 821
 
822
-    if ( $return && !empty( $item ) && !is_wp_error( $return ) ) {
822
+    if ($return && !empty($item) && !is_wp_error($return)) {
823 823
         return $item;
824 824
     }
825 825
 
826
-    if ( $wp_error && is_wp_error( $return ) ) {
826
+    if ($wp_error && is_wp_error($return)) {
827 827
         return $return;
828 828
     }
829 829
     return 0;
Please login to merge, or discard this patch.
includes/abstracts/abstract-wpinv-privacy.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Abstract privacy class.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Abstract class that is intended to be extended by
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @param string $name Plugin identifier.
40 40
      */
41
-    public function __construct( $name = '' ) {
41
+    public function __construct($name = '') {
42 42
         $this->name = $name;
43 43
         $this->init();
44 44
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
      * Hook in events.
48 48
      */
49 49
     protected function init() {
50
-        add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
50
+        add_action('admin_init', array($this, 'add_privacy_message'));
51 51
         // Register data exporters
52
-        add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
52
+        add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10);
53 53
         // Register data erasers
54
-        add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
54
+        add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'));
55 55
     }
56 56
 
57 57
     /**
58 58
      * Adds the privacy message on invoicing privacy page.
59 59
      */
60 60
     public function add_privacy_message() {
61
-        if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
61
+        if (function_exists('wp_add_privacy_policy_content')) {
62 62
             $content = $this->get_privacy_message();
63 63
 
64
-            if ( $content ) {
65
-                wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() );
64
+            if ($content) {
65
+                wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
66 66
             }
67 67
         }
68 68
     }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param array $exporters List of exporter callbacks.
84 84
      * @return array
85 85
      */
86
-    public function register_exporters( $exporters = array() ) {
87
-        foreach ( $this->exporters as $id => $exporter ) {
88
-            $exporters[ $id ] = $exporter;
86
+    public function register_exporters($exporters = array()) {
87
+        foreach ($this->exporters as $id => $exporter) {
88
+            $exporters[$id] = $exporter;
89 89
         }
90 90
         return $exporters;
91 91
     }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
      * @param array $erasers List of eraser callbacks.
97 97
      * @return array
98 98
      */
99
-    public function register_erasers( $erasers = array() ) {
100
-        foreach ( $this->erasers as $id => $eraser ) {
101
-            $erasers[ $id ] = $eraser;
99
+    public function register_erasers($erasers = array()) {
100
+        foreach ($this->erasers as $id => $eraser) {
101
+            $erasers[$id] = $eraser;
102 102
         }
103 103
         return $erasers;
104 104
     }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return array
114 114
      */
115
-    public function add_exporter( $id, $name, $callback ) {
116
-        $this->exporters[ $id ] = array(
115
+    public function add_exporter($id, $name, $callback) {
116
+        $this->exporters[$id] = array(
117 117
             'exporter_friendly_name' => $name,
118 118
             'callback'               => $callback,
119 119
         );
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return array
131 131
      */
132
-    public function add_eraser( $id, $name, $callback ) {
133
-        $this->erasers[ $id ] = array(
132
+    public function add_eraser($id, $name, $callback) {
133
+        $this->erasers[$id] = array(
134 134
             'eraser_friendly_name' => $name,
135 135
             'callback'             => $callback,
136 136
         );
Please login to merge, or discard this patch.