Passed
Pull Request — master (#191)
by
unknown
04:15
created
vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
 class BitrixInstaller extends BaseInstaller
27 27
 {
28 28
     protected $locations = array(
29
-        'module'    => '{$bitrix_dir}/modules/{$name}/',    // deprecated, remove on the major release (Backward compatibility will be broken)
29
+        'module'    => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
30 30
         'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
31
-        'theme'     => '{$bitrix_dir}/templates/{$name}/',  // deprecated, remove on the major release (Backward compatibility will be broken)
31
+        'theme'     => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken)
32 32
         'd7-module'    => '{$bitrix_dir}/modules/{$vendor}.{$name}/',
33 33
         'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/',
34 34
         'd7-template'     => '{$bitrix_dir}/templates/{$vendor}_{$name}/',
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
      */
18 18
     public function inflectPackageVars($vars)
19 19
     {
20
-        $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) {
20
+        $vars['name'] = preg_replace_callback('/(-[a-z])/', function($matches) {
21 21
             return strtoupper($matches[0][1]);
22 22
         }, $vars['name']);
23 23
 
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected function inflectModuleVars($vars)
37 37
     {
38
-        $vars['name'] = str_replace('pxcms-', '', $vars['name']);       // strip out pxcms- just incase (legacy)
39
-        $vars['name'] = str_replace('module-', '', $vars['name']);      // strip out module-
40
-        $vars['name'] = preg_replace('/-module$/', '', $vars['name']);  // strip out -module
41
-        $vars['name'] = str_replace('-', '_', $vars['name']);           // make -'s be _'s
42
-        $vars['name'] = ucwords($vars['name']);                         // make module name camelcased
38
+        $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
39
+        $vars['name'] = str_replace('module-', '', $vars['name']); // strip out module-
40
+        $vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module
41
+        $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
42
+        $vars['name'] = ucwords($vars['name']); // make module name camelcased
43 43
 
44 44
         return $vars;
45 45
     }
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
      */
53 53
     protected function inflectThemeVars($vars)
54 54
     {
55
-        $vars['name'] = str_replace('pxcms-', '', $vars['name']);       // strip out pxcms- just incase (legacy)
56
-        $vars['name'] = str_replace('theme-', '', $vars['name']);       // strip out theme-
57
-        $vars['name'] = preg_replace('/-theme$/', '', $vars['name']);   // strip out -theme
58
-        $vars['name'] = str_replace('-', '_', $vars['name']);           // make -'s be _'s
59
-        $vars['name'] = ucwords($vars['name']);                         // make module name camelcased
55
+        $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy)
56
+        $vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme-
57
+        $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme
58
+        $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s
59
+        $vars['name'] = ucwords($vars['name']); // make module name camelcased
60 60
 
61 61
         return $vars;
62 62
     }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      */
38 38
     private function correctPluginName($vars)
39 39
     {
40
-        $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) {
40
+        $camelCasedName = preg_replace_callback('/(-[a-z])/', function($matches) {
41 41
             return strtoupper($matches[0][1]);
42 42
         }, $vars['name']);
43 43
 
Please login to merge, or discard this patch.
vendor/composer/installers/src/bootstrap.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@
 block discarded – undo
6 6
     }
7 7
 }
8 8
 if ((!$loader = includeIfExists(__DIR__ . '/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__ . '/../../../autoload.php'))) {
9
-    die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
10
-        'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
11
-        'php composer.phar install'.PHP_EOL);
9
+    die('You must set up the project dependencies, run the following commands:' . PHP_EOL .
10
+        'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
11
+        'php composer.phar install' . PHP_EOL);
12 12
 }
13 13
 return $loader;
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Spacing   +94 added lines, -94 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.
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 		 * @return WP_Font_Awesome_Settings - Main instance.
86 86
 		 */
87 87
 		public static function instance() {
88
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
88
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
89 89
 				self::$instance = new WP_Font_Awesome_Settings;
90 90
 
91
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
91
+				add_action('init', array(self::$instance, 'init')); // set settings
92 92
 
93
-				if ( is_admin() ) {
94
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
95
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
+				if (is_admin()) {
94
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
95
+					add_action('admin_init', array(self::$instance, 'register_settings'));
96 96
 				}
97 97
 
98
-				do_action( 'wp_font_awesome_settings_loaded' );
98
+				do_action('wp_font_awesome_settings_loaded');
99 99
 			}
100 100
 
101 101
 			return self::$instance;
@@ -109,30 +109,30 @@  discard block
 block discarded – undo
109 109
 		public function init() {
110 110
 			$this->settings = $this->get_settings();
111 111
 
112
-			if ( $this->settings['type'] == 'CSS' ) {
112
+			if ($this->settings['type'] == 'CSS') {
113 113
 
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
114
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
115
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); //echo '###';exit;
116 116
 				}
117 117
 
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
118
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
119
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
120 120
 				}
121 121
 
122 122
 			} else {
123 123
 
124
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
125
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
124
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
125
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); //echo '###';exit;
126 126
 				}
127 127
 
128
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
129
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
128
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
129
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
130 130
 				}
131 131
 			}
132 132
 
133 133
 			// remove font awesome if set to do so
134
-			if ( $this->settings['dequeue'] == '1' ) {
135
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
134
+			if ($this->settings['dequeue'] == '1') {
135
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
136 136
 			}
137 137
 
138 138
 		}
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 			// build url
145 145
 			$url = $this->get_url();
146 146
 
147
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
148
-			wp_register_style( 'font-awesome', $url, array(), null );
149
-			wp_enqueue_style( 'font-awesome' );
147
+			wp_deregister_style('font-awesome'); // deregister in case its already there
148
+			wp_register_style('font-awesome', $url, array(), null);
149
+			wp_enqueue_style('font-awesome');
150 150
 
151
-			if ( $this->settings['shims'] ) {
152
-				$url = $this->get_url( true );
153
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
154
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
155
-				wp_enqueue_style( 'font-awesome-shims' );
151
+			if ($this->settings['shims']) {
152
+				$url = $this->get_url(true);
153
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
154
+				wp_register_style('font-awesome-shims', $url, array(), null);
155
+				wp_enqueue_style('font-awesome-shims');
156 156
 			}
157 157
 		}
158 158
 
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			// build url
164 164
 			$url = $this->get_url();
165 165
 
166
-			$deregister_function = 'wp'.'_'.'deregister'.'_'.'script';
167
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
168
-			wp_register_script( 'font-awesome', $url, array(), null );
169
-			wp_enqueue_script( 'font-awesome' );
166
+			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
167
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
168
+			wp_register_script('font-awesome', $url, array(), null);
169
+			wp_enqueue_script('font-awesome');
170 170
 
171
-			if ( $this->settings['shims'] ) {
172
-				$url = $this->get_url( true );
173
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
174
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
175
-				wp_enqueue_script( 'font-awesome-shims' );
171
+			if ($this->settings['shims']) {
172
+				$url = $this->get_url(true);
173
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
174
+				wp_register_script('font-awesome-shims', $url, array(), null);
175
+				wp_enqueue_script('font-awesome-shims');
176 176
 			}
177 177
 		}
178 178
 
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 		 *
184 184
 		 * @return string The url to the file.
185 185
 		 */
186
-		public function get_url( $shims = false ) {
186
+		public function get_url($shims = false) {
187 187
 			$script  = $shims ? 'v4-shims' : 'all';
188 188
 			$type    = $this->settings['type'];
189 189
 			$version = $this->settings['version'];
190 190
 
191 191
 			$url = "https://use.fontawesome.com/releases/"; // CDN
192
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
192
+			$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
193 193
 			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
194 194
 			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
195 195
 			$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 		 *
209 209
 		 * @return string The filtered url.
210 210
 		 */
211
-		public function remove_font_awesome( $url, $original_url, $_context ) {
211
+		public function remove_font_awesome($url, $original_url, $_context) {
212 212
 
213
-			if ( $_context == 'display'
214
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
215
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
213
+			if ($_context == 'display'
214
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
215
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
216 216
 			) {// it's a font-awesome-url (probably)
217 217
 
218
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
219
-					if ( $this->settings['type'] == 'JS' ) {
220
-						if ( $this->settings['js-pseudo'] ) {
218
+				if (strstr($url, "wpfas=true") !== false) {
219
+					if ($this->settings['type'] == 'JS') {
220
+						if ($this->settings['js-pseudo']) {
221 221
 							$url .= "' data-search-pseudo-elements defer='defer";
222 222
 						} else {
223 223
 							$url .= "' defer='defer";
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 * Register the database settings with WordPress.
237 237
 		 */
238 238
 		public function register_settings() {
239
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
239
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
240 240
 		}
241 241
 
242 242
 		/**
@@ -244,11 +244,11 @@  discard block
 block discarded – undo
244 244
 		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
245 245
 		 */
246 246
 		public function menu_item() {
247
-			$menu_function = 'add'.'_'.'options'.'_'.'page'; // won't pass theme check if function name present in theme
247
+			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
248 248
 			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
249 249
 				$this,
250 250
 				'settings_page'
251
-			) );
251
+			));
252 252
 		}
253 253
 
254 254
 		/**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		 */
259 259
 		public function get_settings() {
260 260
 
261
-			$db_settings = get_option( 'wp-font-awesome-settings' );
261
+			$db_settings = get_option('wp-font-awesome-settings');
262 262
 
263 263
 			$defaults = array(
264 264
 				'type'      => 'CSS', // type to use, CSS or JS
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
270 270
 			);
271 271
 
272
-			$settings = wp_parse_args( $db_settings, $defaults );
272
+			$settings = wp_parse_args($db_settings, $defaults);
273 273
 
274 274
 			/**
275 275
 			 * Filter the Font Awesome settings.
276 276
 			 *
277 277
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
278 278
 			 */
279
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
279
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
280 280
 		}
281 281
 
282 282
 
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 		 * The settings page html output.
285 285
 		 */
286 286
 		public function settings_page() {
287
-			if ( ! current_user_can( 'manage_options' ) ) {
288
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
287
+			if (!current_user_can('manage_options')) {
288
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
289 289
 			}
290 290
 
291 291
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
292
-			if(isset($_REQUEST['force-version-check'])){
292
+			if (isset($_REQUEST['force-version-check'])) {
293 293
 				$this->get_latest_version($force_api = true);
294 294
 			}
295 295
 			?>
@@ -297,47 +297,47 @@  discard block
 block discarded – undo
297 297
 				<h1><?php echo $this->name; ?></h1>
298 298
 				<form method="post" action="options.php">
299 299
 					<?php
300
-					settings_fields( 'wp-font-awesome-settings' );
301
-					do_settings_sections( 'wp-font-awesome-settings' );
300
+					settings_fields('wp-font-awesome-settings');
301
+					do_settings_sections('wp-font-awesome-settings');
302 302
 					?>
303 303
 					<table class="form-table">
304 304
 						<tr valign="top">
305
-							<th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
305
+							<th scope="row"><label for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
306 306
 							<td>
307 307
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type">
308 308
 									<option
309
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
310
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
309
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
310
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
311 311
 								</select>
312 312
 							</td>
313 313
 						</tr>
314 314
 
315 315
 						<tr valign="top">
316
-							<th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
316
+							<th scope="row"><label for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
317 317
 							<td>
318 318
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
319 319
 									<option
320
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?>
320
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?>
321 321
 									</option>
322
-									<option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>
322
+									<option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>
323 323
 										5.6.0
324 324
 									</option>
325
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
325
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
326 326
 										5.5.0
327 327
 									</option>
328
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
328
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
329 329
 										5.4.0
330 330
 									</option>
331
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
331
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
332 332
 										5.3.0
333 333
 									</option>
334
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
334
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
335 335
 										5.2.0
336 336
 									</option>
337
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
337
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
338 338
 										5.1.0
339 339
 									</option>
340
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
340
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
341 341
 										4.7.1 (CSS only)
342 342
 									</option>
343 343
 								</select>
@@ -345,51 +345,51 @@  discard block
 block discarded – undo
345 345
 						</tr>
346 346
 
347 347
 						<tr valign="top">
348
-							<th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
348
+							<th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
349 349
 							<td>
350 350
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
351 351
 									<option
352
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
352
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
353 353
 									<option
354
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
354
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
355 355
 									<option
356
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
356
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
357 357
 								</select>
358 358
 							</td>
359 359
 						</tr>
360 360
 
361 361
 						<tr valign="top">
362 362
 							<th scope="row"><label
363
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label></th>
363
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label></th>
364 364
 							<td>
365 365
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
366 366
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
367
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
368
-								<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>
367
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
368
+								<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>
369 369
 							</td>
370 370
 						</tr>
371 371
 
372 372
 						<tr valign="top">
373 373
 							<th scope="row"><label
374
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
374
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
375 375
 							</th>
376 376
 							<td>
377 377
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
378 378
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
379
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
379
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
380 380
 								       id="wpfas-js-pseudo"/>
381
-								<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>
381
+								<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>
382 382
 							</td>
383 383
 						</tr>
384 384
 
385 385
 						<tr valign="top">
386
-							<th scope="row"><label for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
386
+							<th scope="row"><label for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
387 387
 							<td>
388 388
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
389 389
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
390
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
390
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
391 391
 								       id="wpfas-dequeue"/>
392
-								<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>
392
+								<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>
393 393
 							</td>
394 394
 						</tr>
395 395
 
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
 		 *
415 415
 		 * @return string Either a valid version number or an empty string.
416 416
 		 */
417
-		public function validate_version_number( $version ) {
417
+		public function validate_version_number($version) {
418 418
 
419
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
419
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
420 420
 				// valid
421 421
 			} else {
422
-				$version = '';// not validated
422
+				$version = ''; // not validated
423 423
 			}
424 424
 
425 425
 			return $version;
@@ -437,16 +437,16 @@  discard block
 block discarded – undo
437 437
 		public function get_latest_version($force_api = false) {
438 438
 			$latest_version = $this->latest;
439 439
 
440
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
440
+			$cache = get_transient('wp-font-awesome-settings-version');
441 441
 
442
-			if ( $cache === false || $force_api) { // its not set
442
+			if ($cache === false || $force_api) { // its not set
443 443
 				$api_ver = $this->get_latest_version_from_api();
444
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
444
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
445 445
 					$latest_version = $api_ver;
446
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
446
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
447 447
 				}
448
-			} elseif ( $this->validate_version_number( $cache ) ) {
449
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
448
+			} elseif ($this->validate_version_number($cache)) {
449
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
450 450
 					$latest_version = $cache;
451 451
 				}
452 452
 			}
@@ -462,10 +462,10 @@  discard block
 block discarded – undo
462 462
 		 */
463 463
 		public function get_latest_version_from_api() {
464 464
 			$version  = "0";
465
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
466
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
467
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
468
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
465
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
466
+			if (!is_wp_error($response) && is_array($response)) {
467
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
468
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
469 469
 					$version = $api_response['tag_name'];
470 470
 				}
471 471
 			}
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +547 added lines, -547 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
141
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
142
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
143
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
144
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
145
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
146
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
147
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
148
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
141
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
142
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
143
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
144
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
145
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
146
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
147
+                        'cols'        => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
148
+                        'rows'        => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
149 149
                     )
150 150
                 );
151 151
             }
@@ -153,194 +153,194 @@  discard block
 block discarded – undo
153 153
     }
154 154
 
155 155
     // Creates our settings in the options table
156
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
156
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
157 157
 }
158
-add_action( 'admin_init', 'wpinv_register_settings' );
158
+add_action('admin_init', 'wpinv_register_settings');
159 159
 
160 160
 function wpinv_get_registered_settings() {
161
-    $pages = wpinv_get_pages( true );
161
+    $pages = wpinv_get_pages(true);
162 162
     
163 163
     $currencies = wpinv_get_currencies();
164 164
     
165 165
     $currency_code_options = array();
166
-    foreach ( $currencies as $code => $name ) {
167
-        $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
166
+    foreach ($currencies as $code => $name) {
167
+        $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
168 168
     }
169 169
     
170 170
     $due_payment_options       = array();
171
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
172
-    for ( $i = 1; $i <= 30; $i++ ) {
171
+    $due_payment_options[0]    = __('Now', 'invoicing');
172
+    for ($i = 1; $i <= 30; $i++) {
173 173
         $due_payment_options[$i] = $i;
174 174
     }
175 175
     
176 176
     $invoice_number_padd_options = array();
177
-    for ( $i = 0; $i <= 20; $i++ ) {
177
+    for ($i = 0; $i <= 20; $i++) {
178 178
         $invoice_number_padd_options[$i] = $i;
179 179
     }
180 180
     
181 181
     $currency_symbol = wpinv_currency_symbol();
182 182
     
183 183
     $last_number = $reset_number = '';
184
-    if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
185
-        $last_invoice_number = is_numeric( $last_invoice_number ) ? $last_invoice_number : wpinv_clean_invoice_number( $last_invoice_number );
184
+    if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
185
+        $last_invoice_number = is_numeric($last_invoice_number) ? $last_invoice_number : wpinv_clean_invoice_number($last_invoice_number);
186 186
 
187
-        if ( !empty( $last_invoice_number ) ) {
188
-            $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
187
+        if (!empty($last_invoice_number)) {
188
+            $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
189 189
         }
190 190
 
191 191
         $nonce = wp_create_nonce('reset_invoice_count');
192
-        $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
192
+        $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
193 193
     }
194 194
     
195 195
     $alert_wrapper_start = '<p style="color: #F00">';
196 196
     $alert_wrapper_close = '</p>';
197 197
     $wpinv_settings = array(
198
-        'general' => apply_filters( 'wpinv_settings_general',
198
+        'general' => apply_filters('wpinv_settings_general',
199 199
             array(
200 200
                 'main' => array(
201 201
                     'location_settings' => array(
202 202
                         'id'   => 'location_settings',
203
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
203
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
204 204
                         'desc' => '',
205 205
                         'type' => 'header',
206 206
                     ),
207 207
                     'default_country' => array(
208 208
                         'id'      => 'default_country',
209
-                        'name'    => __( 'Default Country', 'invoicing' ),
210
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
209
+                        'name'    => __('Default Country', 'invoicing'),
210
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
211 211
                         'type'    => 'select',
212 212
                         'options' => wpinv_get_country_list(),
213 213
                         'std'     => 'GB',
214
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
214
+                        'placeholder' => __('Select a country', 'invoicing'),
215 215
                     ),
216 216
                     'default_state' => array(
217 217
                         'id'      => 'default_state',
218
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
219
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
218
+                        'name'    => __('Default State / Province', 'invoicing'),
219
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
220 220
                         'type'    => 'country_states',
221
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
221
+                        'placeholder' => __('Select a state', 'invoicing'),
222 222
                     ),
223 223
                     'store_name' => array(
224 224
                         'id'   => 'store_name',
225
-                        'name' => __( 'Store Name', 'invoicing' ),
226
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
225
+                        'name' => __('Store Name', 'invoicing'),
226
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
227 227
                         'std'     => get_option('blogname'),
228 228
                         'type' => 'text',
229 229
                     ),
230 230
                     'logo' => array(
231 231
                         'id'   => 'logo',
232
-                        'name' => __( 'Logo URL', 'invoicing' ),
233
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
232
+                        'name' => __('Logo URL', 'invoicing'),
233
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
234 234
                         'type' => 'text',
235 235
                     ),
236 236
                     'store_address' => array(
237 237
                         'id'   => 'store_address',
238
-                        'name' => __( 'Store Address', 'invoicing' ),
239
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
238
+                        'name' => __('Store Address', 'invoicing'),
239
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
240 240
                         'type' => 'textarea',
241 241
                     ),
242 242
                     'page_settings' => array(
243 243
                         'id'   => 'page_settings',
244
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
244
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
245 245
                         'desc' => '',
246 246
                         'type' => 'header',
247 247
                     ),
248 248
                     'checkout_page' => array(
249 249
                         'id'          => 'checkout_page',
250
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
251
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
250
+                        'name'        => __('Checkout Page', 'invoicing'),
251
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
252 252
                         'type'        => 'select',
253 253
                         'options'     => $pages,
254
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
254
+                        'placeholder' => __('Select a page', 'invoicing'),
255 255
                     ),
256 256
                     'tandc_page' => array(
257 257
                         'id'          => 'tandc_page',
258
-                        'name'        => __( 'Terms & Conditions', 'invoicing' ),
259
-                        'desc'        => __( 'If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing' ),
258
+                        'name'        => __('Terms & Conditions', 'invoicing'),
259
+                        'desc'        => __('If you select a "Terms & Conditions" page here the customer will be asked to accept them on checkout.', 'invoicing'),
260 260
                         'type'        => 'select',
261
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
261
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
262 262
                         'chosen'      => true,
263
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
263
+                        'placeholder' => __('Select a page', 'invoicing'),
264 264
                     ),
265 265
                     'success_page' => array(
266 266
                         'id'          => 'success_page',
267
-                        'name'        => __( 'Success Page', 'invoicing' ),
268
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
267
+                        'name'        => __('Success Page', 'invoicing'),
268
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
269 269
                         'type'        => 'select',
270 270
                         'options'     => $pages,
271
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
271
+                        'placeholder' => __('Select a page', 'invoicing'),
272 272
                     ),
273 273
                     'failure_page' => array(
274 274
                         'id'          => 'failure_page',
275
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
276
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
275
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
276
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
277 277
                         'type'        => 'select',
278 278
                         'options'     => $pages,
279
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
279
+                        'placeholder' => __('Select a page', 'invoicing'),
280 280
                     ),
281 281
                     'invoice_history_page' => array(
282 282
                         'id'          => 'invoice_history_page',
283
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
284
-                        'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
283
+                        'name'        => __('Invoice History Page', 'invoicing'),
284
+                        'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
285 285
                         'type'        => 'select',
286 286
                         'options'     => $pages,
287
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
287
+                        'placeholder' => __('Select a page', 'invoicing'),
288 288
                     ),
289 289
                     'invoice_subscription_page' => array(
290 290
                         'id'          => 'invoice_subscription_page',
291
-                        'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
292
-                        'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
291
+                        'name'        => __('Invoice Subscriptions Page', 'invoicing'),
292
+                        'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
293 293
                         'type'        => 'select',
294 294
                         'options'     => $pages,
295
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
295
+                        'placeholder' => __('Select a page', 'invoicing'),
296 296
                     ),
297 297
                 ),
298 298
                 'currency_section' => array(
299 299
                     'currency_settings' => array(
300 300
                         'id'   => 'currency_settings',
301
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
301
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
302 302
                         'desc' => '',
303 303
                         'type' => 'header',
304 304
                     ),
305 305
                     'currency' => array(
306 306
                         'id'      => 'currency',
307
-                        'name'    => __( 'Currency', 'invoicing' ),
308
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
307
+                        'name'    => __('Currency', 'invoicing'),
308
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
309 309
                         'type'    => 'select',
310 310
                         'options' => $currency_code_options,
311 311
                     ),
312 312
                     'currency_position' => array(
313 313
                         'id'      => 'currency_position',
314
-                        'name'    => __( 'Currency Position', 'invoicing' ),
315
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
314
+                        'name'    => __('Currency Position', 'invoicing'),
315
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
316 316
                         'type'    => 'select',
317 317
                         'options'  => array(
318
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
319
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
320
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
321
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
318
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
319
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
320
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
321
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
322 322
                         )
323 323
                     ),
324 324
                     'thousands_separator' => array(
325 325
                         'id'   => 'thousands_separator',
326
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
327
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
326
+                        'name' => __('Thousands Separator', 'invoicing'),
327
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
328 328
                         'type' => 'text',
329 329
                         'size' => 'small',
330 330
                         'std'  => ',',
331 331
                     ),
332 332
                     'decimal_separator' => array(
333 333
                         'id'   => 'decimal_separator',
334
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
335
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
334
+                        'name' => __('Decimal Separator', 'invoicing'),
335
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
336 336
                         'type' => 'text',
337 337
                         'size' => 'small',
338 338
                         'std'  => '.',
339 339
                     ),
340 340
                     'decimals' => array(
341 341
                         'id'   => 'decimals',
342
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
343
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
342
+                        'name' => __('Number of Decimals', 'invoicing'),
343
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
344 344
                         'type' => 'number',
345 345
                         'size' => 'small',
346 346
                         'std'  => '2',
@@ -352,29 +352,29 @@  discard block
 block discarded – undo
352 352
                 'labels' => array(
353 353
                     'labels' => array(
354 354
                         'id'   => 'labels_settings',
355
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
355
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
356 356
                         'desc' => '',
357 357
                         'type' => 'header',
358 358
                     ),
359 359
                     'vat_name' => array(
360 360
                         'id' => 'vat_name',
361
-                        'name' => __( 'VAT Name', 'invoicing' ),
362
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
361
+                        'name' => __('VAT Name', 'invoicing'),
362
+                        'desc' => __('Enter the VAT name', 'invoicing'),
363 363
                         'type' => 'text',
364 364
                         'size' => 'regular',
365 365
                         'std' => 'VAT'
366 366
                     ),
367 367
                     'vat_invoice_notice_label' => array(
368 368
                         'id' => 'vat_invoice_notice_label',
369
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
370
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
369
+                        'name' => __('Invoice Notice Label', 'invoicing'),
370
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
371 371
                         'type' => 'text',
372 372
                         'size' => 'regular',
373 373
                     ),
374 374
                     'vat_invoice_notice' => array(
375 375
                         'id' => 'vat_invoice_notice',
376
-                        'name' => __( 'Invoice notice', 'invoicing' ),
377
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
376
+                        'name' => __('Invoice notice', 'invoicing'),
377
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
378 378
                         'type' => 'text',
379 379
                         'size' => 'regular',
380 380
                     )
@@ -386,22 +386,22 @@  discard block
 block discarded – undo
386 386
                 'main' => array(
387 387
                     'gateway_settings' => array(
388 388
                         'id'   => 'api_header',
389
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
389
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
390 390
                         'desc' => '',
391 391
                         'type' => 'header',
392 392
                     ),
393 393
                     'gateways' => array(
394 394
                         'id'      => 'gateways',
395
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
396
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
395
+                        'name'    => __('Payment Gateways', 'invoicing'),
396
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
397 397
                         'type'    => 'gateways',
398 398
                         'std'     => array('manual'=>1),
399 399
                         'options' => wpinv_get_payment_gateways(),
400 400
                     ),
401 401
                     'default_gateway' => array(
402 402
                         'id'      => 'default_gateway',
403
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
404
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
403
+                        'name'    => __('Default Gateway', 'invoicing'),
404
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
405 405
                         'type'    => 'gateway_select',
406 406
                         'std'     => 'manual',
407 407
                         'options' => wpinv_get_payment_gateways(),
@@ -415,19 +415,19 @@  discard block
 block discarded – undo
415 415
                 'main' => array(
416 416
                     'tax_settings' => array(
417 417
                         'id'   => 'tax_settings',
418
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
418
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
419 419
                         'type' => 'header',
420 420
                     ),
421 421
                     'enable_taxes' => array(
422 422
                         'id'   => 'enable_taxes',
423
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
424
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
423
+                        'name' => __('Enable Taxes', 'invoicing'),
424
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
425 425
                         'type' => 'checkbox',
426 426
                     ),
427 427
                     'tax_rate' => array(
428 428
                         'id'   => 'tax_rate',
429
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
430
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
429
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
430
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
431 431
                         'type' => 'number',
432 432
                         'size' => 'small',
433 433
                         'min'  => '0',
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
                 'rates' => array(
440 440
                     'tax_rates' => array(
441 441
                         'id'   => 'tax_rates',
442
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
443
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
442
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
443
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
444 444
                         'type' => 'tax_rates',
445 445
                     ),
446 446
                 )
@@ -452,61 +452,61 @@  discard block
 block discarded – undo
452 452
                 'main' => array(
453 453
                     'email_settings_header' => array(
454 454
                         'id'   => 'email_settings_header',
455
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
455
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
456 456
                         'type' => 'header',
457 457
                     ),
458 458
                     'email_from_name' => array(
459 459
                         'id'   => 'email_from_name',
460
-                        'name' => __( 'From Name', 'invoicing' ),
461
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
462
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
460
+                        'name' => __('From Name', 'invoicing'),
461
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
462
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
463 463
                         'type' => 'text',
464 464
                     ),
465 465
                     'email_from' => array(
466 466
                         'id'   => 'email_from',
467
-                        'name' => __( 'From Email', 'invoicing' ),
468
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
469
-                        'std' => get_option( 'admin_email' ),
467
+                        'name' => __('From Email', 'invoicing'),
468
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
469
+                        'std' => get_option('admin_email'),
470 470
                         'type' => 'text',
471 471
                     ),
472 472
                     'overdue_settings_header' => array(
473 473
                         'id'   => 'overdue_settings_header',
474
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
474
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
475 475
                         'type' => 'header',
476 476
                     ),
477 477
                     'overdue_active' => array(
478 478
                         'id'   => 'overdue_active',
479
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
480
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
479
+                        'name' => __('Enable Due Date', 'invoicing'),
480
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
481 481
                         'type' => 'checkbox',
482 482
                         'std'  => false,
483 483
                     ),
484 484
                     'overdue_days' => array(
485 485
                         'id'          => 'overdue_days',
486
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
487
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
486
+                        'name'        => __('Default Due Date', 'invoicing'),
487
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
488 488
                         'type'        => 'select',
489 489
                         'options'     => $due_payment_options,
490 490
                         'std'         => 0,
491
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
491
+                        'placeholder' => __('Select a page', 'invoicing'),
492 492
                     ),
493 493
                     'email_template_header' => array(
494 494
                         'id'   => 'email_template_header',
495
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
495
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
496 496
                         'type' => 'header',
497 497
                     ),
498 498
                     'email_header_image' => array(
499 499
                         'id'   => 'email_header_image',
500
-                        'name' => __( 'Header Image', 'invoicing' ),
501
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
500
+                        'name' => __('Header Image', 'invoicing'),
501
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
502 502
                         'std' => '',
503 503
                         'type' => 'text',
504 504
                     ),
505 505
                     'email_footer_text' => array(
506 506
                         'id'   => 'email_footer_text',
507
-                        'name' => __( 'Footer Text', 'invoicing' ),
508
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
509
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
507
+                        'name' => __('Footer Text', 'invoicing'),
508
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
509
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
510 510
                         'type' => 'textarea',
511 511
                         'class' => 'regular-text',
512 512
                         'rows' => 2,
@@ -514,29 +514,29 @@  discard block
 block discarded – undo
514 514
                     ),
515 515
                     'email_base_color' => array(
516 516
                         'id'   => 'email_base_color',
517
-                        'name' => __( 'Base Color', 'invoicing' ),
518
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
517
+                        'name' => __('Base Color', 'invoicing'),
518
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
519 519
                         'std' => '#557da2',
520 520
                         'type' => 'color',
521 521
                     ),
522 522
                     'email_background_color' => array(
523 523
                         'id'   => 'email_background_color',
524
-                        'name' => __( 'Background Color', 'invoicing' ),
525
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
524
+                        'name' => __('Background Color', 'invoicing'),
525
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
526 526
                         'std' => '#f5f5f5',
527 527
                         'type' => 'color',
528 528
                     ),
529 529
                     'email_body_background_color' => array(
530 530
                         'id'   => 'email_body_background_color',
531
-                        'name' => __( 'Body Background Color', 'invoicing' ),
532
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
531
+                        'name' => __('Body Background Color', 'invoicing'),
532
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
533 533
                         'std' => '#fdfdfd',
534 534
                         'type' => 'color',
535 535
                     ),
536 536
                     'email_text_color' => array(
537 537
                         'id'   => 'email_text_color',
538
-                        'name' => __( 'Body Text Color', 'invoicing' ),
539
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
538
+                        'name' => __('Body Text Color', 'invoicing'),
539
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
540 540
                         'std' => '#505050',
541 541
                         'type' => 'color',
542 542
                     ),
@@ -555,26 +555,26 @@  discard block
 block discarded – undo
555 555
                 'main' => array(
556 556
                     'invoicing_privacy_policy_settings' => array(
557 557
                         'id'   => 'invoicing_privacy_policy_settings',
558
-                        'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
558
+                        'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
559 559
                         'type' => 'header',
560 560
                     ),
561 561
                     'privacy_page' => array(
562 562
                         'id'          => 'privacy_page',
563
-                        'name'        => __( 'Privacy Page', 'invoicing' ),
564
-                        'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
563
+                        'name'        => __('Privacy Page', 'invoicing'),
564
+                        'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
565 565
                         'type'        => 'select',
566
-                        'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
566
+                        'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
567 567
                         'chosen'      => true,
568
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
568
+                        'placeholder' => __('Select a page', 'invoicing'),
569 569
                     ),
570 570
                     'invoicing_privacy_checkout_message' => array(
571 571
                         'id' => 'invoicing_privacy_checkout_message',
572
-                        'name' => __( 'Checkout privacy policy', 'invoicing' ),
573
-                        'desc' => __( 'Optionally add privacy policy message which will display on checkout page.', 'invoicing' ),
572
+                        'name' => __('Checkout privacy policy', 'invoicing'),
573
+                        'desc' => __('Optionally add privacy policy message which will display on checkout page.', 'invoicing'),
574 574
                         'type' => 'textarea',
575 575
                         'class'=> 'regular-text',
576 576
                         'rows' => 4,
577
-                        'std'  => sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ),
577
+                        'std'  => sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'),
578 578
                     ),
579 579
                 ),
580 580
             )
@@ -585,19 +585,19 @@  discard block
 block discarded – undo
585 585
                 'main' => array(
586 586
                     'invoice_number_format_settings' => array(
587 587
                         'id'   => 'invoice_number_format_settings',
588
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
588
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
589 589
                         'type' => 'header',
590 590
                     ),
591 591
                     'sequential_invoice_number' => array(
592 592
                         'id'   => 'sequential_invoice_number',
593
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
594
-                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
593
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
594
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
595 595
                         'type' => 'checkbox',
596 596
                     ),
597 597
                     'invoice_sequence_start' => array(
598 598
                         'id'   => 'invoice_sequence_start',
599
-                        'name' => __( 'Sequential Starting Number', 'invoicing' ),
600
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
599
+                        'name' => __('Sequential Starting Number', 'invoicing'),
600
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
601 601
                         'type' => 'number',
602 602
                         'size' => 'small',
603 603
                         'std'  => '1',
@@ -605,16 +605,16 @@  discard block
 block discarded – undo
605 605
                     ),
606 606
                     'invoice_number_padd' => array(
607 607
                         'id'      => 'invoice_number_padd',
608
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
609
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
608
+                        'name'    => __('Minimum Digits', 'invoicing'),
609
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
610 610
                         'type'    => 'select',
611 611
                         'options' => $invoice_number_padd_options,
612 612
                         'std'     => 5,
613 613
                     ),
614 614
                     'invoice_number_prefix' => array(
615 615
                         'id' => 'invoice_number_prefix',
616
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
617
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
616
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
617
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
618 618
                         'type' => 'text',
619 619
                         'size' => 'regular',
620 620
                         'std' => 'WPINV-',
@@ -622,32 +622,32 @@  discard block
 block discarded – undo
622 622
                     ),
623 623
                     'invoice_number_postfix' => array(
624 624
                         'id' => 'invoice_number_postfix',
625
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
626
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
625
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
626
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
627 627
                         'type' => 'text',
628 628
                         'size' => 'regular',
629 629
                         'std' => ''
630 630
                     ),
631 631
                     'checkout_settings' => array(
632 632
                         'id'   => 'checkout_settings',
633
-                        'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
633
+                        'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
634 634
                         'type' => 'header',
635 635
                     ),
636 636
                     'login_to_checkout' => array(
637 637
                         'id'   => 'login_to_checkout',
638
-                        'name' => __( 'Require Login To Checkout', 'invoicing' ),
639
-                        'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
638
+                        'name' => __('Require Login To Checkout', 'invoicing'),
639
+                        'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
640 640
                         'type' => 'checkbox',
641 641
                     ),
642 642
                     'uninstall_settings' => array(
643 643
                         'id'   => 'uninstall_settings',
644
-                        'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
644
+                        'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
645 645
                         'type' => 'header',
646 646
                     ),
647 647
                     'remove_data_on_unistall' => array(
648 648
                         'id'   => 'remove_data_on_unistall',
649
-                        'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
650
-                        'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
649
+                        'name' => __('Remove Data on Uninstall?', 'invoicing'),
650
+                        'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
651 651
                         'type' => 'checkbox',
652 652
                         'std'  => ''
653 653
                     ),
@@ -655,80 +655,80 @@  discard block
 block discarded – undo
655 655
                 'fields' => array(
656 656
                     'fields_settings' => array(
657 657
                         'id'   => 'fields_settings',
658
-                        'name' => '<h3>' . __( 'Address Fields', 'invoicing' ) . '</h3>',
659
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
658
+                        'name' => '<h3>' . __('Address Fields', 'invoicing') . '</h3>',
659
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
660 660
                         'type' => 'header',
661 661
                     ),
662 662
                     'fname_mandatory' => array(
663 663
                         'id'   => 'fname_mandatory',
664
-                        'name' => __( 'First Name', 'invoicing' ),
664
+                        'name' => __('First Name', 'invoicing'),
665 665
                         'type' => 'checkbox',
666 666
                         'std'  => true,
667 667
                     ),
668 668
                     'lname_mandatory' => array(
669 669
                         'id'   => 'lname_mandatory',
670
-                        'name' => __( 'Last Name', 'invoicing' ),
670
+                        'name' => __('Last Name', 'invoicing'),
671 671
                         'type' => 'checkbox',
672 672
                         'std'  => true,
673 673
                     ),
674 674
                     'address_mandatory' => array(
675 675
                         'id'   => 'address_mandatory',
676
-                        'name' => __( 'Address', 'invoicing' ),
676
+                        'name' => __('Address', 'invoicing'),
677 677
                         'type' => 'checkbox',
678 678
                         'std'  => true,
679 679
                     ),
680 680
                     'city_mandatory' => array(
681 681
                         'id'   => 'city_mandatory',
682
-                        'name' => __( 'City', 'invoicing' ),
682
+                        'name' => __('City', 'invoicing'),
683 683
                         'type' => 'checkbox',
684 684
                         'std'  => true,
685 685
                     ),
686 686
                     'country_mandatory' => array(
687 687
                         'id'   => 'country_mandatory',
688
-                        'name' => __( 'Country', 'invoicing' ),
688
+                        'name' => __('Country', 'invoicing'),
689 689
                         'type' => 'checkbox',
690 690
                         'std'  => true,
691 691
                     ),
692 692
                     'state_mandatory' => array(
693 693
                         'id'   => 'state_mandatory',
694
-                        'name' => __( 'State / Province', 'invoicing' ),
694
+                        'name' => __('State / Province', 'invoicing'),
695 695
                         'type' => 'checkbox',
696 696
                         'std'  => true,
697 697
                     ),
698 698
                     'zip_mandatory' => array(
699 699
                         'id'   => 'zip_mandatory',
700
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
700
+                        'name' => __('ZIP / Postcode', 'invoicing'),
701 701
                         'type' => 'checkbox',
702 702
                         'std'  => true,
703 703
                     ),
704 704
                     'phone_mandatory' => array(
705 705
                         'id'   => 'phone_mandatory',
706
-                        'name' => __( 'Phone Number', 'invoicing' ),
706
+                        'name' => __('Phone Number', 'invoicing'),
707 707
                         'type' => 'checkbox',
708 708
                         'std'  => true,
709 709
                     ),
710 710
                     'force_show_company' => array(
711 711
                         'id'   => 'force_show_company',
712
-                        'name' => __( 'Force show company name at checkout.', 'invoicing' ),
712
+                        'name' => __('Force show company name at checkout.', 'invoicing'),
713 713
                         'type' => 'checkbox',
714 714
                         'std'  => false,
715 715
                     ),
716 716
                     'address_autofill_settings' => array(
717 717
                         'id'   => 'address_autofill_settings',
718
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
718
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
719 719
                         'type' => 'header',
720 720
                     ),
721 721
                     'address_autofill_active' => array(
722 722
                         'id'   => 'address_autofill_active',
723
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
724
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
723
+                        'name' => __('Enable/Disable', 'invoicing'),
724
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
725 725
                         'type' => 'checkbox',
726 726
                         'std'  => 0
727 727
                     ),
728 728
                     'address_autofill_api' => array(
729 729
                         'id' => 'address_autofill_api',
730
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
731
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
730
+                        'name' => __('Google Place API Key', 'invoicing'),
731
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
732 732
                         'type' => 'text',
733 733
                         'size' => 'regular',
734 734
                         'std' => ''
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
                 'custom-css' => array(
738 738
                     'css_settings' => array(
739 739
                         'id'   => 'css_settings',
740
-                        'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
740
+                        'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
741 741
                         'type' => 'header',
742 742
                     ),
743 743
                     'template_custom_css' => array(
744 744
                         'id' => 'template_custom_css',
745
-                        'name' => __( 'Invoice Template CSS', 'invoicing' ),
746
-                        'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
745
+                        'name' => __('Invoice Template CSS', 'invoicing'),
746
+                        'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
747 747
                         'type' => 'textarea',
748 748
                         'class'=> 'regular-text',
749 749
                         'rows' => 10,
@@ -757,8 +757,8 @@  discard block
 block discarded – undo
757 757
                 'main' => array(
758 758
                     'tool_settings' => array(
759 759
                         'id'   => 'tool_settings',
760
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
761
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
760
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
761
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
762 762
                         'type' => 'tools',
763 763
                     ),
764 764
                 ),
@@ -766,136 +766,136 @@  discard block
 block discarded – undo
766 766
         )
767 767
     );
768 768
 
769
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
769
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
770 770
 }
771 771
 
772
-function wpinv_settings_sanitize( $input = array() ) {
772
+function wpinv_settings_sanitize($input = array()) {
773 773
     global $wpinv_options;
774 774
 
775
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
775
+    if (empty($_POST['_wp_http_referer'])) {
776 776
         return $input;
777 777
     }
778 778
 
779
-    parse_str( $_POST['_wp_http_referer'], $referrer );
779
+    parse_str($_POST['_wp_http_referer'], $referrer);
780 780
 
781 781
     $settings = wpinv_get_registered_settings();
782
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
783
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
782
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
783
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
784 784
 
785 785
     $input = $input ? $input : array();
786
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
787
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
786
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
787
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
788 788
 
789 789
     // Loop through each setting being saved and pass it through a sanitization filter
790
-    foreach ( $input as $key => $value ) {
790
+    foreach ($input as $key => $value) {
791 791
         // Get the setting type (checkbox, select, etc)
792
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
792
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
793 793
 
794
-        if ( $type ) {
794
+        if ($type) {
795 795
             // Field type specific filter
796
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
796
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
797 797
         }
798 798
 
799 799
         // General filter
800
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
800
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
801 801
     }
802 802
 
803 803
     // Loop through the whitelist and unset any that are empty for the tab being saved
804
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
805
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
804
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
805
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
806 806
 
807
-    $found_settings = array_merge( $main_settings, $section_settings );
807
+    $found_settings = array_merge($main_settings, $section_settings);
808 808
 
809
-    if ( ! empty( $found_settings ) ) {
810
-        foreach ( $found_settings as $key => $value ) {
809
+    if (!empty($found_settings)) {
810
+        foreach ($found_settings as $key => $value) {
811 811
 
812 812
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
813
-            if ( is_numeric( $key ) ) {
813
+            if (is_numeric($key)) {
814 814
                 $key = $value['id'];
815 815
             }
816 816
 
817
-            if ( empty( $input[ $key ] ) ) {
818
-                unset( $wpinv_options[ $key ] );
817
+            if (empty($input[$key])) {
818
+                unset($wpinv_options[$key]);
819 819
             }
820 820
         }
821 821
     }
822 822
 
823 823
     // Merge our new settings with the existing
824
-    $output = array_merge( $wpinv_options, $input );
824
+    $output = array_merge($wpinv_options, $input);
825 825
 
826
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
826
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
827 827
 
828 828
     return $output;
829 829
 }
830 830
 
831
-function wpinv_settings_sanitize_misc_accounting( $input ) {
831
+function wpinv_settings_sanitize_misc_accounting($input) {
832 832
     global $wpinv_options, $wpi_session;
833 833
 
834
-    if ( !current_user_can( 'manage_options' ) ) {
834
+    if (!current_user_can('manage_options')) {
835 835
         return $input;
836 836
     }
837 837
 
838
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
838
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
839 839
         // Shows an admin notice about upgrading previous order numbers
840
-        $wpi_session->set( 'upgrade_sequential', '1' );
840
+        $wpi_session->set('upgrade_sequential', '1');
841 841
     }
842 842
 
843 843
     return $input;
844 844
 }
845
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
845
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
846 846
 
847
-function wpinv_settings_sanitize_tax_rates( $input ) {
848
-    if( !current_user_can( 'manage_options' ) ) {
847
+function wpinv_settings_sanitize_tax_rates($input) {
848
+    if (!current_user_can('manage_options')) {
849 849
         return $input;
850 850
     }
851 851
 
852
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
852
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
853 853
 
854 854
     $tax_rates = array();
855 855
 
856
-    if ( !empty( $new_rates ) ) {
857
-        foreach ( $new_rates as $rate ) {
858
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
856
+    if (!empty($new_rates)) {
857
+        foreach ($new_rates as $rate) {
858
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
859 859
                 continue;
860 860
             }
861 861
             
862
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
862
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
863 863
             
864 864
             $tax_rates[] = $rate;
865 865
         }
866 866
     }
867 867
 
868
-    update_option( 'wpinv_tax_rates', $tax_rates );
868
+    update_option('wpinv_tax_rates', $tax_rates);
869 869
 
870 870
     return $input;
871 871
 }
872
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
872
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
873 873
 
874
-function wpinv_sanitize_text_field( $input ) {
875
-    return trim( $input );
874
+function wpinv_sanitize_text_field($input) {
875
+    return trim($input);
876 876
 }
877
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
877
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
878 878
 
879 879
 function wpinv_get_settings_tabs() {
880 880
     $tabs             = array();
881
-    $tabs['general']  = __( 'General', 'invoicing' );
882
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
883
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
884
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
885
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
886
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
887
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
888
-
889
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
881
+    $tabs['general']  = __('General', 'invoicing');
882
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
883
+    $tabs['taxes']    = __('Taxes', 'invoicing');
884
+    $tabs['emails']   = __('Emails', 'invoicing');
885
+    $tabs['privacy']  = __('Privacy', 'invoicing');
886
+    $tabs['misc']     = __('Misc', 'invoicing');
887
+    $tabs['tools']    = __('Tools', 'invoicing');
888
+
889
+    return apply_filters('wpinv_settings_tabs', $tabs);
890 890
 }
891 891
 
892
-function wpinv_get_settings_tab_sections( $tab = false ) {
892
+function wpinv_get_settings_tab_sections($tab = false) {
893 893
     $tabs     = false;
894 894
     $sections = wpinv_get_registered_settings_sections();
895 895
 
896
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
897
-        $tabs = $sections[ $tab ];
898
-    } else if ( $tab ) {
896
+    if ($tab && !empty($sections[$tab])) {
897
+        $tabs = $sections[$tab];
898
+    } else if ($tab) {
899 899
         $tabs = false;
900 900
     }
901 901
 
@@ -905,143 +905,143 @@  discard block
 block discarded – undo
905 905
 function wpinv_get_registered_settings_sections() {
906 906
     static $sections = false;
907 907
 
908
-    if ( false !== $sections ) {
908
+    if (false !== $sections) {
909 909
         return $sections;
910 910
     }
911 911
 
912 912
     $sections = array(
913
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
914
-            'main' => __( 'General Settings', 'invoicing' ),
915
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
916
-            'labels' => __( 'Label Texts', 'invoicing' ),
917
-        ) ),
918
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
919
-            'main' => __( 'Gateway Settings', 'invoicing' ),
920
-        ) ),
921
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
922
-            'main' => __( 'Tax Settings', 'invoicing' ),
923
-            'rates' => __( 'Tax Rates', 'invoicing' ),
924
-        ) ),
925
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
926
-            'main' => __( 'Email Settings', 'invoicing' ),
927
-        ) ),
928
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
929
-            'main' => __( 'Privacy policy', 'invoicing' ),
930
-        ) ),
931
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
932
-            'main' => __( 'Miscellaneous', 'invoicing' ),
933
-            'fields' => __( 'Fields Settings', 'invoicing' ),
934
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
935
-        ) ),
936
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
937
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
938
-        ) ),
913
+        'general' => apply_filters('wpinv_settings_sections_general', array(
914
+            'main' => __('General Settings', 'invoicing'),
915
+            'currency_section' => __('Currency Settings', 'invoicing'),
916
+            'labels' => __('Label Texts', 'invoicing'),
917
+        )),
918
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
919
+            'main' => __('Gateway Settings', 'invoicing'),
920
+        )),
921
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
922
+            'main' => __('Tax Settings', 'invoicing'),
923
+            'rates' => __('Tax Rates', 'invoicing'),
924
+        )),
925
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
926
+            'main' => __('Email Settings', 'invoicing'),
927
+        )),
928
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
929
+            'main' => __('Privacy policy', 'invoicing'),
930
+        )),
931
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
932
+            'main' => __('Miscellaneous', 'invoicing'),
933
+            'fields' => __('Fields Settings', 'invoicing'),
934
+            'custom-css' => __('Custom CSS', 'invoicing'),
935
+        )),
936
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
937
+            'main' => __('Diagnostic Tools', 'invoicing'),
938
+        )),
939 939
     );
940 940
 
941
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
941
+    $sections = apply_filters('wpinv_settings_sections', $sections);
942 942
 
943 943
     return $sections;
944 944
 }
945 945
 
946
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
946
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
947 947
 	$pages_options = array();
948 948
 
949
-	if( $default_label !== NULL && $default_label !== false ) {
950
-		$pages_options = array( '' => $default_label ); // Blank option
949
+	if ($default_label !== NULL && $default_label !== false) {
950
+		$pages_options = array('' => $default_label); // Blank option
951 951
 	}
952 952
 
953 953
 	$pages = get_pages();
954
-	if ( $pages ) {
955
-		foreach ( $pages as $page ) {
954
+	if ($pages) {
955
+		foreach ($pages as $page) {
956 956
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
957
-            $pages_options[ $page->ID ] = $title;
957
+            $pages_options[$page->ID] = $title;
958 958
 		}
959 959
 	}
960 960
 
961 961
 	return $pages_options;
962 962
 }
963 963
 
964
-function wpinv_header_callback( $args ) {
965
-	if ( !empty( $args['desc'] ) ) {
964
+function wpinv_header_callback($args) {
965
+	if (!empty($args['desc'])) {
966 966
         echo $args['desc'];
967 967
     }
968 968
 }
969 969
 
970
-function wpinv_hidden_callback( $args ) {
970
+function wpinv_hidden_callback($args) {
971 971
 	global $wpinv_options;
972 972
 
973
-	if ( isset( $args['set_value'] ) ) {
973
+	if (isset($args['set_value'])) {
974 974
 		$value = $args['set_value'];
975
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
976
-		$value = $wpinv_options[ $args['id'] ];
975
+	} elseif (isset($wpinv_options[$args['id']])) {
976
+		$value = $wpinv_options[$args['id']];
977 977
 	} else {
978
-		$value = isset( $args['std'] ) ? $args['std'] : '';
978
+		$value = isset($args['std']) ? $args['std'] : '';
979 979
 	}
980 980
 
981
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
981
+	if (isset($args['faux']) && true === $args['faux']) {
982 982
 		$args['readonly'] = true;
983
-		$value = isset( $args['std'] ) ? $args['std'] : '';
983
+		$value = isset($args['std']) ? $args['std'] : '';
984 984
 		$name  = '';
985 985
 	} else {
986
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
986
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
987 987
 	}
988 988
 
989
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
989
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
990 990
     
991 991
 	echo $html;
992 992
 }
993 993
 
994
-function wpinv_checkbox_callback( $args ) {
994
+function wpinv_checkbox_callback($args) {
995 995
 	global $wpinv_options;
996 996
     
997
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
997
+    $sanitize_id = wpinv_sanitize_key($args['id']);
998 998
 
999
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
999
+	if (isset($args['faux']) && true === $args['faux']) {
1000 1000
 		$name = '';
1001 1001
 	} else {
1002 1002
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
1003 1003
 	}
1004 1004
 
1005
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
1005
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
1006 1006
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
1007
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1007
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1008 1008
 
1009 1009
 	echo $html;
1010 1010
 }
1011 1011
 
1012
-function wpinv_multicheck_callback( $args ) {
1012
+function wpinv_multicheck_callback($args) {
1013 1013
 	global $wpinv_options;
1014 1014
 
1015
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
1016
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
1015
+	$sanitize_id = wpinv_sanitize_key($args['id']);
1016
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
1017 1017
 
1018
-	if ( ! empty( $args['options'] ) ) {
1018
+	if (!empty($args['options'])) {
1019 1019
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
1020
-        foreach( $args['options'] as $key => $option ):
1021
-			$sanitize_key = wpinv_sanitize_key( $key );
1022
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
1020
+        foreach ($args['options'] as $key => $option):
1021
+			$sanitize_key = wpinv_sanitize_key($key);
1022
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
1023 1023
 				$enabled = $sanitize_key;
1024 1024
 			} else { 
1025 1025
 				$enabled = NULL; 
1026 1026
 			}
1027
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
1028
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
1027
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
1028
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
1029 1029
 		endforeach;
1030 1030
 		echo '</div>';
1031 1031
 		echo '<p class="description">' . $args['desc'] . '</p>';
1032 1032
 	}
1033 1033
 }
1034 1034
 
1035
-function wpinv_payment_icons_callback( $args ) {
1035
+function wpinv_payment_icons_callback($args) {
1036 1036
 	global $wpinv_options;
1037 1037
     
1038
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1038
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1039 1039
 
1040
-	if ( ! empty( $args['options'] ) ) {
1041
-		foreach( $args['options'] as $key => $option ) {
1042
-            $sanitize_key = wpinv_sanitize_key( $key );
1040
+	if (!empty($args['options'])) {
1041
+		foreach ($args['options'] as $key => $option) {
1042
+            $sanitize_key = wpinv_sanitize_key($key);
1043 1043
             
1044
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
1044
+			if (isset($wpinv_options[$args['id']][$key])) {
1045 1045
 				$enabled = $option;
1046 1046
 			} else {
1047 1047
 				$enabled = NULL;
@@ -1049,196 +1049,196 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
1051 1051
 
1052
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
1052
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
1053 1053
 
1054
-				if ( wpinv_string_is_image_url( $key ) ) {
1055
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1054
+				if (wpinv_string_is_image_url($key)) {
1055
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1056 1056
 				} else {
1057
-					$card = strtolower( str_replace( ' ', '', $option ) );
1057
+					$card = strtolower(str_replace(' ', '', $option));
1058 1058
 
1059
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
1060
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
1059
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
1060
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
1061 1061
 					} else {
1062
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
1062
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
1063 1063
 						$content_dir = WP_CONTENT_DIR;
1064 1064
 
1065
-						if ( function_exists( 'wp_normalize_path' ) ) {
1065
+						if (function_exists('wp_normalize_path')) {
1066 1066
 							// Replaces backslashes with forward slashes for Windows systems
1067
-							$image = wp_normalize_path( $image );
1068
-							$content_dir = wp_normalize_path( $content_dir );
1067
+							$image = wp_normalize_path($image);
1068
+							$content_dir = wp_normalize_path($content_dir);
1069 1069
 						}
1070 1070
 
1071
-						$image = str_replace( $content_dir, content_url(), $image );
1071
+						$image = str_replace($content_dir, content_url(), $image);
1072 1072
 					}
1073 1073
 
1074
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1074
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
1075 1075
 				}
1076 1076
 			echo $option . '</label>';
1077 1077
 		}
1078
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
1078
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
1079 1079
 	}
1080 1080
 }
1081 1081
 
1082
-function wpinv_radio_callback( $args ) {
1082
+function wpinv_radio_callback($args) {
1083 1083
 	global $wpinv_options;
1084 1084
     
1085
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1085
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1086 1086
     
1087
-    foreach ( $args['options'] as $key => $option ) :
1088
-		$sanitize_key = wpinv_sanitize_key( $key );
1087
+    foreach ($args['options'] as $key => $option) :
1088
+		$sanitize_key = wpinv_sanitize_key($key);
1089 1089
         
1090 1090
         $checked = false;
1091 1091
 
1092
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
1092
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
1093 1093
 			$checked = true;
1094
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
1094
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1095 1095
 			$checked = true;
1096 1096
 
1097 1097
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1098
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1098
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1099 1099
 	endforeach;
1100 1100
 
1101
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1101
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1102 1102
 }
1103 1103
 
1104
-function wpinv_gateways_callback( $args ) {
1104
+function wpinv_gateways_callback($args) {
1105 1105
 	global $wpinv_options;
1106 1106
     
1107
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1107
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1108 1108
 
1109
-	foreach ( $args['options'] as $key => $option ) :
1110
-		$sanitize_key = wpinv_sanitize_key( $key );
1109
+	foreach ($args['options'] as $key => $option) :
1110
+		$sanitize_key = wpinv_sanitize_key($key);
1111 1111
         
1112
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1112
+        if (isset($wpinv_options['gateways'][$key]))
1113 1113
 			$enabled = '1';
1114 1114
 		else
1115 1115
 			$enabled = null;
1116 1116
 
1117
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1118
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1117
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1118
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1119 1119
 	endforeach;
1120 1120
 }
1121 1121
 
1122 1122
 function wpinv_gateway_select_callback($args) {
1123 1123
 	global $wpinv_options;
1124 1124
     
1125
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1125
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1126 1126
 
1127 1127
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1128 1128
 
1129
-	foreach ( $args['options'] as $key => $option ) :
1130
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1131
-            $selected = selected( $key, $args['selected'], false );
1129
+	foreach ($args['options'] as $key => $option) :
1130
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1131
+            $selected = selected($key, $args['selected'], false);
1132 1132
         } else {
1133
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1133
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1134 1134
         }
1135
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1135
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1136 1136
 	endforeach;
1137 1137
 
1138 1138
 	echo '</select>';
1139
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1139
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1140 1140
 }
1141 1141
 
1142
-function wpinv_text_callback( $args ) {
1142
+function wpinv_text_callback($args) {
1143 1143
 	global $wpinv_options;
1144 1144
     
1145
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1145
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1146 1146
 
1147
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1148
-		$value = $wpinv_options[ $args['id'] ];
1147
+	if (isset($wpinv_options[$args['id']])) {
1148
+		$value = $wpinv_options[$args['id']];
1149 1149
 	} else {
1150
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1150
+		$value = isset($args['std']) ? $args['std'] : '';
1151 1151
 	}
1152 1152
 
1153
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1153
+	if (isset($args['faux']) && true === $args['faux']) {
1154 1154
 		$args['readonly'] = true;
1155
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1155
+		$value = isset($args['std']) ? $args['std'] : '';
1156 1156
 		$name  = '';
1157 1157
 	} else {
1158
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1158
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1159 1159
 	}
1160
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1160
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1161 1161
 
1162 1162
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1163
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1164
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1165
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1163
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1164
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1165
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1166 1166
 
1167 1167
 	echo $html;
1168 1168
 }
1169 1169
 
1170
-function wpinv_number_callback( $args ) {
1170
+function wpinv_number_callback($args) {
1171 1171
 	global $wpinv_options;
1172 1172
     
1173
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1173
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1174 1174
 
1175
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1176
-		$value = $wpinv_options[ $args['id'] ];
1175
+	if (isset($wpinv_options[$args['id']])) {
1176
+		$value = $wpinv_options[$args['id']];
1177 1177
 	} else {
1178
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1178
+		$value = isset($args['std']) ? $args['std'] : '';
1179 1179
 	}
1180 1180
 
1181
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1181
+	if (isset($args['faux']) && true === $args['faux']) {
1182 1182
 		$args['readonly'] = true;
1183
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1183
+		$value = isset($args['std']) ? $args['std'] : '';
1184 1184
 		$name  = '';
1185 1185
 	} else {
1186
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1186
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1187 1187
 	}
1188 1188
 
1189
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1190
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1191
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1192
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1189
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1190
+	$min  = isset($args['min']) ? $args['min'] : 0;
1191
+	$step = isset($args['step']) ? $args['step'] : 1;
1192
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1193 1193
 
1194
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1195
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1196
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1194
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1195
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
1196
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1197 1197
 
1198 1198
 	echo $html;
1199 1199
 }
1200 1200
 
1201
-function wpinv_textarea_callback( $args ) {
1201
+function wpinv_textarea_callback($args) {
1202 1202
 	global $wpinv_options;
1203 1203
     
1204
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1204
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1205 1205
 
1206
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1207
-		$value = $wpinv_options[ $args['id'] ];
1206
+	if (isset($wpinv_options[$args['id']])) {
1207
+		$value = $wpinv_options[$args['id']];
1208 1208
 	} else {
1209
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1209
+		$value = isset($args['std']) ? $args['std'] : '';
1210 1210
 	}
1211 1211
     
1212
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1213
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1212
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1213
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1214 1214
 
1215
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1216
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1215
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
1216
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1217 1217
 
1218 1218
 	echo $html;
1219 1219
 }
1220 1220
 
1221
-function wpinv_password_callback( $args ) {
1221
+function wpinv_password_callback($args) {
1222 1222
 	global $wpinv_options;
1223 1223
     
1224
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1224
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1225 1225
 
1226
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1227
-		$value = $wpinv_options[ $args['id'] ];
1226
+	if (isset($wpinv_options[$args['id']])) {
1227
+		$value = $wpinv_options[$args['id']];
1228 1228
 	} else {
1229
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1229
+		$value = isset($args['std']) ? $args['std'] : '';
1230 1230
 	}
1231 1231
 
1232
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1233
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1234
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1232
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1233
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
1234
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1235 1235
 
1236 1236
 	echo $html;
1237 1237
 }
1238 1238
 
1239 1239
 function wpinv_missing_callback($args) {
1240 1240
 	printf(
1241
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1241
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1242 1242
 		'<strong>' . $args['id'] . '</strong>'
1243 1243
 	);
1244 1244
 }
@@ -1246,131 +1246,131 @@  discard block
 block discarded – undo
1246 1246
 function wpinv_select_callback($args) {
1247 1247
 	global $wpinv_options;
1248 1248
     
1249
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1249
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1250 1250
 
1251
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1252
-		$value = $wpinv_options[ $args['id'] ];
1251
+	if (isset($wpinv_options[$args['id']])) {
1252
+		$value = $wpinv_options[$args['id']];
1253 1253
 	} else {
1254
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1254
+		$value = isset($args['std']) ? $args['std'] : '';
1255 1255
 	}
1256 1256
     
1257
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1257
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1258 1258
         $value = $args['selected'];
1259 1259
     }
1260 1260
 
1261
-	if ( isset( $args['placeholder'] ) ) {
1261
+	if (isset($args['placeholder'])) {
1262 1262
 		$placeholder = $args['placeholder'];
1263 1263
 	} else {
1264 1264
 		$placeholder = '';
1265 1265
 	}
1266 1266
     
1267
-    if( !empty( $args['onchange'] ) ) {
1268
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1267
+    if (!empty($args['onchange'])) {
1268
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1269 1269
     } else {
1270 1270
         $onchange = '';
1271 1271
     }
1272 1272
 
1273
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1273
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1274 1274
 
1275
-	foreach ( $args['options'] as $option => $name ) {
1276
-		$selected = selected( $option, $value, false );
1277
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1275
+	foreach ($args['options'] as $option => $name) {
1276
+		$selected = selected($option, $value, false);
1277
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1278 1278
 	}
1279 1279
 
1280 1280
 	$html .= '</select>';
1281
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1281
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1282 1282
 
1283 1283
 	echo $html;
1284 1284
 }
1285 1285
 
1286
-function wpinv_color_select_callback( $args ) {
1286
+function wpinv_color_select_callback($args) {
1287 1287
 	global $wpinv_options;
1288 1288
     
1289
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1289
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1290 1290
 
1291
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1292
-		$value = $wpinv_options[ $args['id'] ];
1291
+	if (isset($wpinv_options[$args['id']])) {
1292
+		$value = $wpinv_options[$args['id']];
1293 1293
 	} else {
1294
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1294
+		$value = isset($args['std']) ? $args['std'] : '';
1295 1295
 	}
1296 1296
 
1297
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1297
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1298 1298
 
1299
-	foreach ( $args['options'] as $option => $color ) {
1300
-		$selected = selected( $option, $value, false );
1301
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1299
+	foreach ($args['options'] as $option => $color) {
1300
+		$selected = selected($option, $value, false);
1301
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1302 1302
 	}
1303 1303
 
1304 1304
 	$html .= '</select>';
1305
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1305
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1306 1306
 
1307 1307
 	echo $html;
1308 1308
 }
1309 1309
 
1310
-function wpinv_rich_editor_callback( $args ) {
1310
+function wpinv_rich_editor_callback($args) {
1311 1311
 	global $wpinv_options, $wp_version;
1312 1312
     
1313
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1313
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1314 1314
 
1315
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1316
-		$value = $wpinv_options[ $args['id'] ];
1315
+	if (isset($wpinv_options[$args['id']])) {
1316
+		$value = $wpinv_options[$args['id']];
1317 1317
 
1318
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1319
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1318
+		if (empty($args['allow_blank']) && empty($value)) {
1319
+			$value = isset($args['std']) ? $args['std'] : '';
1320 1320
 		}
1321 1321
 	} else {
1322
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1322
+		$value = isset($args['std']) ? $args['std'] : '';
1323 1323
 	}
1324 1324
 
1325
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1325
+	$rows = isset($args['size']) ? $args['size'] : 20;
1326 1326
 
1327
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1327
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1328 1328
 		ob_start();
1329
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
1329
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
1330 1330
 		$html = ob_get_clean();
1331 1331
 	} else {
1332
-		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1332
+		$html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
1333 1333
 	}
1334 1334
 
1335
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1335
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1336 1336
 
1337 1337
 	echo $html;
1338 1338
 }
1339 1339
 
1340
-function wpinv_upload_callback( $args ) {
1340
+function wpinv_upload_callback($args) {
1341 1341
 	global $wpinv_options;
1342 1342
     
1343
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1343
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1344 1344
 
1345
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1345
+	if (isset($wpinv_options[$args['id']])) {
1346 1346
 		$value = $wpinv_options[$args['id']];
1347 1347
 	} else {
1348 1348
 		$value = isset($args['std']) ? $args['std'] : '';
1349 1349
 	}
1350 1350
 
1351
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1352
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1353
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1354
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1351
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1352
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
1353
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1354
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1355 1355
 
1356 1356
 	echo $html;
1357 1357
 }
1358 1358
 
1359
-function wpinv_color_callback( $args ) {
1359
+function wpinv_color_callback($args) {
1360 1360
 	global $wpinv_options;
1361 1361
     
1362
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1362
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1363 1363
 
1364
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1365
-		$value = $wpinv_options[ $args['id'] ];
1364
+	if (isset($wpinv_options[$args['id']])) {
1365
+		$value = $wpinv_options[$args['id']];
1366 1366
 	} else {
1367
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1367
+		$value = isset($args['std']) ? $args['std'] : '';
1368 1368
 	}
1369 1369
 
1370
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1370
+	$default = isset($args['std']) ? $args['std'] : '';
1371 1371
 
1372
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1373
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1372
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($default) . '" />';
1373
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1374 1374
 
1375 1375
 	echo $html;
1376 1376
 }
@@ -1378,9 +1378,9 @@  discard block
 block discarded – undo
1378 1378
 function wpinv_country_states_callback($args) {
1379 1379
 	global $wpinv_options;
1380 1380
     
1381
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1381
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1382 1382
 
1383
-	if ( isset( $args['placeholder'] ) ) {
1383
+	if (isset($args['placeholder'])) {
1384 1384
 		$placeholder = $args['placeholder'];
1385 1385
 	} else {
1386 1386
 		$placeholder = '';
@@ -1388,16 +1388,16 @@  discard block
 block discarded – undo
1388 1388
 
1389 1389
 	$states = wpinv_get_country_states();
1390 1390
 
1391
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : '';
1392
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1391
+	$class = empty($states) ? ' class="wpinv-no-states"' : '';
1392
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1393 1393
 
1394
-	foreach ( $states as $option => $name ) {
1395
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1396
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1394
+	foreach ($states as $option => $name) {
1395
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1396
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1397 1397
 	}
1398 1398
 
1399 1399
 	$html .= '</select>';
1400
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1400
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1401 1401
 
1402 1402
 	echo $html;
1403 1403
 }
@@ -1412,95 +1412,95 @@  discard block
 block discarded – undo
1412 1412
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1413 1413
 		<thead>
1414 1414
 			<tr>
1415
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1416
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1417
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1418
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1419
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1420
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1415
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1416
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1417
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1418
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1419
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1420
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1421 1421
 			</tr>
1422 1422
 		</thead>
1423 1423
         <tbody>
1424
-		<?php if( !empty( $rates ) ) : ?>
1425
-			<?php foreach( $rates as $key => $rate ) : ?>
1424
+		<?php if (!empty($rates)) : ?>
1425
+			<?php foreach ($rates as $key => $rate) : ?>
1426 1426
             <?php 
1427
-            $sanitized_key = wpinv_sanitize_key( $key );
1427
+            $sanitized_key = wpinv_sanitize_key($key);
1428 1428
             ?>
1429 1429
 			<tr>
1430 1430
 				<td class="wpinv_tax_country">
1431 1431
 					<?php
1432
-					echo wpinv_html_select( array(
1433
-						'options'          => wpinv_get_country_list( true ),
1432
+					echo wpinv_html_select(array(
1433
+						'options'          => wpinv_get_country_list(true),
1434 1434
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1435 1435
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1436 1436
 						'selected'         => $rate['country'],
1437 1437
 						'show_option_all'  => false,
1438 1438
 						'show_option_none' => false,
1439 1439
 						'class'            => 'wpinv-tax-country',
1440
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1441
-					) );
1440
+						'placeholder'      => __('Choose a country', 'invoicing')
1441
+					));
1442 1442
 					?>
1443 1443
 				</td>
1444 1444
 				<td class="wpinv_tax_state">
1445 1445
 					<?php
1446
-					$states = wpinv_get_country_states( $rate['country'] );
1447
-					if( !empty( $states ) ) {
1448
-						echo wpinv_html_select( array(
1449
-							'options'          => array_merge( array( '' => '' ), $states ),
1446
+					$states = wpinv_get_country_states($rate['country']);
1447
+					if (!empty($states)) {
1448
+						echo wpinv_html_select(array(
1449
+							'options'          => array_merge(array('' => ''), $states),
1450 1450
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1451 1451
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1452 1452
 							'selected'         => $rate['state'],
1453 1453
 							'show_option_all'  => false,
1454 1454
 							'show_option_none' => false,
1455
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1456
-						) );
1455
+							'placeholder'      => __('Choose a state', 'invoicing')
1456
+						));
1457 1457
 					} else {
1458
-						echo wpinv_html_text( array(
1458
+						echo wpinv_html_text(array(
1459 1459
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1460
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1460
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1461 1461
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1462
-						) );
1462
+						));
1463 1463
 					}
1464 1464
 					?>
1465 1465
 				</td>
1466 1466
 				<td class="wpinv_tax_global">
1467
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
1468
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1467
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
1468
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1469 1469
 				</td>
1470
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1471
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1472
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1470
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1471
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1472
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1473 1473
 			</tr>
1474 1474
 			<?php endforeach; ?>
1475 1475
 		<?php else : ?>
1476 1476
 			<tr>
1477 1477
 				<td class="wpinv_tax_country">
1478 1478
 					<?php
1479
-					echo wpinv_html_select( array(
1480
-						'options'          => wpinv_get_country_list( true ),
1479
+					echo wpinv_html_select(array(
1480
+						'options'          => wpinv_get_country_list(true),
1481 1481
 						'name'             => 'tax_rates[0][country]',
1482 1482
 						'show_option_all'  => false,
1483 1483
 						'show_option_none' => false,
1484 1484
 						'class'            => 'wpinv-tax-country',
1485
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1486
-					) ); ?>
1485
+						'placeholder'      => __('Choose a country', 'invoicing')
1486
+					)); ?>
1487 1487
 				</td>
1488 1488
 				<td class="wpinv_tax_state">
1489
-					<?php echo wpinv_html_text( array(
1489
+					<?php echo wpinv_html_text(array(
1490 1490
 						'name' => 'tax_rates[0][state]'
1491
-					) ); ?>
1491
+					)); ?>
1492 1492
 				</td>
1493 1493
 				<td class="wpinv_tax_global">
1494 1494
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1495
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1495
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1496 1496
 				</td>
1497
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1497
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td>
1498 1498
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1499
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1499
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1500 1500
 			</tr>
1501 1501
 		<?php endif; ?>
1502 1502
         </tbody>
1503
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1503
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1504 1504
 	</table>
1505 1505
 	<?php
1506 1506
 	echo ob_get_clean();
@@ -1511,76 +1511,76 @@  discard block
 block discarded – undo
1511 1511
     ob_start(); ?>
1512 1512
     </td><tr>
1513 1513
     <td colspan="2" class="wpinv_tools_tdbox">
1514
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1515
-    <?php do_action( 'wpinv_tools_before' ); ?>
1514
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1515
+    <?php do_action('wpinv_tools_before'); ?>
1516 1516
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1517 1517
         <thead>
1518 1518
             <tr>
1519
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1520
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1521
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1519
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1520
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1521
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1522 1522
             </tr>
1523 1523
         </thead>
1524
-            <?php do_action( 'wpinv_tools_row' ); ?>
1524
+            <?php do_action('wpinv_tools_row'); ?>
1525 1525
         <tbody>
1526 1526
         </tbody>
1527 1527
     </table>
1528
-    <?php do_action( 'wpinv_tools_after' ); ?>
1528
+    <?php do_action('wpinv_tools_after'); ?>
1529 1529
     <?php
1530 1530
     echo ob_get_clean();
1531 1531
 }
1532 1532
 
1533
-function wpinv_descriptive_text_callback( $args ) {
1534
-	echo wp_kses_post( $args['desc'] );
1533
+function wpinv_descriptive_text_callback($args) {
1534
+	echo wp_kses_post($args['desc']);
1535 1535
 }
1536 1536
 
1537
-function wpinv_hook_callback( $args ) {
1538
-	do_action( 'wpinv_' . $args['id'], $args );
1537
+function wpinv_hook_callback($args) {
1538
+	do_action('wpinv_' . $args['id'], $args);
1539 1539
 }
1540 1540
 
1541 1541
 function wpinv_set_settings_cap() {
1542 1542
 	return 'manage_options';
1543 1543
 }
1544
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1544
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1545 1545
 
1546
-function wpinv_settings_sanitize_input( $value, $key ) {
1547
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1548
-        $value = wpinv_sanitize_amount( $value, 4 );
1546
+function wpinv_settings_sanitize_input($value, $key) {
1547
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1548
+        $value = wpinv_sanitize_amount($value, 4);
1549 1549
         $value = $value >= 100 ? 99 : $value;
1550 1550
     }
1551 1551
         
1552 1552
     return $value;
1553 1553
 }
1554
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1554
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1555 1555
 
1556
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1557
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1558
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1556
+function wpinv_on_update_settings($old_value, $value, $option) {
1557
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1558
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1559 1559
     
1560
-    if ( $old != $new ) {
1561
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1560
+    if ($old != $new) {
1561
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1562 1562
     }
1563 1563
 }
1564
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1565
-add_action( 'wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1566
-add_action( 'wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1567
-add_action( 'wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1568
-add_action( 'wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1569
-add_action( 'wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1570
-add_action( 'wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1571
-add_action( 'wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1572
-add_action( 'wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1573
-add_action( 'wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1574
-add_action( 'wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2 );
1575
-
1576
-function wpinv_settings_tab_bottom_emails( $active_tab, $section ) {
1564
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1565
+add_action('wpinv_settings_tab_bottom_emails_new_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1566
+add_action('wpinv_settings_tab_bottom_emails_cancelled_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1567
+add_action('wpinv_settings_tab_bottom_emails_failed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1568
+add_action('wpinv_settings_tab_bottom_emails_onhold_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1569
+add_action('wpinv_settings_tab_bottom_emails_processing_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1570
+add_action('wpinv_settings_tab_bottom_emails_completed_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1571
+add_action('wpinv_settings_tab_bottom_emails_refunded_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1572
+add_action('wpinv_settings_tab_bottom_emails_user_invoice', 'wpinv_settings_tab_bottom_emails', 10, 2);
1573
+add_action('wpinv_settings_tab_bottom_emails_user_note', 'wpinv_settings_tab_bottom_emails', 10, 2);
1574
+add_action('wpinv_settings_tab_bottom_emails_overdue', 'wpinv_settings_tab_bottom_emails', 10, 2);
1575
+
1576
+function wpinv_settings_tab_bottom_emails($active_tab, $section) {
1577 1577
     ?>
1578 1578
     <div class="wpinv-email-wc-row ">
1579 1579
         <div class="wpinv-email-wc-td">
1580
-            <h3 class="wpinv-email-wc-title"><?php echo apply_filters( 'wpinv_settings_email_wildcards_title', __( 'Wildcards For Emails', 'invoicing' ) ); ?></h3>
1580
+            <h3 class="wpinv-email-wc-title"><?php echo apply_filters('wpinv_settings_email_wildcards_title', __('Wildcards For Emails', 'invoicing')); ?></h3>
1581 1581
             <p class="wpinv-email-wc-description">
1582 1582
                 <?php
1583
-                $description = __( 'The following wildcards can be used in email subjects, heading and content:<br>
1583
+                $description = __('The following wildcards can be used in email subjects, heading and content:<br>
1584 1584
                     <strong>{site_title} :</strong> Site Title<br>
1585 1585
                     <strong>{name} :</strong> Customer\'s full name<br>
1586 1586
                     <strong>{first_name} :</strong> Customer\'s first name<br>
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                     <strong>{invoice_due_date} :</strong> The date the invoice is due<br>
1595 1595
                     <strong>{date} :</strong> Today\'s date.<br>
1596 1596
                     <strong>{is_was} :</strong> If due date of invoice is past, displays "was" otherwise displays "is"<br>
1597
-                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing' );
1597
+                    <strong>{invoice_label} :</strong> Invoices/quotes singular name. Ex: Invoice/Quote<br>', 'invoicing');
1598 1598
                 echo apply_filters('wpinv_settings_email_wildcards_description', $description, $active_tab, $section);
1599 1599
                 ?>
1600 1600
             </p>
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -7,245 +7,245 @@  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
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Created Date', 'invoicing' ),
21
-        'payment_date'      => __( 'Payment Date', 'invoicing' ),
22
-        'status'            => __( 'Status', 'invoicing' ),
23
-        'ID'                => __( 'ID', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Created Date', 'invoicing'),
21
+        'payment_date'      => __('Payment Date', 'invoicing'),
22
+        'status'            => __('Status', 'invoicing'),
23
+        'ID'                => __('ID', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
39
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
40 40
 
41
-function wpinv_sortable_columns( $columns ) {
41
+function wpinv_sortable_columns($columns) {
42 42
     $columns = array(
43
-        'ID'            => array( 'ID', true ),
44
-        'number'        => array( 'number', false ),
45
-        'amount'        => array( 'amount', false ),
46
-        'invoice_date'  => array( 'date', false ),
47
-        'payment_date'  => array( 'payment_date', true ),
48
-        'customer'      => array( 'customer', false ),
49
-        'status'        => array( 'status', false ),
43
+        'ID'            => array('ID', true),
44
+        'number'        => array('number', false),
45
+        'amount'        => array('amount', false),
46
+        'invoice_date'  => array('date', false),
47
+        'payment_date'  => array('payment_date', true),
48
+        'customer'      => array('customer', false),
49
+        'status'        => array('status', false),
50 50
     );
51 51
     
52
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
52
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
53 53
 }
54
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
54
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
55 55
 
56
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
56
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
58 58
     global $post, $wpi_invoice;
59 59
     
60
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
61
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
60
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
61
+        $wpi_invoice = new WPInv_Invoice($post->ID);
62 62
     }
63 63
 
64 64
     $value = NULL;
65 65
     
66
-    switch ( $column_name ) {
66
+    switch ($column_name) {
67 67
         case 'email' :
68
-            $value   = $wpi_invoice->get_email();
68
+            $value = $wpi_invoice->get_email();
69 69
             break;
70 70
         case 'customer' :
71 71
             $customer_name = $wpi_invoice->get_user_full_name();
72
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
73
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
74
-            if ( $email = $wpi_invoice->get_email() ) {
72
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
73
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
74
+            if ($email = $wpi_invoice->get_email()) {
75 75
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
76 76
             }
77 77
             break;
78 78
         case 'amount' :
79
-            echo $wpi_invoice->get_total( true );
79
+            echo $wpi_invoice->get_total(true);
80 80
             break;
81 81
         case 'invoice_date' :
82
-            $date_format = get_option( 'date_format' );
83
-            $time_format = get_option( 'time_format' );
84
-            $date_time_format = $date_format . ' '. $time_format;
82
+            $date_format = get_option('date_format');
83
+            $time_format = get_option('time_format');
84
+            $date_time_format = $date_format . ' ' . $time_format;
85 85
             
86 86
             $m_time = $post->post_date;
87
-            $h_time = mysql2date( $date_format, $m_time );
87
+            $h_time = mysql2date($date_format, $m_time);
88 88
             
89
-            $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
89
+            $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
90 90
             break;
91 91
         case 'payment_date' :
92
-            if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) {
93
-                $date_format = get_option( 'date_format' );
94
-                $time_format = get_option( 'time_format' );
95
-                $date_time_format = $date_format . ' '. $time_format;
92
+            if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) {
93
+                $date_format = get_option('date_format');
94
+                $time_format = get_option('time_format');
95
+                $date_time_format = $date_format . ' ' . $time_format;
96 96
                 
97 97
                 $m_time = $date_completed;
98
-                $h_time = mysql2date( $date_format, $m_time );
98
+                $h_time = mysql2date($date_format, $m_time);
99 99
                 
100
-                $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
100
+                $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
101 101
             } else {
102 102
                 $value = '-';
103 103
             }
104 104
             break;
105 105
         case 'status' :
106
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
107
-            $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
108
-            if ( 1 == $is_viewed ) {
109
-                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
106
+            $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
107
+            $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID);
108
+            if (1 == $is_viewed) {
109
+                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>';
110 110
             }
111
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() ) && ( $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() ) ) ) {
112
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
111
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded()) && ($gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway()))) {
112
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
113 113
             }
114 114
             break;
115 115
         case 'number' :
116
-            $edit_link = get_edit_post_link( $post->ID );
117
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
116
+            $edit_link = get_edit_post_link($post->ID);
117
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
118 118
             break;
119 119
         case 'wpi_actions' :
120 120
             $value = '';
121
-            if ( !empty( $post->post_name ) ) {
122
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
121
+            if (!empty($post->post_name)) {
122
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
123 123
             }
124 124
             
125
-            if ( $email = $wpi_invoice->get_email() ) {
126
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
125
+            if ($email = $wpi_invoice->get_email()) {
126
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
127 127
             }
128 128
             
129 129
             break;
130 130
         default:
131
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
131
+            $value = isset($post->$column_name) ? $post->$column_name : '';
132 132
             break;
133 133
 
134 134
     }
135
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
135
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
136 136
     
137
-    if ( $value !== NULL ) {
137
+    if ($value !== NULL) {
138 138
         echo $value;
139 139
     }
140 140
 }
141 141
 
142
-function wpinv_admin_post_id( $id = 0 ) {
142
+function wpinv_admin_post_id($id = 0) {
143 143
     global $post;
144 144
 
145
-    if ( isset( $id ) && ! empty( $id ) ) {
145
+    if (isset($id) && !empty($id)) {
146 146
         return (int)$id;
147
-    } else if ( get_the_ID() ) {
148
-        return (int) get_the_ID();
149
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
150
-        return (int) $post->ID;
151
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
152
-        return (int) $_GET['post'];
153
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
154
-        return (int) $_GET['id'];
155
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
156
-        return (int) $_POST['id'];
147
+    } else if (get_the_ID()) {
148
+        return (int)get_the_ID();
149
+    } else if (isset($post->ID) && !empty($post->ID)) {
150
+        return (int)$post->ID;
151
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
152
+        return (int)$_GET['post'];
153
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
154
+        return (int)$_GET['id'];
155
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
156
+        return (int)$_POST['id'];
157 157
     } 
158 158
 
159 159
     return null;
160 160
 }
161 161
     
162
-function wpinv_admin_post_type( $id = 0 ) {
163
-    if ( !$id ) {
162
+function wpinv_admin_post_type($id = 0) {
163
+    if (!$id) {
164 164
         $id = wpinv_admin_post_id();
165 165
     }
166 166
     
167
-    $type = get_post_type( $id );
167
+    $type = get_post_type($id);
168 168
     
169
-    if ( !$type ) {
170
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
169
+    if (!$type) {
170
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
171 171
     }
172 172
     
173
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
173
+    return apply_filters('wpinv_admin_post_type', $type, $id);
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177 177
 	global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
179
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
180
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
181 181
 	}
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
183
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
184
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
185 185
 	}
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
187
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
188
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
189 189
 	}
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
191
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
192
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
193 193
 	}
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
195
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
196
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
197 197
 	}
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
199
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
200
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
201 201
 	}
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
203
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
204
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
205 205
 	}
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
208
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
209 209
     }
210 210
     
211
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
211
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
212
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
213 213
     }
214 214
 
215
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
216
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
215
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
216
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
219
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
220
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
221 221
 	}
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
223
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
224
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
225 225
 	}
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
227
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
228
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
229 229
 	}
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
232
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
234
+		if (!empty($message)) {
235
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
236 236
 		}
237 237
 	}
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+	settings_errors('wpinv-notices');
240 240
 }
241
-add_action( 'admin_notices', 'wpinv_admin_messages' );
241
+add_action('admin_notices', 'wpinv_admin_messages');
242 242
 
243
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
244
-function wpinv_show_test_payment_gateway_notice(){
245
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
243
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
244
+function wpinv_show_test_payment_gateway_notice() {
245
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
246 246
 }
247 247
 
248
-function wpinv_test_payment_gateway_messages(){
248
+function wpinv_test_payment_gateway_messages() {
249 249
     $gateways = wpinv_get_enabled_payment_gateways();
250 250
     $name = array(); $test_gateways = '';
251 251
     if ($gateways) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         }
257 257
         $test_gateways = implode(', ', $name);
258 258
     }
259
-    if(isset($test_gateways) && !empty($test_gateways)){
259
+    if (isset($test_gateways) && !empty($test_gateways)) {
260 260
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
261
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
261
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
262 262
         ?>
263 263
         <div class="notice notice-warning is-dismissible">
264 264
             <p><?php echo $notice; ?></p>
@@ -267,29 +267,29 @@  discard block
 block discarded – undo
267 267
     }
268 268
 }
269 269
 
270
-function wpinv_items_columns( $existing_columns ) {
270
+function wpinv_items_columns($existing_columns) {
271 271
     global $wpinv_euvat;
272 272
     
273 273
     $columns                = array();
274 274
     $columns['cb']          = $existing_columns['cb'];
275
-    $columns['title']       = __( 'Title', 'invoicing' );
276
-    $columns['price']       = __( 'Price', 'invoicing' );
277
-    if ( $wpinv_euvat->allow_vat_rules() ) {
278
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
275
+    $columns['title']       = __('Title', 'invoicing');
276
+    $columns['price']       = __('Price', 'invoicing');
277
+    if ($wpinv_euvat->allow_vat_rules()) {
278
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
279 279
     }
280
-    if ( $wpinv_euvat->allow_vat_classes() ) {
281
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
280
+    if ($wpinv_euvat->allow_vat_classes()) {
281
+        $columns['vat_class']   = __('VAT class', 'invoicing');
282 282
     }
283
-    $columns['type']        = __( 'Type', 'invoicing' );
284
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
285
-    $columns['date']        = __( 'Date', 'invoicing' );
286
-    $columns['id']          = __( 'ID', 'invoicing' );
283
+    $columns['type']        = __('Type', 'invoicing');
284
+    $columns['recurring']   = __('Recurring', 'invoicing');
285
+    $columns['date']        = __('Date', 'invoicing');
286
+    $columns['id']          = __('ID', 'invoicing');
287 287
 
288
-    return apply_filters( 'wpinv_items_columns', $columns );
288
+    return apply_filters('wpinv_items_columns', $columns);
289 289
 }
290
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
290
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
291 291
 
292
-function wpinv_items_sortable_columns( $columns ) {
292
+function wpinv_items_sortable_columns($columns) {
293 293
     $columns['price']       = 'price';
294 294
     $columns['vat_rule']    = 'vat_rule';
295 295
     $columns['vat_class']   = 'vat_class';
@@ -299,151 +299,151 @@  discard block
 block discarded – undo
299 299
 
300 300
     return $columns;
301 301
 }
302
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
302
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
303 303
 
304
-function wpinv_items_table_custom_column( $column ) {
304
+function wpinv_items_table_custom_column($column) {
305 305
     global $wpinv_euvat, $post, $wpi_item;
306 306
     
307
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
308
-        $wpi_item = new WPInv_Item( $post->ID );
307
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
308
+        $wpi_item = new WPInv_Item($post->ID);
309 309
     }
310 310
 
311
-    switch ( $column ) {
311
+    switch ($column) {
312 312
         case 'price' :
313
-            echo wpinv_item_price( $post->ID );
313
+            echo wpinv_item_price($post->ID);
314 314
         break;
315 315
         case 'vat_rule' :
316
-            echo $wpinv_euvat->item_rule_label( $post->ID );
316
+            echo $wpinv_euvat->item_rule_label($post->ID);
317 317
         break;
318 318
         case 'vat_class' :
319
-            echo $wpinv_euvat->item_class_label( $post->ID );
319
+            echo $wpinv_euvat->item_class_label($post->ID);
320 320
         break;
321 321
         case 'type' :
322
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
322
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
323 323
         break;
324 324
         case 'recurring' :
325
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
325
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
326 326
         break;
327 327
         case 'id' :
328 328
            echo $post->ID;
329 329
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
330
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
331
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
332
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
330
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
331
+                    if ($wpinv_euvat->allow_vat_rules()) {
332
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
333 333
                     }
334
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
335
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
334
+                    if ($wpinv_euvat->allow_vat_classes()) {
335
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
336 336
                     }
337
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
337
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
338 338
                 </div>';
339 339
         break;
340 340
     }
341 341
     
342
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
342
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
343 343
 }
344
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
344
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
345 345
 
346 346
 function wpinv_add_items_filters() {
347 347
     global $wpinv_euvat, $typenow;
348 348
 
349 349
     // Checks if the current post type is 'item'
350
-    if ( $typenow == 'wpi_item') {
351
-        if ( $wpinv_euvat->allow_vat_rules() ) {
352
-            echo wpinv_html_select( array(
353
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
350
+    if ($typenow == 'wpi_item') {
351
+        if ($wpinv_euvat->allow_vat_rules()) {
352
+            echo wpinv_html_select(array(
353
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
354 354
                     'name'             => 'vat_rule',
355 355
                     'id'               => 'vat_rule',
356
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
356
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
357 357
                     'show_option_all'  => false,
358 358
                     'show_option_none' => false,
359 359
                     'class'            => 'gdmbx2-text-medium',
360
-                ) );
360
+                ));
361 361
         }
362 362
         
363
-        if ( $wpinv_euvat->allow_vat_classes() ) {
364
-            echo wpinv_html_select( array(
365
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
363
+        if ($wpinv_euvat->allow_vat_classes()) {
364
+            echo wpinv_html_select(array(
365
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
366 366
                     'name'             => 'vat_class',
367 367
                     'id'               => 'vat_class',
368
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
368
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
369 369
                     'show_option_all'  => false,
370 370
                     'show_option_none' => false,
371 371
                     'class'            => 'gdmbx2-text-medium',
372
-                ) );
372
+                ));
373 373
         }
374 374
             
375
-        echo wpinv_html_select( array(
376
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
375
+        echo wpinv_html_select(array(
376
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
377 377
                 'name'             => 'type',
378 378
                 'id'               => 'type',
379
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
379
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
380 380
                 'show_option_all'  => false,
381 381
                 'show_option_none' => false,
382 382
                 'class'            => 'gdmbx2-text-medium',
383
-            ) );
383
+            ));
384 384
 
385
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
385
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
386 386
             echo '<input type="hidden" name="all_posts" value="1" />';
387 387
         }
388 388
     }
389 389
 }
390
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
390
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
391 391
 
392
-function wpinv_send_invoice_after_save( $invoice ) {
393
-    if ( empty( $_POST['wpi_save_send'] ) ) {
392
+function wpinv_send_invoice_after_save($invoice) {
393
+    if (empty($_POST['wpi_save_send'])) {
394 394
         return;
395 395
     }
396 396
     
397
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
398
-        wpinv_user_invoice_notification( $invoice->ID );
397
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
398
+        wpinv_user_invoice_notification($invoice->ID);
399 399
     }
400 400
 }
401
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
401
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
402 402
 
403
-function wpinv_send_register_new_user( $data, $postarr ) {
404
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
405
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
406
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
403
+function wpinv_send_register_new_user($data, $postarr) {
404
+    if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
405
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
406
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
407 407
         
408
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
409
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
410
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
411
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
412
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
413
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
408
+        if ($is_new_user && $email && !email_exists($email)) {
409
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
410
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
411
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
412
+            $user_nicename = $display_name ? trim($display_name) : $email;
413
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
414 414
             
415
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
416
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
415
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
416
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
417 417
                 $new_user_login = strstr($email, '@', true);
418
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
419
-                    $user_login = sanitize_user($new_user_login, true );
418
+                if (validate_username($user_login) && username_exists($user_login)) {
419
+                    $user_login = sanitize_user($new_user_login, true);
420 420
                 }
421
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
422
-                    $user_append_text = rand(10,1000);
423
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
421
+                if (validate_username($user_login) && username_exists($user_login)) {
422
+                    $user_append_text = rand(10, 1000);
423
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
424 424
                 }
425 425
                 
426
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
426
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
427 427
                     $user_login = $email;
428 428
                 }
429 429
             }
430 430
             
431 431
             $userdata = array(
432 432
                 'user_login' => $user_login,
433
-                'user_pass' => wp_generate_password( 12, false ),
434
-                'user_email' => sanitize_text_field( $email ),
433
+                'user_pass' => wp_generate_password(12, false),
434
+                'user_email' => sanitize_text_field($email),
435 435
                 'first_name' => $first_name,
436 436
                 'last_name' => $last_name,
437
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
437
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
438 438
                 'nickname' => $display_name,
439 439
                 'display_name' => $display_name,
440 440
             );
441 441
 
442
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
442
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
443 443
             
444
-            $new_user_id = wp_insert_user( $userdata );
444
+            $new_user_id = wp_insert_user($userdata);
445 445
             
446
-            if ( !is_wp_error( $new_user_id ) ) {
446
+            if (!is_wp_error($new_user_id)) {
447 447
                 $data['post_author'] = $new_user_id;
448 448
                 $_POST['post_author'] = $new_user_id;
449 449
                 $_POST['post_author_override'] = $new_user_id;
@@ -464,72 +464,72 @@  discard block
 block discarded – undo
464 464
                 
465 465
                 $meta = array();
466 466
                 ///$meta['_wpinv_user_id'] = $new_user_id;
467
-                foreach ( $meta_fields as $field ) {
468
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
467
+                foreach ($meta_fields as $field) {
468
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
469 469
                 }
470 470
                 
471
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
471
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
472 472
 
473 473
                 // Update user meta.
474
-                foreach ( $meta as $key => $value ) {
475
-                    update_user_meta( $new_user_id, $key, $value );
474
+                foreach ($meta as $key => $value) {
475
+                    update_user_meta($new_user_id, $key, $value);
476 476
                 }
477 477
                 
478
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
478
+                if (function_exists('wp_send_new_user_notifications')) {
479 479
                     // Send email notifications related to the creation of new user.
480
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
480
+                    wp_send_new_user_notifications($new_user_id, 'user');
481 481
                 }
482 482
             } else {
483
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
483
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
484 484
             }
485 485
         }
486 486
     }
487 487
     
488 488
     return $data;
489 489
 }
490
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
490
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
491 491
 
492
-function wpinv_show_recurring_supported_gateways( $item_ID ) {
492
+function wpinv_show_recurring_supported_gateways($item_ID) {
493 493
     $all_gateways = wpinv_get_payment_gateways();
494 494
 
495
-    if ( !empty( $all_gateways ) ) {
495
+    if (!empty($all_gateways)) {
496 496
         $gateways = array();
497 497
 
498
-        foreach ( $all_gateways as $key => $gateway ) {
499
-            if ( wpinv_gateway_support_subscription( $key ) ) {
498
+        foreach ($all_gateways as $key => $gateway) {
499
+            if (wpinv_gateway_support_subscription($key)) {
500 500
                 $gateways[] = $gateway['admin_label'];
501 501
             }
502 502
         }
503 503
 
504
-        if ( !empty( $gateways ) ) {
504
+        if (!empty($gateways)) {
505 505
             ?>
506
-            <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span>
506
+            <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span>
507 507
             <?php
508 508
         }
509 509
     }
510 510
 }
511
-add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 );
511
+add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1);
512 512
 
513
-function wpinv_post_updated_messages( $messages ) {
513
+function wpinv_post_updated_messages($messages) {
514 514
     global $post, $post_ID;
515 515
 
516 516
     $messages['wpi_discount'] = array(
517 517
         0   => '',
518
-        1   => __( 'Discount updated.', 'invoicing' ),
519
-        2   => __( 'Custom field updated.', 'invoicing' ),
520
-        3   => __( 'Custom field deleted.', 'invoicing' ),
521
-        4   => __( 'Discount updated.', 'invoicing' ),
522
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
523
-        6   => __( 'Discount updated.', 'invoicing' ),
524
-        7   => __( 'Discount saved.', 'invoicing' ),
525
-        8   => __( 'Discount submitted.', 'invoicing' ),
526
-        9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
527
-        10  => __( 'Discount draft updated.', 'invoicing' ),
518
+        1   => __('Discount updated.', 'invoicing'),
519
+        2   => __('Custom field updated.', 'invoicing'),
520
+        3   => __('Custom field deleted.', 'invoicing'),
521
+        4   => __('Discount updated.', 'invoicing'),
522
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int)$_GET['revision'], false)) : false,
523
+        6   => __('Discount updated.', 'invoicing'),
524
+        7   => __('Discount saved.', 'invoicing'),
525
+        8   => __('Discount submitted.', 'invoicing'),
526
+        9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
527
+        10  => __('Discount draft updated.', 'invoicing'),
528 528
     );
529 529
 
530 530
     return $messages;
531 531
 }
532
-add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 );
532
+add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1);
533 533
 
534 534
 add_action('admin_init', 'admin_init_example_type');
535 535
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 function admin_init_example_type() {
540 540
     global $typenow;
541 541
 
542
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
542
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
543 543
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
544 544
     }
545 545
 }
@@ -554,9 +554,9 @@  discard block
 block discarded – undo
554 554
     global $wpdb;
555 555
 
556 556
     if ($query->is_main_query() && !empty($query->query['s'])) {
557
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
558
-        if ( ! empty( $search ) ) {
559
-            $search = preg_replace( '/^ AND /', '', $search );
557
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
558
+        if (!empty($search)) {
559
+            $search = preg_replace('/^ AND /', '', $search);
560 560
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
561 561
         } else {
562 562
             $search = " AND ( {$conditions_str} )";
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
     return $search;
567 567
 }
568 568
 
569
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
570
-function wpinv_reset_invoice_count(){
571
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
569
+add_action('admin_init', 'wpinv_reset_invoice_count');
570
+function wpinv_reset_invoice_count() {
571
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
572 572
         wpinv_update_option('invoice_sequence_start', 1);
573 573
         delete_option('wpinv_last_invoice_number');
574 574
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -579,8 +579,8 @@  discard block
 block discarded – undo
579 579
 }
580 580
 
581 581
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
582
-function wpinv_invoice_count_reset_message(){
583
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
582
+function wpinv_invoice_count_reset_message() {
583
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
584 584
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
585 585
         ?>
586 586
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +283 added lines, -283 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,253 +251,253 @@  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 ) {
397
+function wpinv_cart_item_price($item) {
398 398
     $use_taxes  = wpinv_use_taxes();
399
-    $item_id    = isset( $item['id'] ) ? $item['id'] : 0;
400
-    $price      = isset( $item['item_price'] ) ? wpinv_round_amount( $item['item_price'] ) : 0;
401
-    $options    = isset( $item['options'] ) ? $item['options'] : array();
402
-    $price_id   = isset( $options['price_id'] ) ? $options['price_id'] : false;
403
-    $tax        = wpinv_price( wpinv_format_amount( $item['tax'] ) );
404
-    
405
-    if ( !wpinv_is_free_item( $item_id, $price_id ) && !wpinv_item_is_tax_exclusive( $item_id ) ) {
406
-        if ( wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax() ) {
399
+    $item_id    = isset($item['id']) ? $item['id'] : 0;
400
+    $price      = isset($item['item_price']) ? wpinv_round_amount($item['item_price']) : 0;
401
+    $options    = isset($item['options']) ? $item['options'] : array();
402
+    $price_id   = isset($options['price_id']) ? $options['price_id'] : false;
403
+    $tax        = wpinv_price(wpinv_format_amount($item['tax']));
404
+    
405
+    if (!wpinv_is_free_item($item_id, $price_id) && !wpinv_item_is_tax_exclusive($item_id)) {
406
+        if (wpinv_prices_show_tax_on_checkout() && !wpinv_prices_include_tax()) {
407 407
             $price += $tax;
408 408
         }
409 409
         
410
-        if( !wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax() ) {
410
+        if (!wpinv_prices_show_tax_on_checkout() && wpinv_prices_include_tax()) {
411 411
             $price -= $tax;
412 412
         }        
413 413
     }
414 414
 
415
-    $price = wpinv_price( wpinv_format_amount( $price ) );
415
+    $price = wpinv_price(wpinv_format_amount($price));
416 416
 
417
-    return apply_filters( 'wpinv_cart_item_price_label', $price, $item );
417
+    return apply_filters('wpinv_cart_item_price_label', $price, $item);
418 418
 }
419 419
 
420
-function wpinv_cart_item_subtotal( $item ) {
421
-    $subtotal   = isset( $item['subtotal'] ) ? $item['subtotal'] : 0;
422
-    $subtotal   = wpinv_price( wpinv_format_amount( $subtotal ) );
420
+function wpinv_cart_item_subtotal($item) {
421
+    $subtotal   = isset($item['subtotal']) ? $item['subtotal'] : 0;
422
+    $subtotal   = wpinv_price(wpinv_format_amount($subtotal));
423 423
 
424
-    return apply_filters( 'wpinv_cart_item_subtotal_label', $subtotal, $item );
424
+    return apply_filters('wpinv_cart_item_subtotal_label', $subtotal, $item);
425 425
 }
426 426
 
427
-function wpinv_cart_item_tax( $item ) {
427
+function wpinv_cart_item_tax($item) {
428 428
     $tax        = '';
429 429
     $tax_rate   = '';
430 430
     
431
-    if ( isset( $item['tax'] ) && $item['tax'] > 0 && $item['subtotal'] > 0 ) {
432
-        $tax      = wpinv_price( wpinv_format_amount( $item['tax'] ) );
433
-        $tax_rate = !empty( $item['vat_rate'] ) ? $item['vat_rate'] : ( $item['tax'] / $item['subtotal'] ) * 100;
434
-        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
431
+    if (isset($item['tax']) && $item['tax'] > 0 && $item['subtotal'] > 0) {
432
+        $tax      = wpinv_price(wpinv_format_amount($item['tax']));
433
+        $tax_rate = !empty($item['vat_rate']) ? $item['vat_rate'] : ($item['tax'] / $item['subtotal']) * 100;
434
+        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
435 435
         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate normal small">(' . $tax_rate . '%)</small>' : '';
436 436
     }
437 437
     
438
-    $tax        = $tax . $tax_rate;
438
+    $tax = $tax . $tax_rate;
439 439
     
440
-    if ( $tax === '' ) {
440
+    if ($tax === '') {
441 441
         $tax = 0; // Zero tax
442 442
     }
443 443
 
444
-    return apply_filters( 'wpinv_cart_item_tax_label', $tax, $item );
444
+    return apply_filters('wpinv_cart_item_tax_label', $tax, $item);
445 445
 }
446 446
 
447
-function wpinv_get_cart_item_price( $item_id = 0, $cart_item = array(), $options = array(), $remove_tax_from_inclusive = false ) {
447
+function wpinv_get_cart_item_price($item_id = 0, $cart_item = array(), $options = array(), $remove_tax_from_inclusive = false) {
448 448
     $price = 0;
449 449
     
450 450
     // Set custom price
451
-    if ( isset( $cart_item['custom_price'] ) && $cart_item['custom_price'] !== '' ) {
451
+    if (isset($cart_item['custom_price']) && $cart_item['custom_price'] !== '') {
452 452
         $price = $cart_item['custom_price'];
453 453
     } else {
454
-        $variable_prices = wpinv_has_variable_prices( $item_id );
454
+        $variable_prices = wpinv_has_variable_prices($item_id);
455 455
 
456
-        if ( $variable_prices ) {
457
-            $prices = wpinv_get_variable_prices( $item_id );
456
+        if ($variable_prices) {
457
+            $prices = wpinv_get_variable_prices($item_id);
458 458
 
459
-            if ( $prices ) {
460
-                if( ! empty( $options ) ) {
461
-                    $price = isset( $prices[ $options['price_id'] ] ) ? $prices[ $options['price_id'] ]['amount'] : false;
459
+            if ($prices) {
460
+                if (!empty($options)) {
461
+                    $price = isset($prices[$options['price_id']]) ? $prices[$options['price_id']]['amount'] : false;
462 462
                 } else {
463 463
                     $price = false;
464 464
                 }
465 465
             }
466 466
         }
467 467
 
468
-        if( ! $variable_prices || false === $price ) {
468
+        if (!$variable_prices || false === $price) {
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
-    if ( $remove_tax_from_inclusive && wpinv_prices_include_tax() ) {
475
-        $price -= wpinv_get_cart_item_tax( $item_id, $price, $options );
474
+    if ($remove_tax_from_inclusive && wpinv_prices_include_tax()) {
475
+        $price -= wpinv_get_cart_item_tax($item_id, $price, $options);
476 476
     }
477 477
 
478
-    return apply_filters( 'wpinv_cart_item_price', $price, $item_id, $cart_item, $options, $remove_tax_from_inclusive );
478
+    return apply_filters('wpinv_cart_item_price', $price, $item_id, $cart_item, $options, $remove_tax_from_inclusive);
479 479
 }
480 480
 
481
-function wpinv_get_cart_item_price_id( $item = array() ) {
482
-    if( isset( $item['item_number'] ) ) {
483
-        $price_id = isset( $item['item_number']['options']['price_id'] ) ? $item['item_number']['options']['price_id'] : null;
481
+function wpinv_get_cart_item_price_id($item = array()) {
482
+    if (isset($item['item_number'])) {
483
+        $price_id = isset($item['item_number']['options']['price_id']) ? $item['item_number']['options']['price_id'] : null;
484 484
     } else {
485
-        $price_id = isset( $item['options']['price_id'] ) ? $item['options']['price_id'] : null;
485
+        $price_id = isset($item['options']['price_id']) ? $item['options']['price_id'] : null;
486 486
     }
487 487
     return $price_id;
488 488
 }
489 489
 
490
-function wpinv_get_cart_item_price_name( $item = array() ) {
491
-    $price_id = (int)wpinv_get_cart_item_price_id( $item );
492
-    $prices   = wpinv_get_variable_prices( $item['id'] );
493
-    $name     = ! empty( $prices[ $price_id ] ) ? $prices[ $price_id ]['name'] : '';
494
-    return apply_filters( 'wpinv_get_cart_item_price_name', $name, $item['id'], $price_id, $item );
490
+function wpinv_get_cart_item_price_name($item = array()) {
491
+    $price_id = (int)wpinv_get_cart_item_price_id($item);
492
+    $prices   = wpinv_get_variable_prices($item['id']);
493
+    $name     = !empty($prices[$price_id]) ? $prices[$price_id]['name'] : '';
494
+    return apply_filters('wpinv_get_cart_item_price_name', $name, $item['id'], $price_id, $item);
495 495
 }
496 496
 
497
-function wpinv_get_cart_item_name( $item = array() ) {
498
-    $item_title = !empty( $item['name'] ) ? $item['name'] : get_the_title( $item['id'] );
497
+function wpinv_get_cart_item_name($item = array()) {
498
+    $item_title = !empty($item['name']) ? $item['name'] : get_the_title($item['id']);
499 499
 
500
-    if ( empty( $item_title ) ) {
500
+    if (empty($item_title)) {
501 501
         $item_title = $item['id'];
502 502
     }
503 503
 
@@ -507,23 +507,23 @@  discard block
 block discarded – undo
507 507
     }
508 508
     */
509 509
 
510
-    return apply_filters( 'wpinv_get_cart_item_name', $item_title, $item['id'], $item );
510
+    return apply_filters('wpinv_get_cart_item_name', $item_title, $item['id'], $item);
511 511
 }
512 512
 
513
-function wpinv_has_variable_prices( $item_id = 0 ) {
513
+function wpinv_has_variable_prices($item_id = 0) {
514 514
     return false;
515 515
 }
516 516
 
517
-function wpinv_get_item_position_in_cart( $item_id = 0, $options = array() ) {
517
+function wpinv_get_item_position_in_cart($item_id = 0, $options = array()) {
518 518
     $cart_items = wpinv_get_cart_contents();
519 519
 
520
-    if ( !is_array( $cart_items ) ) {
520
+    if (!is_array($cart_items)) {
521 521
         return false; // Empty cart
522 522
     } else {
523
-        foreach ( $cart_items as $position => $item ) {
524
-            if ( $item['id'] == $item_id ) {
525
-                if ( isset( $options['price_id'] ) && isset( $item['options']['price_id'] ) ) {
526
-                    if ( (int) $options['price_id'] == (int) $item['options']['price_id'] ) {
523
+        foreach ($cart_items as $position => $item) {
524
+            if ($item['id'] == $item_id) {
525
+                if (isset($options['price_id']) && isset($item['options']['price_id'])) {
526
+                    if ((int)$options['price_id'] == (int)$item['options']['price_id']) {
527 527
                         return $position;
528 528
                     }
529 529
                 } else {
@@ -536,80 +536,80 @@  discard block
 block discarded – undo
536 536
     return false; // Not found
537 537
 }
538 538
 
539
-function wpinv_get_cart_item_quantity( $item ) {
540
-    if ( wpinv_item_quantities_enabled() ) {
541
-        $quantity = !empty( $item['quantity'] ) && (int)$item['quantity'] > 0 ? absint( $item['quantity'] ) : 1;
539
+function wpinv_get_cart_item_quantity($item) {
540
+    if (wpinv_item_quantities_enabled()) {
541
+        $quantity = !empty($item['quantity']) && (int)$item['quantity'] > 0 ? absint($item['quantity']) : 1;
542 542
     } else {
543 543
         $quantity = 1;
544 544
     }
545 545
     
546
-    if ( $quantity < 1 ) {
546
+    if ($quantity < 1) {
547 547
         $quantity = 1;
548 548
     }
549 549
     
550
-    return apply_filters( 'wpinv_get_cart_item_quantity', $quantity, $item );
550
+    return apply_filters('wpinv_get_cart_item_quantity', $quantity, $item);
551 551
 }
552 552
 
553
-function wpinv_get_item_suffix( $item, $html = true ) {
554
-    if ( empty( $item ) ) {
553
+function wpinv_get_item_suffix($item, $html = true) {
554
+    if (empty($item)) {
555 555
         return NULL;
556 556
     }
557 557
     
558
-    if ( is_int( $item ) ) {
559
-        $item = new WPInv_Item( $item );
558
+    if (is_int($item)) {
559
+        $item = new WPInv_Item($item);
560 560
     }
561 561
     
562
-    if ( !( is_object( $item ) && is_a( $item, 'WPInv_Item' ) ) ) {
562
+    if (!(is_object($item) && is_a($item, 'WPInv_Item'))) {
563 563
         return NULL;
564 564
     }
565 565
     
566
-    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '';
566
+    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '';
567 567
     
568
-    if ( !$html && $suffix ) {
569
-        $suffix = strip_tags( $suffix );
568
+    if (!$html && $suffix) {
569
+        $suffix = strip_tags($suffix);
570 570
     }
571 571
     
572
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
572
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
573 573
 }
574 574
 
575
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
576
-    if ( empty( $item ) ) {
575
+function wpinv_remove_item($item = 0, $force_delete = false) {
576
+    if (empty($item)) {
577 577
         return NULL;
578 578
     }
579 579
     
580
-    if ( is_int( $item ) ) {
581
-        $item = new WPInv_Item( $item );
580
+    if (is_int($item)) {
581
+        $item = new WPInv_Item($item);
582 582
     }
583 583
     
584
-    if ( !( is_object( $item ) && is_a( $item, 'WPInv_Item' ) ) ) {
584
+    if (!(is_object($item) && is_a($item, 'WPInv_Item'))) {
585 585
         return NULL;
586 586
     }
587 587
     
588
-    do_action( 'wpinv_pre_delete_item', $item );
588
+    do_action('wpinv_pre_delete_item', $item);
589 589
 
590
-    wp_delete_post( $item->ID, $force_delete );
590
+    wp_delete_post($item->ID, $force_delete);
591 591
 
592
-    do_action( 'wpinv_post_delete_item', $item );
592
+    do_action('wpinv_post_delete_item', $item);
593 593
 }
594 594
 
595
-function wpinv_can_delete_item( $post_id ) {
596
-    $return = current_user_can( 'manage_options' ) ? true : false;
595
+function wpinv_can_delete_item($post_id) {
596
+    $return = current_user_can('manage_options') ? true : false;
597 597
     
598
-    if ( $return && wpinv_item_in_use( $post_id ) ) {
598
+    if ($return && wpinv_item_in_use($post_id)) {
599 599
         $return = false; // Don't delete item already use in invoices.
600 600
     }
601 601
     
602
-    return apply_filters( 'wpinv_can_delete_item', $return, $post_id );
602
+    return apply_filters('wpinv_can_delete_item', $return, $post_id);
603 603
 }
604 604
 
605 605
 function wpinv_admin_action_delete() {
606 606
     $screen = get_current_screen();
607 607
     
608
-    if ( !empty( $screen->post_type ) && $screen->post_type == 'wpi_item' && !empty( $_REQUEST['post'] ) && is_array( $_REQUEST['post'] ) ) {
608
+    if (!empty($screen->post_type) && $screen->post_type == 'wpi_item' && !empty($_REQUEST['post']) && is_array($_REQUEST['post'])) {
609 609
         $post_ids = array();
610 610
         
611
-        foreach ( $_REQUEST['post'] as $post_id ) {
612
-            if ( !wpinv_can_delete_item( $post_id ) ) {
611
+        foreach ($_REQUEST['post'] as $post_id) {
612
+            if (!wpinv_can_delete_item($post_id)) {
613 613
                 continue;
614 614
             }
615 615
             
@@ -619,86 +619,86 @@  discard block
 block discarded – undo
619 619
         $_REQUEST['post'] = $post_ids;
620 620
     }
621 621
 }
622
-add_action( 'admin_action_trash', 'wpinv_admin_action_delete', -10 );
623
-add_action( 'admin_action_delete', 'wpinv_admin_action_delete', -10 );
622
+add_action('admin_action_trash', 'wpinv_admin_action_delete', -10);
623
+add_action('admin_action_delete', 'wpinv_admin_action_delete', -10);
624 624
 
625
-function wpinv_check_delete_item( $check, $post, $force_delete ) {
626
-    if ( $post->post_type == 'wpi_item' ) {
627
-        if ( $force_delete && !wpinv_can_delete_item( $post->ID ) ) {
625
+function wpinv_check_delete_item($check, $post, $force_delete) {
626
+    if ($post->post_type == 'wpi_item') {
627
+        if ($force_delete && !wpinv_can_delete_item($post->ID)) {
628 628
             return true;
629 629
         }
630 630
     }
631 631
     
632 632
     return $check;
633 633
 }
634
-add_filter( 'pre_delete_post', 'wpinv_check_delete_item', 10, 3 );
634
+add_filter('pre_delete_post', 'wpinv_check_delete_item', 10, 3);
635 635
 
636
-function wpinv_item_in_use( $item_id ) {
636
+function wpinv_item_in_use($item_id) {
637 637
     global $wpdb, $wpi_items_in_use;
638 638
     
639
-    if ( !$item_id > 0 ) {
639
+    if (!$item_id > 0) {
640 640
         return false;
641 641
     }
642 642
     
643
-    if ( !empty( $wpi_items_in_use ) ) {
644
-        if ( isset( $wpi_items_in_use[$item_id] ) ) {
643
+    if (!empty($wpi_items_in_use)) {
644
+        if (isset($wpi_items_in_use[$item_id])) {
645 645
             return $wpi_items_in_use[$item_id];
646 646
         }
647 647
     } else {
648 648
         $wpi_items_in_use = array();
649 649
     }
650 650
     
651
-    $statuses   = array_keys( wpinv_get_invoice_statuses( true, true ) );
651
+    $statuses = array_keys(wpinv_get_invoice_statuses(true, true));
652 652
     
653
-    $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 )";
654
-    $in_use = $wpdb->get_var( $query ) > 0 ? true : false;
653
+    $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 )";
654
+    $in_use = $wpdb->get_var($query) > 0 ? true : false;
655 655
     
656 656
     $wpi_items_in_use[$item_id] = $in_use;
657 657
     
658 658
     return $in_use;
659 659
 }
660 660
 
661
-function wpinv_create_item( $args = array(), $wp_error = false, $force_update = false ) {
661
+function wpinv_create_item($args = array(), $wp_error = false, $force_update = false) {
662 662
     // Set some defaults
663 663
     $defaults = array(
664
-        'type'                 => 'custom',                                                // Optional. Item type. Default 'custom'.
665
-        'title'                => '',                                                      // Required. Item title.
666
-        'custom_id'            => 0,                                                       // Optional. Any integer or non numeric id. Must be unique within item type.
667
-        'price'                => '0.00',                                                  // Optional. Item price. Default '0.00'.
668
-        'status'               => 'pending',                                               // Optional. pending, publish
669
-        'custom_name'          => '',                                                      // Optional. Plural sub title for item.
670
-        'custom_singular_name' => '',                                                      // Optional. Singular sub title for item.
671
-        'vat_rule'             => 'digital',                                               // Optional. digital => Digital item, physical => Physical item
672
-        'editable'             => true,                                                    // Optional. Item editable from Items list page? Default true.
673
-        'excerpt'              => '',                                                      // Optional. Item short description
664
+        'type'                 => 'custom', // Optional. Item type. Default 'custom'.
665
+        'title'                => '', // Required. Item title.
666
+        'custom_id'            => 0, // Optional. Any integer or non numeric id. Must be unique within item type.
667
+        'price'                => '0.00', // Optional. Item price. Default '0.00'.
668
+        'status'               => 'pending', // Optional. pending, publish
669
+        'custom_name'          => '', // Optional. Plural sub title for item.
670
+        'custom_singular_name' => '', // Optional. Singular sub title for item.
671
+        'vat_rule'             => 'digital', // Optional. digital => Digital item, physical => Physical item
672
+        'editable'             => true, // Optional. Item editable from Items list page? Default true.
673
+        'excerpt'              => '', // Optional. Item short description
674 674
         /* Recurring item fields */
675
-        'is_recurring'         => 0,                                                       // Optional. 1 => Allow recurring or 0 => Don't allow recurring
676
-        'recurring_period'     => 'M',                                                     // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
677
-        'recurring_interval'   => 0,                                                       // Optional. Integer value between 1 - 90.
678
-        'recurring_limit'      => 0,                                                       // Optional. Any integer number. 0 for recurring forever until cancelled.
679
-        'free_trial'           => 0,                                                       // Optional. 1 => Allow free trial or 0 => Don't free trial
680
-        'trial_period'         => 'M',                                                     // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
681
-        'trial_interval'       => 0,                                                       // Optional. Any integer number.
675
+        'is_recurring'         => 0, // Optional. 1 => Allow recurring or 0 => Don't allow recurring
676
+        'recurring_period'     => 'M', // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
677
+        'recurring_interval'   => 0, // Optional. Integer value between 1 - 90.
678
+        'recurring_limit'      => 0, // Optional. Any integer number. 0 for recurring forever until cancelled.
679
+        'free_trial'           => 0, // Optional. 1 => Allow free trial or 0 => Don't free trial
680
+        'trial_period'         => 'M', // Optional. D => Daily, W => Weekly, M => Monthly, Y => Yearly
681
+        'trial_interval'       => 0, // Optional. Any integer number.
682 682
     );
683 683
 
684
-    $data = wp_parse_args( $args, $defaults );
684
+    $data = wp_parse_args($args, $defaults);
685 685
 
686
-    if ( empty( $data['type'] ) ) {
686
+    if (empty($data['type'])) {
687 687
         $data['type'] = 'custom';
688 688
     }
689 689
 
690
-    if ( !empty( $data['custom_id'] ) ) {
691
-        $item = wpinv_get_item_by( 'custom_id', $data['custom_id'], $data['type'] );
690
+    if (!empty($data['custom_id'])) {
691
+        $item = wpinv_get_item_by('custom_id', $data['custom_id'], $data['type']);
692 692
     } else {
693 693
         $item = NULL;
694 694
     }
695 695
 
696
-    if ( !empty( $item ) ) {
697
-        if ( $force_update ) {
698
-            if ( empty( $args['ID'] ) ) {
696
+    if (!empty($item)) {
697
+        if ($force_update) {
698
+            if (empty($args['ID'])) {
699 699
                 $args['ID'] = $item->ID;
700 700
             }
701
-            return wpinv_update_item( $args, $wp_error );
701
+            return wpinv_update_item($args, $wp_error);
702 702
         }
703 703
 
704 704
         return $item;
@@ -709,19 +709,19 @@  discard block
 block discarded – undo
709 709
     $meta['custom_id']              = $data['custom_id'];
710 710
     $meta['custom_singular_name']   = $data['custom_singular_name'];
711 711
     $meta['custom_name']            = $data['custom_name'];
712
-    $meta['price']                  = wpinv_round_amount( $data['price'] );
712
+    $meta['price']                  = wpinv_round_amount($data['price']);
713 713
     $meta['editable']               = (int)$data['editable'];
714 714
     $meta['vat_rule']               = $data['vat_rule'];
715 715
     $meta['vat_class']              = '_standard';
716 716
     
717
-    if ( !empty( $data['is_recurring'] ) ) {
717
+    if (!empty($data['is_recurring'])) {
718 718
         $meta['is_recurring']       = $data['is_recurring'];
719 719
         $meta['recurring_period']   = $data['recurring_period'];
720
-        $meta['recurring_interval'] = absint( $data['recurring_interval'] );
721
-        $meta['recurring_limit']    = absint( $data['recurring_limit'] );
720
+        $meta['recurring_interval'] = absint($data['recurring_interval']);
721
+        $meta['recurring_limit']    = absint($data['recurring_limit']);
722 722
         $meta['free_trial']         = $data['free_trial'];
723 723
         $meta['trial_period']       = $data['trial_period'];
724
-        $meta['trial_interval']     = absint( $data['trial_interval'] );
724
+        $meta['trial_interval']     = absint($data['trial_interval']);
725 725
     } else {
726 726
         $meta['is_recurring']       = 0;
727 727
         $meta['recurring_period']   = '';
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
         $meta['trial_interval']     = '';
733 733
     }
734 734
     
735
-    $post_data  = array( 
735
+    $post_data = array( 
736 736
         'post_title'    => $data['title'],
737 737
         'post_excerpt'  => $data['excerpt'],
738 738
         'post_status'   => $data['status'],
@@ -740,89 +740,89 @@  discard block
 block discarded – undo
740 740
     );
741 741
 
742 742
     $item = new WPInv_Item();
743
-    $return = $item->create( $post_data, $wp_error );
743
+    $return = $item->create($post_data, $wp_error);
744 744
 
745
-    if ( $return && !empty( $item ) && !is_wp_error( $return ) ) {
745
+    if ($return && !empty($item) && !is_wp_error($return)) {
746 746
         return $item;
747 747
     }
748 748
 
749
-    if ( $wp_error && is_wp_error( $return ) ) {
749
+    if ($wp_error && is_wp_error($return)) {
750 750
         return $return;
751 751
     }
752 752
     return 0;
753 753
 }
754 754
 
755
-function wpinv_update_item( $args = array(), $wp_error = false ) {
756
-    $item = !empty( $args['ID'] ) ? new WPInv_Item( $args['ID'] ) : NULL;
755
+function wpinv_update_item($args = array(), $wp_error = false) {
756
+    $item = !empty($args['ID']) ? new WPInv_Item($args['ID']) : NULL;
757 757
 
758
-    if ( empty( $item ) || !( !empty( $item->post_type ) && $item->post_type == 'wpi_item' ) ) {
759
-        if ( $wp_error ) {
760
-            return new WP_Error( 'wpinv_invalid_item', __( 'Invalid item.', 'invoicing' ) );
758
+    if (empty($item) || !(!empty($item->post_type) && $item->post_type == 'wpi_item')) {
759
+        if ($wp_error) {
760
+            return new WP_Error('wpinv_invalid_item', __('Invalid item.', 'invoicing'));
761 761
         }
762 762
         return 0;
763 763
     }
764 764
     
765
-    if ( !empty( $args['custom_id'] ) ) {
766
-        $item_exists = wpinv_get_item_by( 'custom_id', $args['custom_id'], ( !empty( $args['type'] ) ? $args['type'] : $item->type ) );
765
+    if (!empty($args['custom_id'])) {
766
+        $item_exists = wpinv_get_item_by('custom_id', $args['custom_id'], (!empty($args['type']) ? $args['type'] : $item->type));
767 767
         
768
-        if ( !empty( $item_exists ) && $item_exists->ID != $args['ID'] ) {
769
-            if ( $wp_error ) {
770
-                return new WP_Error( 'wpinv_invalid_custom_id', __( 'Item with custom id already exists.', 'invoicing' ) );
768
+        if (!empty($item_exists) && $item_exists->ID != $args['ID']) {
769
+            if ($wp_error) {
770
+                return new WP_Error('wpinv_invalid_custom_id', __('Item with custom id already exists.', 'invoicing'));
771 771
             }
772 772
             return 0;
773 773
         }
774 774
     }
775 775
 
776
-    $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' );
776
+    $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 777
 
778 778
     $post_data = array();
779
-    if ( isset( $args['title'] ) ) { 
779
+    if (isset($args['title'])) { 
780 780
         $post_data['post_title'] = $args['title'];
781 781
     }
782
-    if ( isset( $args['excerpt'] ) ) { 
782
+    if (isset($args['excerpt'])) { 
783 783
         $post_data['post_excerpt'] = $args['excerpt'];
784 784
     }
785
-    if ( isset( $args['status'] ) ) { 
785
+    if (isset($args['status'])) { 
786 786
         $post_data['post_status'] = $args['status'];
787 787
     }
788 788
     
789
-    foreach ( $meta_fields as $meta_field ) {
790
-        if ( isset( $args[ $meta_field ] ) ) { 
791
-            $value = $args[ $meta_field ];
789
+    foreach ($meta_fields as $meta_field) {
790
+        if (isset($args[$meta_field])) { 
791
+            $value = $args[$meta_field];
792 792
 
793
-            switch ( $meta_field ) {
793
+            switch ($meta_field) {
794 794
                 case 'price':
795
-                    $value = wpinv_round_amount( $value );
795
+                    $value = wpinv_round_amount($value);
796 796
                 break;
797 797
                 case 'recurring_interval':
798 798
                 case 'recurring_limit':
799 799
                 case 'trial_interval':
800
-                    $value = absint( $value );
800
+                    $value = absint($value);
801 801
                 break;
802 802
 				case 'editable':
803
-                    $value = (int) $value;
803
+                    $value = (int)$value;
804 804
                 break;
805 805
             }
806 806
 
807
-            $post_data['meta'][ $meta_field ] = $value;
807
+            $post_data['meta'][$meta_field] = $value;
808 808
         };
809 809
     }
810 810
 
811
-    if ( empty( $post_data ) ) {
812
-        if ( $wp_error ) {
813
-            return new WP_Error( 'wpinv_invalid_item_data', __( 'Invalid item data.', 'invoicing' ) );
811
+    if (empty($post_data)) {
812
+        if ($wp_error) {
813
+            return new WP_Error('wpinv_invalid_item_data', __('Invalid item data.', 'invoicing'));
814 814
         }
815 815
         return 0;
816 816
     }
817 817
     $post_data['ID'] = $args['ID'];
818 818
 
819
-    $return = $item->update( $post_data, $wp_error );
819
+    $return = $item->update($post_data, $wp_error);
820 820
 
821
-    if ( $return && !empty( $item ) && !is_wp_error( $return ) ) {
821
+    if ($return && !empty($item) && !is_wp_error($return)) {
822 822
         return $item;
823 823
     }
824 824
 
825
-    if ( $wp_error && is_wp_error( $return ) ) {
825
+    if ($wp_error && is_wp_error($return)) {
826 826
         return $return;
827 827
     }
828 828
     return 0;
Please login to merge, or discard this patch.