Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.67";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return string
21 21
 	 */
22
-	public static function name( $text, $multiple = false ) {
22
+	public static function name($text, $multiple = false) {
23 23
 		$output = '';
24 24
 
25
-		if ( $text ) {
26
-			$is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
-			$output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
25
+		if ($text) {
26
+			$is_multiple = strpos($text, '[') === false && $multiple ? '[]' : '';
27
+			$output      = ' name="' . esc_attr($text) . $is_multiple . '" ';
28 28
 		}
29 29
 
30 30
 		return $output;
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string The sanitized item.
39 39
 	 */
40
-	public static function id( $text ) {
40
+	public static function id($text) {
41 41
 		$output = '';
42 42
 
43
-		if ( $text ) {
44
-			$output = ' id="' . sanitize_html_class( $text ) . '" ';
43
+		if ($text) {
44
+			$output = ' id="' . sanitize_html_class($text) . '" ';
45 45
 		}
46 46
 
47 47
 		return $output;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string The sanitized item.
56 56
 	 */
57
-	public static function title( $text ) {
57
+	public static function title($text) {
58 58
 		$output = '';
59 59
 
60
-		if ( $text ) {
61
-			$output = ' title="' . esc_attr( $text ) . '" ';
60
+		if ($text) {
61
+			$output = ' title="' . esc_attr($text) . '" ';
62 62
 		}
63 63
 
64 64
 		return $output;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string The sanitized item.
73 73
 	 */
74
-	public static function value( $text ) {
74
+	public static function value($text) {
75 75
 		$output = '';
76 76
 
77
-		if ( $text !== null && $text !== false ) {
78
-			$output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
77
+		if ($text !== null && $text !== false) {
78
+			$output = ' value="' . esc_attr(wp_unslash($text)) . '" ';
79 79
 		}
80 80
 
81 81
 		return $output;
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string The sanitized item.
90 90
 	 */
91
-	public static function class_attr( $text ) {
91
+	public static function class_attr($text) {
92 92
 		$output = '';
93 93
 
94
-		if ( $text ) {
95
-			$classes = self::esc_classes( $text );
96
-			if ( ! empty( $classes ) ) {
94
+		if ($text) {
95
+			$classes = self::esc_classes($text);
96
+			if (!empty($classes)) {
97 97
 				$output = ' class="' . $classes . '" ';
98 98
 			}
99 99
 		}
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return string
110 110
 	 */
111
-	public static function esc_classes( $text ) {
111
+	public static function esc_classes($text) {
112 112
 		$output = '';
113 113
 
114
-		if ( $text ) {
115
-			$classes = explode( " ", $text );
116
-			$classes = array_map( "trim", $classes );
117
-			$classes = array_map( "sanitize_html_class", $classes );
118
-			if ( ! empty( $classes ) ) {
119
-				$output = implode( " ", $classes );
114
+		if ($text) {
115
+			$classes = explode(" ", $text);
116
+			$classes = array_map("trim", $classes);
117
+			$classes = array_map("sanitize_html_class", $classes);
118
+			if (!empty($classes)) {
119
+				$output = implode(" ", $classes);
120 120
 			}
121 121
 		}
122 122
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string
131 131
 	 */
132
-	public static function data_attributes( $args ) {
132
+	public static function data_attributes($args) {
133 133
 		$output = '';
134 134
 
135
-		if ( ! empty( $args ) ) {
135
+		if (!empty($args)) {
136 136
 
137
-			foreach ( $args as $key => $val ) {
138
-				if ( substr( $key, 0, 5 ) === "data-" ) {
139
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
137
+			foreach ($args as $key => $val) {
138
+				if (substr($key, 0, 5) === "data-") {
139
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
140 140
 				}
141 141
 			}
142 142
 		}
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string
151 151
 	 */
152
-	public static function aria_attributes( $args ) {
152
+	public static function aria_attributes($args) {
153 153
 		$output = '';
154 154
 
155
-		if ( ! empty( $args ) ) {
155
+		if (!empty($args)) {
156 156
 
157
-			foreach ( $args as $key => $val ) {
158
-				if ( substr( $key, 0, 5 ) === "aria-" ) {
159
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
157
+			foreach ($args as $key => $val) {
158
+				if (substr($key, 0, 5) === "aria-") {
159
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
160 160
 				}
161 161
 			}
162 162
 		}
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return string
175 175
 	 */
176
-	public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
176
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
177 177
 		$output = '';
178 178
 
179
-		if ( $class ) {
180
-			$classes = self::esc_classes( $class );
181
-			if ( ! empty( $classes ) ) {
179
+		if ($class) {
180
+			$classes = self::esc_classes($class);
181
+			if (!empty($classes)) {
182 182
 				$output = '<i class="' . $classes . '" ';
183 183
 				// extra attributes
184
-				if ( ! empty( $extra_attributes ) ) {
185
-					$output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
184
+				if (!empty($extra_attributes)) {
185
+					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186 186
 				}
187 187
 				$output .= '></i>';
188
-				if ( $space_after ) {
188
+				if ($space_after) {
189 189
 					$output .= " ";
190 190
 				}
191 191
 			}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return string
201 201
 	 */
202
-	public static function extra_attributes( $args ) {
202
+	public static function extra_attributes($args) {
203 203
 		$output = '';
204 204
 
205
-		if ( ! empty( $args ) ) {
205
+		if (!empty($args)) {
206 206
 
207
-			if ( is_array( $args ) ) {
208
-				foreach ( $args as $key => $val ) {
209
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
207
+			if (is_array($args)) {
208
+				foreach ($args as $key => $val) {
209
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
210 210
 				}
211 211
 			} else {
212 212
 				$output .= ' ' . $args . ' ';
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return string
224 224
 	 */
225
-	public static function help_text( $text ) {
225
+	public static function help_text($text) {
226 226
 		$output = '';
227 227
 
228
-		if ( $text ) {
229
-			$output .= '<small class="form-text text-muted">' . wp_kses_post( $text ) . '</small>';
228
+		if ($text) {
229
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
230 230
 		}
231 231
 
232 232
 
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return string|void
242 242
 	 */
243
-	public static function element_require( $input ) {
243
+	public static function element_require($input) {
244 244
 
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
245
+		$input = str_replace("'", '"', $input); // we only want double quotes
246 246
 
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
+		$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
248 248
 			"jQuery(form).find('[data-argument=\"",
249 249
 			"\"]').find('input,select,textarea').val()",
250 250
 			"\"]').find('input:checked').val()",
251
-		), $input ) );
251
+		), $input));
252 252
 
253
-		if ( $output ) {
253
+		if ($output) {
254 254
 			$output = ' data-element-require="' . $output . '" ';
255 255
 		}
256 256
 
@@ -267,21 +267,21 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return mixed Stripped value.
269 269
 	 */
270
-	public static function sanitize_html_field( $value, $input = array() ) {
270
+	public static function sanitize_html_field($value, $input = array()) {
271 271
 		$original = $value;
272 272
 
273
-		if ( is_array( $value ) ) {
274
-			foreach ( $value as $index => $item ) {
275
-				$value[ $index ] = self::_sanitize_html_field( $value, $input );
273
+		if (is_array($value)) {
274
+			foreach ($value as $index => $item) {
275
+				$value[$index] = self::_sanitize_html_field($value, $input);
276 276
 			}
277
-		} elseif ( is_object( $value ) ) {
278
-			$object_vars = get_object_vars( $value );
277
+		} elseif (is_object($value)) {
278
+			$object_vars = get_object_vars($value);
279 279
 
280
-			foreach ( $object_vars as $property_name => $property_value ) {
281
-				$value->$property_name = self::_sanitize_html_field( $property_value, $input );
280
+			foreach ($object_vars as $property_name => $property_value) {
281
+				$value->$property_name = self::_sanitize_html_field($property_value, $input);
282 282
 			}
283 283
 		} else {
284
-			$value = self::_sanitize_html_field( $value, $input );
284
+			$value = self::_sanitize_html_field($value, $input);
285 285
 		}
286 286
 
287 287
 		/**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		 * @param string|array $value Original content without filter.
294 294
 		 * @param array $input Input Field.
295 295
 		 */
296
-		return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
296
+		return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input);
297 297
 	}
298 298
 
299 299
 	/**
@@ -316,20 +316,20 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return string Filtered content with only allowed HTML elements.
318 318
 	 */
319
-	public static function _sanitize_html_field( $value, $input = array() ) {
320
-		if ( $value === '' ) {
319
+	public static function _sanitize_html_field($value, $input = array()) {
320
+		if ($value === '') {
321 321
 			return $value;
322 322
 		}
323 323
 
324
-		$allowed_html = self::kses_allowed_html( 'post', $input );
324
+		$allowed_html = self::kses_allowed_html('post', $input);
325 325
 
326
-		if ( ! is_array( $allowed_html ) ) {
327
-			$allowed_html = wp_kses_allowed_html( 'post' );
326
+		if (!is_array($allowed_html)) {
327
+			$allowed_html = wp_kses_allowed_html('post');
328 328
 		}
329 329
 
330
-		$filtered = trim( wp_unslash( $value ) );
331
-		$filtered = wp_kses( $filtered, $allowed_html );
332
-		$filtered = balanceTags( $filtered ); // Balances tags
330
+		$filtered = trim(wp_unslash($value));
331
+		$filtered = wp_kses($filtered, $allowed_html);
332
+		$filtered = balanceTags($filtered); // Balances tags
333 333
 
334 334
 		return $filtered;
335 335
 	}
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @return array Array of allowed HTML tags and their allowed attributes.
348 348
 	 */
349
-	public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
-		$allowed_html = wp_kses_allowed_html( $context );
349
+	public static function kses_allowed_html($context = 'post', $input = array()) {
350
+		$allowed_html = wp_kses_allowed_html($context);
351 351
 
352
-		if ( is_array( $allowed_html ) ) {
352
+		if (is_array($allowed_html)) {
353 353
 			// <iframe>
354
-			if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
354
+			if (!isset($allowed_html['iframe']) && $context == 'post') {
355 355
 				$allowed_html['iframe'] = array(
356 356
 					'class'           => true,
357 357
 					'id'              => true,
@@ -380,23 +380,23 @@  discard block
 block discarded – undo
380 380
 		 * @param @param string|array $context The context for which to retrieve tags.
381 381
 		 * @param array $input Input field.
382 382
 		 */
383
-		return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
383
+		return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input);
384 384
 	}
385 385
 
386
-	public static function get_column_class( $label_number = 2, $type = 'label' ) {
386
+	public static function get_column_class($label_number = 2, $type = 'label') {
387 387
 
388 388
 		$class = '';
389 389
 
390 390
 		// set default if empty
391
-		if( $label_number === '' ){
391
+		if ($label_number === '') {
392 392
 			$label_number = 2;
393 393
 		}
394 394
 
395
-		if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
-			if ( $type == 'label' ) {
397
-				$class = 'col-sm-' . absint( $label_number );
398
-			} elseif ( $type == 'input' ) {
399
-				$class = 'col-sm-' . ( 12 - absint( $label_number ) );
395
+		if ($label_number && $label_number < 12 && $label_number > 0) {
396
+			if ($type == 'label') {
397
+				$class = 'col-sm-' . absint($label_number);
398
+			} elseif ($type == 'input') {
399
+				$class = 'col-sm-' . (12 - absint($label_number));
400 400
 			}
401 401
 		}
402 402
 
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param string $str String to sanitize.
416 416
 	 * @return string Sanitized string.
417 417
 	 */
418
-	public static function sanitize_textarea_field( $str ) {
419
-		$filtered = self::_sanitize_text_fields( $str, true );
418
+	public static function sanitize_textarea_field($str) {
419
+		$filtered = self::_sanitize_text_fields($str, true);
420 420
 
421 421
 		/**
422 422
 		 * Filters a sanitized textarea field string.
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 		 * @param string $filtered The sanitized string.
427 427
 		 * @param string $str      The string prior to being sanitized.
428 428
 		 */
429
-		return apply_filters( 'sanitize_textarea_field', $filtered, $str );
429
+		return apply_filters('sanitize_textarea_field', $filtered, $str);
430 430
 	}
431 431
 
432 432
 	/**
@@ -439,40 +439,40 @@  discard block
 block discarded – undo
439 439
 	 * @param bool   $keep_newlines Optional. Whether to keep newlines. Default: false.
440 440
 	 * @return string Sanitized string.
441 441
 	 */
442
-	public static function _sanitize_text_fields( $str, $keep_newlines = false ) {
443
-		if ( is_object( $str ) || is_array( $str ) ) {
442
+	public static function _sanitize_text_fields($str, $keep_newlines = false) {
443
+		if (is_object($str) || is_array($str)) {
444 444
 			return '';
445 445
 		}
446 446
 
447 447
 		$str = (string) $str;
448 448
 
449
-		$filtered = wp_check_invalid_utf8( $str );
449
+		$filtered = wp_check_invalid_utf8($str);
450 450
 
451
-		if ( strpos( $filtered, '<' ) !== false ) {
452
-			$filtered = wp_pre_kses_less_than( $filtered );
451
+		if (strpos($filtered, '<') !== false) {
452
+			$filtered = wp_pre_kses_less_than($filtered);
453 453
 			// This will strip extra whitespace for us.
454
-			$filtered = wp_strip_all_tags( $filtered, false );
454
+			$filtered = wp_strip_all_tags($filtered, false);
455 455
 
456 456
 			// Use HTML entities in a special case to make sure no later
457 457
 			// newline stripping stage could lead to a functional tag.
458
-			$filtered = str_replace( "<\n", "&lt;\n", $filtered );
458
+			$filtered = str_replace("<\n", "&lt;\n", $filtered);
459 459
 		}
460 460
 
461
-		if ( ! $keep_newlines ) {
462
-			$filtered = preg_replace( '/[\r\n\t ]+/', ' ', $filtered );
461
+		if (!$keep_newlines) {
462
+			$filtered = preg_replace('/[\r\n\t ]+/', ' ', $filtered);
463 463
 		}
464
-		$filtered = trim( $filtered );
464
+		$filtered = trim($filtered);
465 465
 
466 466
 		$found = false;
467
-		while ( preg_match( '`[^%](%[a-f0-9]{2})`i', $filtered, $match ) ) {
468
-			$filtered = str_replace( $match[1], '', $filtered );
467
+		while (preg_match('`[^%](%[a-f0-9]{2})`i', $filtered, $match)) {
468
+			$filtered = str_replace($match[1], '', $filtered);
469 469
 			$found = true;
470 470
 		}
471
-		unset( $match );
471
+		unset($match);
472 472
 
473
-		if ( $found ) {
473
+		if ($found) {
474 474
 			// Strip out the whitespace that may now exist after removing the octets.
475
-			$filtered = trim( preg_replace( '` +`', ' ', $filtered ) );
475
+			$filtered = trim(preg_replace('` +`', ' ', $filtered));
476 476
 		}
477 477
 
478 478
 		return $filtered;
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input( $args = array() ) {
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'                     => 'text',
24 24
 			'name'                     => '',
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 * Parse incoming $args into an array and merge it with $defaults
65 65
 		 */
66
-		$args   = wp_parse_args( $args, $defaults );
66
+		$args   = wp_parse_args($args, $defaults);
67 67
 		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
68
+		if (!empty($args['type'])) {
69 69
 			// hidden label option needs to be empty
70 70
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71 71
 
72
-			$type = sanitize_html_class( $args['type'] );
72
+			$type = sanitize_html_class($args['type']);
73 73
 
74 74
 			$help_text   = '';
75 75
 			$label       = '';
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			);
84 84
 
85 85
 			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
86
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
87 87
 				$label_after         = true;
88 88
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89 89
 			}
90 90
 
91 91
 			// Some special sauce for files
92
-			if ( $type == 'file' ) {
92
+			if ($type == 'file') {
93 93
 				$label_after = true; // if type file we need the label after
94 94
 				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
95
+			} elseif ($type == 'checkbox') {
96 96
 				$label_after = true; // if type file we need the label after
97 97
 				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
98
+			} elseif ($type == 'datepicker' || $type == 'timepicker') {
99 99
 				$type = 'text';
100 100
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
101 101
 				$args['class'] .= ' bg-initial ';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				// enqueue the script
105 105
 				$aui_settings = AyeCode_UI_Settings::instance();
106 106
 				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
107
+			} elseif ($type == 'iconpicker') {
108 108
 				$type = 'text';
109 109
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 				$aui_settings->enqueue_iconpicker();
120 120
 			}
121 121
 
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
122
+			if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) {
123
+				$output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />';
124 124
 			}
125 125
 
126 126
 
@@ -128,88 +128,88 @@  discard block
 block discarded – undo
128 128
 			$output .= '<input type="' . $type . '" ';
129 129
 
130 130
 			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
131
+			if (!empty($args['name'])) {
132
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
133 133
 			}
134 134
 
135 135
 			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
136
+			if (!empty($args['id'])) {
137
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
138 138
 			}
139 139
 
140 140
 			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
141
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
142
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
143 143
 			}
144 144
 
145 145
 			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
146
+			if (!empty($args['title'])) {
147
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
148 148
 			}
149 149
 
150 150
 			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
151
+			if (!empty($args['value'])) {
152
+				$output .= AUI_Component_Helper::value($args['value']);
153 153
 			}
154 154
 
155 155
 			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
156
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
157 157
 				$output .= ' checked ';
158 158
 			}
159 159
 
160 160
 			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
161
+			if (!empty($args['validation_text'])) {
162
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
163 163
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164 164
 			}
165 165
 
166 166
 			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
167
+			if (!empty($args['validation_pattern'])) {
168
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
169 169
 			}
170 170
 
171 171
 			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
172
+			if (!empty($args['step'])) {
173 173
 				$output .= ' step="' . $args['step'] . '" ';
174 174
 			}
175 175
 
176 176
 			// required
177
-			if ( ! empty( $args['required'] ) ) {
177
+			if (!empty($args['required'])) {
178 178
 				$output .= ' required ';
179 179
 			}
180 180
 
181 181
 			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
182
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
183 183
 			$output .= ' class="form-control ' . $class . '" ';
184 184
 
185 185
 			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
186
+			$output .= AUI_Component_Helper::data_attributes($args);
187 187
 
188 188
 			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
189
+			if (!empty($args['extra_attributes'])) {
190
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
191 191
 			}
192 192
 
193 193
 			// close
194 194
 			$output .= ' >';
195 195
 
196 196
 			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
197
+			if (!empty($args['help_text'])) {
198
+				$help_text = AUI_Component_Helper::help_text($args['help_text']);
199 199
 			}
200 200
 
201 201
 			// label
202
-			if ( ! empty( $args['label'] ) ) {
202
+			if (!empty($args['label'])) {
203 203
 				$label_base_class = '';
204
-				if ( $type == 'file' ) {
204
+				if ($type == 'file') {
205 205
 					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
206
+				} elseif ($type == 'checkbox') {
207
+					if (!empty($args['label_force_left'])) {
208
+						$label_args['title'] = wp_kses_post($args['help_text']);
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else {
213 213
 
214 214
 					}
215 215
 
@@ -217,45 +217,45 @@  discard block
 block discarded – undo
217 217
 				}
218 218
 				$label_args['class'] .= $label_base_class;
219 219
 				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
220
+				if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; }
221
+				$label = self::label($temp_label_args, $type);
222 222
 			}
223 223
 
224 224
 
225 225
 
226 226
 
227 227
 			// set help text in the correct position
228
-			if ( $label_after ) {
228
+			if ($label_after) {
229 229
 				$output .= $label . $help_text;
230 230
 			}
231 231
 
232 232
 			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
233
+			if ($type == 'file') {
234
+				$output = self::wrap(array(
235 235
 					'content' => $output,
236 236
 					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
237
+				));
238
+			} elseif ($type == 'checkbox') {
239 239
 
240 240
 				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
241
+				$label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label');
242
+				$label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>';
243
+				$switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : '';
244
+				$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox';
245
+				if (!empty($args['label_force_left'])) {
246 246
 					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
247
+					$label = str_replace("custom-control-label", "", self::label($label_args, 'cb'));
248 248
 				}
249
-				$output     = self::wrap( array(
249
+				$output = self::wrap(array(
250 250
 					'content' => $output,
251 251
 					'class'   => 'custom-control ' . $wrap_class
252
-				) );
252
+				));
253 253
 
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
254
+				if ($args['label_type'] == 'horizontal') {
255
+					$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
256 256
 					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257 257
 				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
258
+			} elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
259 259
 
260 260
 
261 261
 				// allow password field to toggle view
@@ -269,62 +269,62 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 
271 271
 			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
272
+			if ($args['input_group_left'] || $args['input_group_right']) {
273
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
274
+				if ($args['input_group_left']) {
275
+					$output = self::wrap(array(
276 276
 						'content'                 => $output,
277 277
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278 278
 						'input_group_left'        => $args['input_group_left'],
279 279
 						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
280
+					));
281 281
 				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
282
+				if ($args['input_group_right']) {
283
+					$output = self::wrap(array(
284 284
 						'content'                  => $output,
285 285
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286 286
 						'input_group_right'        => $args['input_group_right'],
287 287
 						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
288
+					));
289 289
 				}
290 290
 
291 291
 			}
292 292
 
293
-			if ( ! $label_after ) {
293
+			if (!$label_after) {
294 294
 				$output .= $help_text;
295 295
 			}
296 296
 
297 297
 
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
298
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
299
+				$output = self::wrap(array(
300 300
 					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
301
+					'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
302
+				));
303 303
 			}
304 304
 
305
-			if ( ! $label_after ) {
305
+			if (!$label_after) {
306 306
 				$output = $label . $output;
307 307
 			}
308 308
 
309 309
 			// wrap
310
-			if ( ! $args['no_wrap'] ) {
310
+			if (!$args['no_wrap']) {
311 311
 				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312 312
 				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
313
+				$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+				$output           = self::wrap(array(
315 315
 					'content'         => $output,
316 316
 					'class'           => $wrap_class,
317 317
 					'element_require' => $args['element_require'],
318 318
 					'argument_id'     => $args['id'],
319 319
 					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
320
+				));
321 321
 			}
322 322
 		}
323 323
 
324 324
 		return $output;
325 325
 	}
326 326
 
327
-	public static function label( $args = array(), $type = '' ) {
327
+	public static function label($args = array(), $type = '') {
328 328
 		//<label for="exampleInputEmail1">Email address</label>
329 329
 		$defaults = array(
330 330
 			'title'      => 'div',
@@ -337,33 +337,33 @@  discard block
 block discarded – undo
337 337
 		/**
338 338
 		 * Parse incoming $args into an array and merge it with $defaults
339 339
 		 */
340
-		$args   = wp_parse_args( $args, $defaults );
340
+		$args   = wp_parse_args($args, $defaults);
341 341
 		$output = '';
342 342
 
343
-		if ( $args['title'] ) {
343
+		if ($args['title']) {
344 344
 
345 345
 			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
346
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
347 347
 				$class = $args['class'];
348 348
 			} else {
349 349
 				$class = 'sr-only ' . $args['class'];
350 350
 			}
351 351
 
352 352
 			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
353
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
354
+				$class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label';
355 355
 			}
356 356
 
357 357
 			// open
358 358
 			$output .= '<label ';
359 359
 
360 360
 			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
361
+			if (!empty($args['for'])) {
362
+				$output .= ' for="' . esc_attr($args['for']) . '" ';
363 363
 			}
364 364
 
365 365
 			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
366
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
367 367
 			$output .= ' class="' . $class . '" ';
368 368
 
369 369
 			// close
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 
372 372
 
373 373
 			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
374
+			if (!empty($args['title'])) {
375
+				$output .= wp_kses_post($args['title']);
376 376
 			}
377 377
 
378 378
 			// close wrap
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return string
394 394
 	 */
395
-	public static function wrap( $args = array() ) {
395
+	public static function wrap($args = array()) {
396 396
 		$defaults = array(
397 397
 			'type'                     => 'div',
398 398
 			'class'                    => 'form-group',
@@ -409,31 +409,31 @@  discard block
 block discarded – undo
409 409
 		/**
410 410
 		 * Parse incoming $args into an array and merge it with $defaults
411 411
 		 */
412
-		$args   = wp_parse_args( $args, $defaults );
412
+		$args   = wp_parse_args($args, $defaults);
413 413
 		$output = '';
414
-		if ( $args['type'] ) {
414
+		if ($args['type']) {
415 415
 
416 416
 			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
417
+			$output .= '<' . sanitize_html_class($args['type']);
418 418
 
419 419
 			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
420
+			if (!empty($args['element_require'])) {
421
+				$output .= AUI_Component_Helper::element_require($args['element_require']);
422 422
 				$args['class'] .= " aui-conditional-field";
423 423
 			}
424 424
 
425 425
 			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
426
+			if (!empty($args['argument_id'])) {
427
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
428 428
 			}
429 429
 
430 430
 			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
431
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
432 432
 			$output .= ' class="' . $class . '" ';
433 433
 
434 434
 			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
435
+			if (!empty($args['wrap_attributes'])) {
436
+				$output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']);
437 437
 			}
438 438
 
439 439
 			// close wrap
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
444
+			if (!empty($args['input_group_left'])) {
445
+				$position_class   = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
446
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447 447
 				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448 448
 			}
449 449
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			$output .= $args['content'];
452 452
 
453 453
 			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
454
+			if (!empty($args['input_group_right'])) {
455
+				$position_class    = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
456
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457 457
 				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458 458
 			}
459 459
 
460 460
 
461 461
 			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
462
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
463 463
 
464 464
 
465 465
 		} else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return string The rendered component.
478 478
 	 */
479
-	public static function textarea( $args = array() ) {
479
+	public static function textarea($args = array()) {
480 480
 		$defaults = array(
481 481
 			'name'               => '',
482 482
 			'class'              => '',
@@ -513,28 +513,28 @@  discard block
 block discarded – undo
513 513
 		/**
514 514
 		 * Parse incoming $args into an array and merge it with $defaults
515 515
 		 */
516
-		$args   = wp_parse_args( $args, $defaults );
516
+		$args   = wp_parse_args($args, $defaults);
517 517
 		$output = '';
518 518
 
519 519
 		// hidden label option needs to be empty
520 520
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
521 521
 
522 522
 		// floating labels don't work with wysiwyg so set it as top
523
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
523
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
524 524
 			$args['label_type'] = 'top';
525 525
 		}
526 526
 
527 527
 		$label_after = $args['label_after'];
528 528
 
529 529
 		// floating labels need label after
530
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
530
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
531 531
 			$label_after         = true;
532 532
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
533 533
 		}
534 534
 
535 535
 		// label
536
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
537
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
536
+		if (!empty($args['label']) && is_array($args['label'])) {
537
+		} elseif (!empty($args['label']) && !$label_after) {
538 538
 			$label_args = array(
539 539
 				'title'      => $args['label'],
540 540
 				'for'        => $args['id'],
@@ -542,34 +542,34 @@  discard block
 block discarded – undo
542 542
 				'label_type' => $args['label_type'],
543 543
 				'label_col'  => $args['label_col']
544 544
 			);
545
-			$output .= self::label( $label_args );
545
+			$output .= self::label($label_args);
546 546
 		}
547 547
 
548 548
 		// maybe horizontal label
549
-		if ( $args['label_type'] == 'horizontal' ) {
550
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
549
+		if ($args['label_type'] == 'horizontal') {
550
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
551 551
 			$output .= '<div class="' . $input_col . '">';
552 552
 		}
553 553
 
554
-		if ( ! empty( $args['wysiwyg'] ) ) {
554
+		if (!empty($args['wysiwyg'])) {
555 555
 			ob_start();
556 556
 			$content   = $args['value'];
557
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
557
+			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
558 558
 			$settings  = array(
559
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
559
+				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
560 560
 				'quicktags'     => false,
561 561
 				'media_buttons' => false,
562 562
 				'editor_class'  => 'form-control',
563
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
563
+				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
564 564
 				'teeny'         => true,
565 565
 			);
566 566
 
567 567
 			// maybe set settings if array
568
-			if ( is_array( $args['wysiwyg'] ) ) {
569
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
568
+			if (is_array($args['wysiwyg'])) {
569
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
570 570
 			}
571 571
 
572
-			wp_editor( $content, $editor_id, $settings );
572
+			wp_editor($content, $editor_id, $settings);
573 573
 			$output .= ob_get_clean();
574 574
 		} else {
575 575
 
@@ -577,65 +577,65 @@  discard block
 block discarded – undo
577 577
 			$output .= '<textarea ';
578 578
 
579 579
 			// name
580
-			if ( ! empty( $args['name'] ) ) {
581
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
580
+			if (!empty($args['name'])) {
581
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
582 582
 			}
583 583
 
584 584
 			// id
585
-			if ( ! empty( $args['id'] ) ) {
586
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
585
+			if (!empty($args['id'])) {
586
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
587 587
 			}
588 588
 
589 589
 			// placeholder
590
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
591
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
590
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
591
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
592 592
 			}
593 593
 
594 594
 			// title
595
-			if ( ! empty( $args['title'] ) ) {
596
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
595
+			if (!empty($args['title'])) {
596
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
597 597
 			}
598 598
 
599 599
 			// validation text
600
-			if ( ! empty( $args['validation_text'] ) ) {
601
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
600
+			if (!empty($args['validation_text'])) {
601
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
602 602
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
603 603
 			}
604 604
 
605 605
 			// validation_pattern
606
-			if ( ! empty( $args['validation_pattern'] ) ) {
607
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
606
+			if (!empty($args['validation_pattern'])) {
607
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
608 608
 			}
609 609
 
610 610
 			// required
611
-			if ( ! empty( $args['required'] ) ) {
611
+			if (!empty($args['required'])) {
612 612
 				$output .= ' required ';
613 613
 			}
614 614
 
615 615
 			// rows
616
-			if ( ! empty( $args['rows'] ) ) {
617
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
616
+			if (!empty($args['rows'])) {
617
+				$output .= ' rows="' . absint($args['rows']) . '" ';
618 618
 			}
619 619
 
620 620
 
621 621
 			// class
622
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
622
+			$class = !empty($args['class']) ? $args['class'] : '';
623 623
 			$output .= ' class="form-control ' . $class . '" ';
624 624
 
625 625
 			// extra attributes
626
-			if ( ! empty( $args['extra_attributes'] ) ) {
627
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
626
+			if (!empty($args['extra_attributes'])) {
627
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
628 628
 			}
629 629
 
630 630
 			// close tag
631 631
 			$output .= ' >';
632 632
 
633 633
 			// value
634
-			if ( ! empty( $args['value'] ) ) {
635
-				if ( ! empty( $args['allow_tags'] ) ) {
636
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
634
+			if (!empty($args['value'])) {
635
+				if (!empty($args['allow_tags'])) {
636
+					$output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML.
637 637
 				} else {
638
-					$output .= AUI_Component_Helper::sanitize_textarea_field( $args['value'] );
638
+					$output .= AUI_Component_Helper::sanitize_textarea_field($args['value']);
639 639
 				}
640 640
 			}
641 641
 
@@ -644,23 +644,23 @@  discard block
 block discarded – undo
644 644
 
645 645
 
646 646
 			// input group wraps
647
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
648
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
649
-				if ( $args['input_group_left'] ) {
650
-					$output = self::wrap( array(
647
+			if ($args['input_group_left'] || $args['input_group_right']) {
648
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
649
+				if ($args['input_group_left']) {
650
+					$output = self::wrap(array(
651 651
 						'content'                 => $output,
652 652
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
653 653
 						'input_group_left'        => $args['input_group_left'],
654 654
 						'input_group_left_inside' => $args['input_group_left_inside']
655
-					) );
655
+					));
656 656
 				}
657
-				if ( $args['input_group_right'] ) {
658
-					$output = self::wrap( array(
657
+				if ($args['input_group_right']) {
658
+					$output = self::wrap(array(
659 659
 						'content'                  => $output,
660 660
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
661 661
 						'input_group_right'        => $args['input_group_right'],
662 662
 						'input_group_right_inside' => $args['input_group_right_inside']
663
-					) );
663
+					));
664 664
 				}
665 665
 
666 666
 			}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 
669 669
 		}
670 670
 
671
-		if ( ! empty( $args['label'] ) && $label_after ) {
671
+		if (!empty($args['label']) && $label_after) {
672 672
 			$label_args = array(
673 673
 				'title'      => $args['label'],
674 674
 				'for'        => $args['id'],
@@ -676,32 +676,32 @@  discard block
 block discarded – undo
676 676
 				'label_type' => $args['label_type'],
677 677
 				'label_col'  => $args['label_col']
678 678
 			);
679
-			$output .= self::label( $label_args );
679
+			$output .= self::label($label_args);
680 680
 		}
681 681
 
682 682
 		// help text
683
-		if ( ! empty( $args['help_text'] ) ) {
684
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
683
+		if (!empty($args['help_text'])) {
684
+			$output .= AUI_Component_Helper::help_text($args['help_text']);
685 685
 		}
686 686
 
687 687
 		// maybe horizontal label
688
-		if ( $args['label_type'] == 'horizontal' ) {
688
+		if ($args['label_type'] == 'horizontal') {
689 689
 			$output .= '</div>';
690 690
 		}
691 691
 
692 692
 
693 693
 		// wrap
694
-		if ( ! $args['no_wrap'] ) {
694
+		if (!$args['no_wrap']) {
695 695
 			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
696 696
 			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
697
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
-			$output           = self::wrap( array(
697
+			$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
698
+			$output           = self::wrap(array(
699 699
 				'content'         => $output,
700 700
 				'class'           => $wrap_class,
701 701
 				'element_require' => $args['element_require'],
702 702
 				'argument_id'     => $args['id'],
703 703
 				'wrap_attributes' => $args['wrap_attributes'],
704
-			) );
704
+			));
705 705
 		}
706 706
 
707 707
 
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 	 *
716 716
 	 * @return string The rendered component.
717 717
 	 */
718
-	public static function select( $args = array() ) {
718
+	public static function select($args = array()) {
719 719
 		$defaults = array(
720 720
 			'class'            => '',
721 721
 			'wrap_class'       => '',
@@ -752,11 +752,11 @@  discard block
 block discarded – undo
752 752
 		/**
753 753
 		 * Parse incoming $args into an array and merge it with $defaults
754 754
 		 */
755
-		$args   = wp_parse_args( $args, $defaults );
755
+		$args   = wp_parse_args($args, $defaults);
756 756
 		$output = '';
757 757
 
758 758
 		// for now lets hide floating labels
759
-		if ( $args['label_type'] == 'floating' ) {
759
+		if ($args['label_type'] == 'floating') {
760 760
 			$args['label_type'] = 'hidden';
761 761
 		}
762 762
 
@@ -767,31 +767,31 @@  discard block
 block discarded – undo
767 767
 		$label_after = $args['label_after'];
768 768
 
769 769
 		// floating labels need label after
770
-		if ( $args['label_type'] == 'floating' ) {
770
+		if ($args['label_type'] == 'floating') {
771 771
 			$label_after         = true;
772 772
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
773 773
 		}
774 774
 
775 775
 		// Maybe setup select2
776 776
 		$is_select2 = false;
777
-		if ( ! empty( $args['select2'] ) ) {
777
+		if (!empty($args['select2'])) {
778 778
 			$args['class'] .= ' aui-select2';
779 779
 			$is_select2 = true;
780
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
780
+		} elseif (strpos($args['class'], 'aui-select2') !== false) {
781 781
 			$is_select2 = true;
782 782
 		}
783 783
 
784 784
 		// select2 tags
785
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
785
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
786 786
 			$args['data-tags']             = 'true';
787 787
 			$args['data-token-separators'] = "[',']";
788 788
 			$args['multiple']              = true;
789 789
 		}
790 790
 
791 791
 		// select2 placeholder
792
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
793
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
794
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
792
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
793
+			$args['data-placeholder'] = esc_attr($args['placeholder']);
794
+			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
795 795
 		}
796 796
 
797 797
 
@@ -803,61 +803,61 @@  discard block
 block discarded – undo
803 803
 //		}
804 804
 
805 805
 		// Set hidden input to save empty value for multiselect.
806
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
807
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
806
+		if (!empty($args['multiple']) && !empty($args['name'])) {
807
+			$output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>';
808 808
 		}
809 809
 
810 810
 		// open/type
811 811
 		$output .= '<select ';
812 812
 
813 813
 		// style
814
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
814
+		if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
815 815
 			$output .= " style='width:100%;' ";
816 816
 		}
817 817
 
818 818
 		// element require
819
-		if ( ! empty( $args['element_require'] ) ) {
820
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
819
+		if (!empty($args['element_require'])) {
820
+			$output .= AUI_Component_Helper::element_require($args['element_require']);
821 821
 			$args['class'] .= " aui-conditional-field";
822 822
 		}
823 823
 
824 824
 		// class
825
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
826
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
825
+		$class = !empty($args['class']) ? $args['class'] : '';
826
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
827 827
 
828 828
 		// name
829
-		if ( ! empty( $args['name'] ) ) {
830
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
829
+		if (!empty($args['name'])) {
830
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
831 831
 		}
832 832
 
833 833
 		// id
834
-		if ( ! empty( $args['id'] ) ) {
835
-			$output .= AUI_Component_Helper::id( $args['id'] );
834
+		if (!empty($args['id'])) {
835
+			$output .= AUI_Component_Helper::id($args['id']);
836 836
 		}
837 837
 
838 838
 		// title
839
-		if ( ! empty( $args['title'] ) ) {
840
-			$output .= AUI_Component_Helper::title( $args['title'] );
839
+		if (!empty($args['title'])) {
840
+			$output .= AUI_Component_Helper::title($args['title']);
841 841
 		}
842 842
 
843 843
 		// data-attributes
844
-		$output .= AUI_Component_Helper::data_attributes( $args );
844
+		$output .= AUI_Component_Helper::data_attributes($args);
845 845
 
846 846
 		// aria-attributes
847
-		$output .= AUI_Component_Helper::aria_attributes( $args );
847
+		$output .= AUI_Component_Helper::aria_attributes($args);
848 848
 
849 849
 		// extra attributes
850
-		if ( ! empty( $args['extra_attributes'] ) ) {
851
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
850
+		if (!empty($args['extra_attributes'])) {
851
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
852 852
 		}
853 853
 
854 854
 		// required
855
-		if ( ! empty( $args['required'] ) ) {
855
+		if (!empty($args['required'])) {
856 856
 			$output .= ' required ';
857 857
 		}
858 858
 
859 859
 		// multiple
860
-		if ( ! empty( $args['multiple'] ) ) {
860
+		if (!empty($args['multiple'])) {
861 861
 			$output .= ' multiple ';
862 862
 		}
863 863
 
@@ -865,50 +865,50 @@  discard block
 block discarded – undo
865 865
 		$output .= ' >';
866 866
 
867 867
 		// placeholder
868
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
869
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
870
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
868
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
869
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
870
+		} elseif ($is_select2 && !empty($args['placeholder'])) {
871 871
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
872 872
 		}
873 873
 
874 874
 		// Options
875
-		if ( ! empty( $args['options'] ) ) {
875
+		if (!empty($args['options'])) {
876 876
 
877
-			if ( ! is_array( $args['options'] ) ) {
877
+			if (!is_array($args['options'])) {
878 878
 				$output .= $args['options']; // not the preferred way but an option
879 879
 			} else {
880
-				foreach ( $args['options'] as $val => $name ) {
880
+				foreach ($args['options'] as $val => $name) {
881 881
 					$selected = '';
882
-					if ( is_array( $name ) ) {
883
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
884
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
882
+					if (is_array($name)) {
883
+						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
884
+							$option_label = isset($name['label']) ? $name['label'] : '';
885 885
 
886
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
886
+							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
887 887
 						} else {
888
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
889
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
890
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
891
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
892
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
893
-							} elseif ( ! empty( $args['value'] ) ) {
894
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
895
-							} elseif ( empty( $args['value'] ) && $args['value'] === $option_value ) {
896
-								$selected = selected( $option_value, $args['value'], false );
888
+							$option_label = isset($name['label']) ? $name['label'] : '';
889
+							$option_value = isset($name['value']) ? $name['value'] : '';
890
+							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : '';
891
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
892
+								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
893
+							} elseif (!empty($args['value'])) {
894
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
895
+							} elseif (empty($args['value']) && $args['value'] === $option_value) {
896
+								$selected = selected($option_value, $args['value'], false);
897 897
 							}
898 898
 
899
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
899
+							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>';
900 900
 						}
901 901
 					} else {
902
-						if ( ! empty( $args['value'] ) ) {
903
-							if ( is_array( $args['value'] ) ) {
904
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
905
-							} elseif ( ! empty( $args['value'] ) ) {
906
-								$selected = selected( $args['value'], $val, false );
902
+						if (!empty($args['value'])) {
903
+							if (is_array($args['value'])) {
904
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
905
+							} elseif (!empty($args['value'])) {
906
+								$selected = selected($args['value'], $val, false);
907 907
 							}
908
-						} elseif ( $args['value'] === $val ) {
909
-							$selected = selected( $args['value'], $val, false );
908
+						} elseif ($args['value'] === $val) {
909
+							$selected = selected($args['value'], $val, false);
910 910
 						}
911
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
911
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
912 912
 					}
913 913
 				}
914 914
 			}
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 		$label = '';
922 922
 		$help_text = '';
923 923
 		// label
924
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
925
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
924
+		if (!empty($args['label']) && is_array($args['label'])) {
925
+		} elseif (!empty($args['label']) && !$label_after) {
926 926
 			$label_args = array(
927 927
 				'title'      => $args['label'],
928 928
 				'for'        => $args['id'],
@@ -930,49 +930,49 @@  discard block
 block discarded – undo
930 930
 				'label_type' => $args['label_type'],
931 931
 				'label_col'  => $args['label_col']
932 932
 			);
933
-			$label = self::label( $label_args );
933
+			$label = self::label($label_args);
934 934
 		}
935 935
 
936 936
 		// help text
937
-		if ( ! empty( $args['help_text'] ) ) {
938
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
937
+		if (!empty($args['help_text'])) {
938
+			$help_text = AUI_Component_Helper::help_text($args['help_text']);
939 939
 		}
940 940
 
941 941
 		// input group wraps
942
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
943
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
944
-			if ( $args['input_group_left'] ) {
945
-				$output = self::wrap( array(
942
+		if ($args['input_group_left'] || $args['input_group_right']) {
943
+			$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
944
+			if ($args['input_group_left']) {
945
+				$output = self::wrap(array(
946 946
 					'content'                 => $output,
947 947
 					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
948 948
 					'input_group_left'        => $args['input_group_left'],
949 949
 					'input_group_left_inside' => $args['input_group_left_inside']
950
-				) );
950
+				));
951 951
 			}
952
-			if ( $args['input_group_right'] ) {
953
-				$output = self::wrap( array(
952
+			if ($args['input_group_right']) {
953
+				$output = self::wrap(array(
954 954
 					'content'                  => $output,
955 955
 					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
956 956
 					'input_group_right'        => $args['input_group_right'],
957 957
 					'input_group_right_inside' => $args['input_group_right_inside']
958
-				) );
958
+				));
959 959
 			}
960 960
 
961 961
 		}
962 962
 
963
-		if ( ! $label_after ) {
963
+		if (!$label_after) {
964 964
 			$output .= $help_text;
965 965
 		}
966 966
 
967 967
 
968
-		if ( $args['label_type'] == 'horizontal' ) {
969
-			$output = self::wrap( array(
968
+		if ($args['label_type'] == 'horizontal') {
969
+			$output = self::wrap(array(
970 970
 				'content' => $output,
971
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
972
-			) );
971
+				'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
972
+			));
973 973
 		}
974 974
 
975
-		if ( ! $label_after ) {
975
+		if (!$label_after) {
976 976
 			$output = $label . $output;
977 977
 		}
978 978
 
@@ -983,16 +983,16 @@  discard block
 block discarded – undo
983 983
 
984 984
 
985 985
 		// wrap
986
-		if ( ! $args['no_wrap'] ) {
986
+		if (!$args['no_wrap']) {
987 987
 			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
988
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
-			$output     = self::wrap( array(
988
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
989
+			$output     = self::wrap(array(
990 990
 				'content'         => $output,
991 991
 				'class'           => $wrap_class,
992 992
 				'element_require' => $args['element_require'],
993 993
 				'argument_id'     => $args['id'],
994 994
 				'wrap_attributes' => $args['wrap_attributes'],
995
-			) );
995
+			));
996 996
 		}
997 997
 
998 998
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 *
1007 1007
 	 * @return string The rendered component.
1008 1008
 	 */
1009
-	public static function radio( $args = array() ) {
1009
+	public static function radio($args = array()) {
1010 1010
 		$defaults = array(
1011 1011
 			'class'            => '',
1012 1012
 			'wrap_class'       => '',
@@ -1036,10 +1036,10 @@  discard block
 block discarded – undo
1036 1036
 		/**
1037 1037
 		 * Parse incoming $args into an array and merge it with $defaults
1038 1038
 		 */
1039
-		$args = wp_parse_args( $args, $defaults );
1039
+		$args = wp_parse_args($args, $defaults);
1040 1040
 
1041 1041
 		// for now lets use horizontal for floating
1042
-		if ( $args['label_type'] == 'floating' ) {
1042
+		if ($args['label_type'] == 'floating') {
1043 1043
 			$args['label_type'] = 'horizontal';
1044 1044
 		}
1045 1045
 
@@ -1054,47 +1054,47 @@  discard block
 block discarded – undo
1054 1054
 
1055 1055
 
1056 1056
 		// label before
1057
-		if ( ! empty( $args['label'] ) ) {
1058
-			$output .= self::label( $label_args, 'radio' );
1057
+		if (!empty($args['label'])) {
1058
+			$output .= self::label($label_args, 'radio');
1059 1059
 		}
1060 1060
 
1061 1061
 		// maybe horizontal label
1062
-		if ( $args['label_type'] == 'horizontal' ) {
1063
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1062
+		if ($args['label_type'] == 'horizontal') {
1063
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
1064 1064
 			$output .= '<div class="' . $input_col . '">';
1065 1065
 		}
1066 1066
 
1067
-		if ( ! empty( $args['options'] ) ) {
1067
+		if (!empty($args['options'])) {
1068 1068
 			$count = 0;
1069
-			foreach ( $args['options'] as $value => $label ) {
1069
+			foreach ($args['options'] as $value => $label) {
1070 1070
 				$option_args            = $args;
1071 1071
 				$option_args['value']   = $value;
1072 1072
 				$option_args['label']   = $label;
1073 1073
 				$option_args['checked'] = $value == $args['value'] ? true : false;
1074
-				$output .= self::radio_option( $option_args, $count );
1075
-				$count ++;
1074
+				$output .= self::radio_option($option_args, $count);
1075
+				$count++;
1076 1076
 			}
1077 1077
 		}
1078 1078
 
1079 1079
 		// help text
1080
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1080
+		$help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : '';
1081 1081
 		$output .= $help_text;
1082 1082
 
1083 1083
 		// maybe horizontal label
1084
-		if ( $args['label_type'] == 'horizontal' ) {
1084
+		if ($args['label_type'] == 'horizontal') {
1085 1085
 			$output .= '</div>';
1086 1086
 		}
1087 1087
 
1088 1088
 		// wrap
1089 1089
 		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1090
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
-		$output     = self::wrap( array(
1090
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1091
+		$output     = self::wrap(array(
1092 1092
 			'content'         => $output,
1093 1093
 			'class'           => $wrap_class,
1094 1094
 			'element_require' => $args['element_require'],
1095 1095
 			'argument_id'     => $args['id'],
1096 1096
 			'wrap_attributes' => $args['wrap_attributes'],
1097
-		) );
1097
+		));
1098 1098
 
1099 1099
 
1100 1100
 		return $output;
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @return string The rendered component.
1109 1109
 	 */
1110
-	public static function radio_option( $args = array(), $count = '' ) {
1110
+	public static function radio_option($args = array(), $count = '') {
1111 1111
 		$defaults = array(
1112 1112
 			'class'            => '',
1113 1113
 			'id'               => '',
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		/**
1126 1126
 		 * Parse incoming $args into an array and merge it with $defaults
1127 1127
 		 */
1128
-		$args = wp_parse_args( $args, $defaults );
1128
+		$args = wp_parse_args($args, $defaults);
1129 1129
 
1130 1130
 		$output = '';
1131 1131
 
@@ -1136,43 +1136,43 @@  discard block
 block discarded – undo
1136 1136
 		$output .= ' class="form-check-input" ';
1137 1137
 
1138 1138
 		// name
1139
-		if ( ! empty( $args['name'] ) ) {
1140
-			$output .= AUI_Component_Helper::name( $args['name'] );
1139
+		if (!empty($args['name'])) {
1140
+			$output .= AUI_Component_Helper::name($args['name']);
1141 1141
 		}
1142 1142
 
1143 1143
 		// id
1144
-		if ( ! empty( $args['id'] ) ) {
1145
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1144
+		if (!empty($args['id'])) {
1145
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
1146 1146
 		}
1147 1147
 
1148 1148
 		// title
1149
-		if ( ! empty( $args['title'] ) ) {
1150
-			$output .= AUI_Component_Helper::title( $args['title'] );
1149
+		if (!empty($args['title'])) {
1150
+			$output .= AUI_Component_Helper::title($args['title']);
1151 1151
 		}
1152 1152
 
1153 1153
 		// value
1154
-		if ( isset( $args['value'] ) ) {
1155
-			$output .= AUI_Component_Helper::value( $args['value'] );
1154
+		if (isset($args['value'])) {
1155
+			$output .= AUI_Component_Helper::value($args['value']);
1156 1156
 		}
1157 1157
 
1158 1158
 		// checked, for radio and checkboxes
1159
-		if ( $args['checked'] ) {
1159
+		if ($args['checked']) {
1160 1160
 			$output .= ' checked ';
1161 1161
 		}
1162 1162
 
1163 1163
 		// data-attributes
1164
-		$output .= AUI_Component_Helper::data_attributes( $args );
1164
+		$output .= AUI_Component_Helper::data_attributes($args);
1165 1165
 
1166 1166
 		// aria-attributes
1167
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1167
+		$output .= AUI_Component_Helper::aria_attributes($args);
1168 1168
 
1169 1169
 		// extra attributes
1170
-		if ( ! empty( $args['extra_attributes'] ) ) {
1171
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1170
+		if (!empty($args['extra_attributes'])) {
1171
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1172 1172
 		}
1173 1173
 
1174 1174
 		// required
1175
-		if ( ! empty( $args['required'] ) ) {
1175
+		if (!empty($args['required'])) {
1176 1176
 			$output .= ' required ';
1177 1177
 		}
1178 1178
 
@@ -1180,38 +1180,38 @@  discard block
 block discarded – undo
1180 1180
 		$output .= ' >';
1181 1181
 
1182 1182
 		// label
1183
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1184
-		} elseif ( ! empty( $args['label'] ) ) {
1185
-			$output .= self::label( array(
1183
+		if (!empty($args['label']) && is_array($args['label'])) {
1184
+		} elseif (!empty($args['label'])) {
1185
+			$output .= self::label(array(
1186 1186
 				'title' => $args['label'],
1187 1187
 				'for'   => $args['id'] . $count,
1188 1188
 				'class' => 'form-check-label'
1189
-			), 'radio' );
1189
+			), 'radio');
1190 1190
 		}
1191 1191
 
1192 1192
 		// wrap
1193
-		if ( ! $args['no_wrap'] ) {
1193
+		if (!$args['no_wrap']) {
1194 1194
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1195 1195
 
1196 1196
 			// Unique wrap class
1197 1197
 			$uniq_class = 'fwrap';
1198
-			if ( ! empty( $args['name'] ) ) {
1198
+			if (!empty($args['name'])) {
1199 1199
 				$uniq_class .= '-' . $args['name'];
1200
-			} else if ( ! empty( $args['id'] ) ) {
1200
+			} else if (!empty($args['id'])) {
1201 1201
 				$uniq_class .= '-' . $args['id'];
1202 1202
 			}
1203 1203
 
1204
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1204
+			if (isset($args['value']) || $args['value'] !== "") {
1205 1205
 				$uniq_class .= '-' . $args['value'];
1206 1206
 			} else {
1207 1207
 				$uniq_class .= '-' . $count;
1208 1208
 			}
1209
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1209
+			$wrap_class .= ' ' . sanitize_html_class($uniq_class);
1210 1210
 
1211
-			$output = self::wrap( array(
1211
+			$output = self::wrap(array(
1212 1212
 				'content' => $output,
1213 1213
 				'class'   => $wrap_class
1214
-			) );
1214
+			));
1215 1215
 		}
1216 1216
 
1217 1217
 		return $output;
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.6.4' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.6.4');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  * @since  2.0.8
53 53
  */
54 54
 function getpaid_deactivation_hook() {
55
-    update_option( 'wpinv_flush_permalinks', 1 );
55
+    update_option('wpinv_flush_permalinks', 1);
56 56
 }
57
-register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' );
57
+register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook');
58 58
 
59 59
 /**
60 60
  * @deprecated
@@ -64,4 +64,4 @@  discard block
 block discarded – undo
64 64
 }
65 65
 
66 66
 // Kickstart the plugin.
67
-add_action( 'plugins_loaded', 'getpaid', -100 );
67
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.
templates/payment-forms/embed.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 	// Is the request set up correctly?
4
-	if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
4
+	if (empty($_GET['form']) && empty($_GET['item'])) {
5 5
 		return aui()->alert(
6 6
 			array(
7 7
 				'type'    => 'warning',
8
-				'content' => __( 'No payment form or item selected', 'invoicing' ),
8
+				'content' => __('No payment form or item selected', 'invoicing'),
9 9
 			)
10 10
 		);
11
-		wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 );
11
+		wp_die(__('No payment form or item selected', 'invoicing'), 400);
12 12
 	}
13 13
 
14 14
 	// Payment form or button?
15
-	if ( ! empty( $_GET['form'] ) ) {
15
+	if (!empty($_GET['form'])) {
16 16
 
17 17
 		$shortcode = sprintf(
18 18
 			'[getpaid form=%s]',
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 		$shortcode = sprintf(
25 25
 			'[getpaid item=%s]',
26
-			esc_attr( urldecode( $_GET['item'] ) )
26
+			esc_attr(urldecode($_GET['item']))
27 27
 		);
28 28
 
29 29
 	}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 
36 36
 	<head>
37 37
 
38
-		<meta charset="<?php bloginfo( 'charset' ); ?>">
38
+		<meta charset="<?php bloginfo('charset'); ?>">
39 39
         <meta name="viewport" content="width=device-width, initial-scale=1.0" >
40 40
 
41 41
         <meta name="robots" content="noindex,nofollow">
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 			wp_print_styles();
49 49
 			wp_print_head_scripts();
50 50
 			wp_custom_css_cb();
51
-			wpinv_get_template( 'frontend-head.php' );
51
+			wpinv_get_template('frontend-head.php');
52 52
 		?>
53 53
 
54 54
 		<style type="text/css">
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 	<body class="body page-template-default page">
84 84
 		<div id="getpaid-form-embed" class="container my-5 page type-page status-publish hentry post post-content">
85 85
 			<?php
86
-				do_action( 'getpaid_payment_form_embed_top' );
87
-				echo do_shortcode( $shortcode );
88
-				do_action( 'getpaid_payment_form_embed_bottom' );
89
-				wpinv_get_template( 'frontend-footer.php' );
86
+				do_action('getpaid_payment_form_embed_top');
87
+				echo do_shortcode($shortcode);
88
+				do_action('getpaid_payment_form_embed_bottom');
89
+				wpinv_get_template('frontend-footer.php');
90 90
 			?>
91 91
 		</div>
92 92
 		<?php wp_footer(); ?>
Please login to merge, or discard this patch.
includes/error-functions.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Returns the errors as html
@@ -15,36 +15,36 @@  discard block
 block discarded – undo
15 15
  * @param bool $wrap whether or not to wrap the errors.
16 16
  * @since  1.0.19
17 17
  */
18
-function getpaid_get_errors_html( $clear = true, $wrap = true ) {
18
+function getpaid_get_errors_html($clear = true, $wrap = true) {
19 19
 
20 20
     $errors = '';
21
-    foreach ( wpinv_get_errors() as $id => $error ) {
22
-        $type     = 'error';
21
+    foreach (wpinv_get_errors() as $id => $error) {
22
+        $type = 'error';
23 23
 
24
-        if ( is_array( $error ) ) {
24
+        if (is_array($error)) {
25 25
             $type  = $error['type'];
26 26
             $error = $error['text'];
27 27
         }
28 28
 
29
-        if ( $wrap ) {
29
+        if ($wrap) {
30 30
 
31 31
             $errors .= aui()->alert(
32 32
                 array(
33
-                    'content'     => wp_kses_post( $error ),
33
+                    'content'     => wp_kses_post($error),
34 34
                     'type'        => $type,
35 35
                 )
36 36
             );
37 37
 
38 38
         } else {
39 39
 
40
-            $id      = esc_attr( $id );
41
-            $error   = wp_kses_post( $error );
40
+            $id      = esc_attr($id);
41
+            $error   = wp_kses_post($error);
42 42
             $errors .= "<div data-code='$id'>$error</div>";
43 43
         }
44 44
 
45 45
     }
46 46
 
47
-    if ( $clear ){
47
+    if ($clear) {
48 48
         wpinv_clear_errors();
49 49
     }
50 50
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
  * Prints (then clears) all available errors.
57 57
  */
58 58
 function wpinv_print_errors() {
59
-    echo wp_kses_post( getpaid_get_errors_html() );
59
+    echo wp_kses_post(getpaid_get_errors_html());
60 60
 }
61 61
 
62 62
 /**
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
  * @return array
66 66
  */
67 67
 function wpinv_get_errors() {
68
-    $errors = getpaid_session()->get( 'wpinv_errors' );
69
-    return is_array( $errors ) ? $errors : array();
68
+    $errors = getpaid_session()->get('wpinv_errors');
69
+    return is_array($errors) ? $errors : array();
70 70
 }
71 71
 
72 72
 /**
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
  * @param string $error_message The error message.
77 77
  * @param string $type Either error, info, warning, primary, dark, light or success.
78 78
  */
79
-function wpinv_set_error( $error_id, $error_message, $type = 'error' ) {
79
+function wpinv_set_error($error_id, $error_message, $type = 'error') {
80 80
 
81 81
     $errors              = wpinv_get_errors();
82
-    $errors[ $error_id ] = array(
82
+    $errors[$error_id] = array(
83 83
         'type' =>  $type,
84 84
         'text' =>  $error_message,
85 85
     );
86 86
 
87
-    getpaid_session()->set( 'wpinv_errors', $errors );
87
+    getpaid_session()->set('wpinv_errors', $errors);
88 88
 }
89 89
 
90 90
 /**
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
  * 
93 93
  */
94 94
 function wpinv_has_errors() {
95
-    return count( wpinv_get_errors() ) > 0;
95
+    return count(wpinv_get_errors()) > 0;
96 96
 }
97 97
 
98 98
 /**
@@ -100,21 +100,21 @@  discard block
 block discarded – undo
100 100
  * 
101 101
  */
102 102
 function wpinv_clear_errors() {
103
-    getpaid_session()->set( 'wpinv_errors', null );
103
+    getpaid_session()->set('wpinv_errors', null);
104 104
 }
105 105
 
106 106
 /**
107 107
  * Clears a single error.
108 108
  * 
109 109
  */
110
-function wpinv_unset_error( $error_id ) {
110
+function wpinv_unset_error($error_id) {
111 111
     $errors = wpinv_get_errors();
112 112
 
113
-    if ( isset( $errors[ $error_id ] ) ) {
114
-        unset( $errors[ $error_id ] );
113
+    if (isset($errors[$error_id])) {
114
+        unset($errors[$error_id]);
115 115
     }
116 116
 
117
-    getpaid_session()->set( 'wpinv_errors', $errors );
117
+    getpaid_session()->set('wpinv_errors', $errors);
118 118
 }
119 119
 
120 120
 /**
@@ -125,15 +125,15 @@  discard block
 block discarded – undo
125 125
  * @param string $message Message to log.
126 126
  * @param string $version Version the message was added in.
127 127
  */
128
-function getpaid_doing_it_wrong( $function, $message, $version ) {
128
+function getpaid_doing_it_wrong($function, $message, $version) {
129 129
 
130 130
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
131 131
 
132
-	if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) {
133
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
134
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
132
+	if (wp_doing_ajax() || defined('REST_REQUEST')) {
133
+		do_action('doing_it_wrong_run', $function, $message, $version);
134
+		error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
135 135
 	} else {
136
-		_doing_it_wrong( $function, $message, $version );
136
+		_doing_it_wrong($function, $message, $version);
137 137
 	}
138 138
 
139 139
 }
@@ -147,42 +147,42 @@  discard block
 block discarded – undo
147 147
  * @param string $line The line that contains the error.
148 148
  * @param bool $exit Whether or not to exit function execution.
149 149
  */
150
-function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) {
150
+function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) {
151 151
     
152
-    if ( true === apply_filters( 'wpinv_log_errors', true ) ) {
152
+    if (true === apply_filters('wpinv_log_errors', true)) {
153 153
 
154 154
         // Ensure the log is a scalar.
155
-        if ( ! is_scalar( $log ) ) {
156
-            $log = print_r( $log, true );
155
+        if (!is_scalar($log)) {
156
+            $log = print_r($log, true);
157 157
         }
158 158
 
159 159
         // Add title.
160
-        if ( ! empty( $title ) ) {
161
-            $log  = $title . ' ' . trim( $log );
160
+        if (!empty($title)) {
161
+            $log = $title . ' ' . trim($log);
162 162
         }
163 163
 
164 164
         // Add the file to the label.
165
-        if ( ! empty( $file ) ) {
165
+        if (!empty($file)) {
166 166
             $log .= ' in ' . $file;
167 167
         }
168 168
 
169 169
         // Add the line number to the label.
170
-        if ( ! empty( $line ) ) {
170
+        if (!empty($line)) {
171 171
             $log .= ' on line ' . $line;
172 172
         }
173 173
 
174 174
         // Log the message.
175
-        error_log( trim ( $log ) );
175
+        error_log(trim($log));
176 176
 
177 177
         // ... and a backtrace.
178
-        if ( false !== $title && false !== $file ) {
179
-            error_log( 'Backtrace ' . wp_debug_backtrace_summary() );
178
+        if (false !== $title && false !== $file) {
179
+            error_log('Backtrace ' . wp_debug_backtrace_summary());
180 180
         }
181 181
 
182 182
     }
183 183
 
184 184
     // Maybe exit.
185
-    if ( $exit ) {
185
+    if ($exit) {
186 186
         exit;
187 187
     }
188 188
 
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 1 patch
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
     
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) { 
60
+function wpinv_country_name($country_code = '') { 
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
     
77
-    if ( !empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
         
80
-        $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 
117 117
         }
@@ -130,22 +130,22 @@  discard block
 block discarded – undo
130 130
     $address_fields = apply_filters(
131 131
         'getpaid_user_address_fields',
132 132
         array(
133
-            'first_name' => __( 'First Name', 'invoicing' ),
134
-            'last_name'  => __( 'Last Name', 'invoicing' ),
135
-            'address'    => __( 'Address', 'invoicing' ),
136
-            'city'       => __( 'City', 'invoicing' ),
137
-            'country'    => __( 'Country', 'invoicing' ),
138
-            'state'      => __( 'State', 'invoicing' ),
139
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
140
-            'phone'      => __( 'Phone Number', 'invoicing' ),
141
-            'company'    => __( 'Company', 'invoicing' ),
142
-            'company_id'    => __( 'Company ID', 'invoicing' ),
143
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
133
+            'first_name' => __('First Name', 'invoicing'),
134
+            'last_name'  => __('Last Name', 'invoicing'),
135
+            'address'    => __('Address', 'invoicing'),
136
+            'city'       => __('City', 'invoicing'),
137
+            'country'    => __('Country', 'invoicing'),
138
+            'state'      => __('State', 'invoicing'),
139
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
140
+            'phone'      => __('Phone Number', 'invoicing'),
141
+            'company'    => __('Company', 'invoicing'),
142
+            'company_id'    => __('Company ID', 'invoicing'),
143
+            'vat_number' => __('VAT Number', 'invoicing'),
144 144
         )
145 145
     );
146 146
 
147
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) {
148
-        unset( $address_fields['vat_number'] );
147
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) {
148
+        unset($address_fields['vat_number']);
149 149
     }
150 150
 
151 151
     return $address_fields;
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
  * 
157 157
  * @return bool
158 158
  */
159
-function getpaid_is_address_field_whitelisted( $key ) {
160
-    return array_key_exists( $key, getpaid_user_address_fields() );
159
+function getpaid_is_address_field_whitelisted($key) {
160
+    return array_key_exists($key, getpaid_user_address_fields());
161 161
 }
162 162
 
163 163
 /**
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
  *
168 168
  * @param WPInv_Invoice $invoice
169 169
  */
170
-function getpaid_save_invoice_user_address( $invoice ) {
170
+function getpaid_save_invoice_user_address($invoice) {
171 171
 
172 172
     // Retrieve the invoice.
173
-    $invoice = wpinv_get_invoice( $invoice );
173
+    $invoice = wpinv_get_invoice($invoice);
174 174
 
175 175
     // Abort if it does not exist.
176
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
176
+    if (empty($invoice) || $invoice->is_renewal()) {
177 177
         return;
178 178
     }
179 179
 
180
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
180
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
181 181
 
182
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
183
-            $value = call_user_func( array( $invoice, "get_$field" ) );
182
+        if (is_callable(array($invoice, "get_$field"))) {
183
+            $value = call_user_func(array($invoice, "get_$field"));
184 184
 
185 185
             // Only save if it is not empty.
186
-            if ( ! empty( $value ) ) {
187
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
186
+            if (!empty($value)) {
187
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
188 188
             }
189 189
 
190 190
         }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     }
193 193
 
194 194
 }
195
-add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' );
195
+add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address');
196 196
 
197 197
 /**
198 198
  * Retrieves a saved user address.
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
  * @param bool $with_default Whether or not we should use the default country and state.
202 202
  * @return array
203 203
  */
204
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
204
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
205 205
 
206 206
     // Prepare the user id.
207
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
208
-    $user_info = get_userdata( $user_id );
207
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
208
+    $user_info = get_userdata($user_id);
209 209
 
210 210
     // Abort if non exists.
211
-    if ( empty( $user_info ) ) {
211
+    if (empty($user_info)) {
212 212
         return array();
213 213
     }
214 214
 
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
         'email'   => $user_info->user_email,
219 219
     );
220 220
 
221
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
222
-        $address[$field] = getpaid_get_user_address_field( $user_id, $field );
221
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
222
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
223 223
     }
224 224
 
225
-    $address = array_filter( $address );
225
+    $address = array_filter($address);
226 226
 
227
-    if ( ! $with_default ) {
227
+    if (!$with_default) {
228 228
         return $address;
229 229
     }
230 230
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
         'country'    => wpinv_get_default_country(),
236 236
     );
237 237
 
238
-    return getpaid_array_merge_if_empty( $address, $defaults );
238
+    return getpaid_array_merge_if_empty($address, $defaults);
239 239
 
240 240
 }
241 241
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @param string $field The field to use.
247 247
  * @return string|null
248 248
  */
249
-function getpaid_get_user_address_field( $user_id, $field ) {
249
+function getpaid_get_user_address_field($user_id, $field) {
250 250
 
251 251
     $prefixes = array(
252 252
         '_wpinv_',
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
         ''
255 255
     );
256 256
 
257
-    foreach ( $prefixes as $prefix ) {
257
+    foreach ($prefixes as $prefix) {
258 258
 
259 259
         // Meta table.
260
-        $value = get_user_meta( $user_id, $prefix . $field, true );
260
+        $value = get_user_meta($user_id, $prefix . $field, true);
261 261
         
262 262
         // UWP table.
263
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
263
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
264 264
 
265
-        if ( ! empty( $value ) ) {
265
+        if (!empty($value)) {
266 266
             return $value;
267 267
         }
268 268
 
@@ -279,16 +279,16 @@  discard block
 block discarded – undo
279 279
  * @param string $return What to return.
280 280
  * @return array
281 281
  */
282
-function wpinv_get_continents( $return = 'all' ) {
282
+function wpinv_get_continents($return = 'all') {
283 283
 
284
-    $continents = wpinv_get_data( 'continents' );
284
+    $continents = wpinv_get_data('continents');
285 285
 
286
-    switch( $return ) {
286
+    switch ($return) {
287 287
         case 'name' :
288
-            return wp_list_pluck( $continents, 'name' );
288
+            return wp_list_pluck($continents, 'name');
289 289
             break;
290 290
         case 'countries' :
291
-            return wp_list_pluck( $continents, 'countries' );
291
+            return wp_list_pluck($continents, 'countries');
292 292
             break;
293 293
         default :
294 294
             return $continents;
@@ -304,12 +304,12 @@  discard block
 block discarded – undo
304 304
  * @param string $country Country code. If no code is specified, defaults to the default country.
305 305
  * @return string
306 306
  */
307
-function wpinv_get_continent_code_for_country( $country = false ) {
307
+function wpinv_get_continent_code_for_country($country = false) {
308 308
 
309
-    $country = wpinv_sanitize_country( $country );
309
+    $country = wpinv_sanitize_country($country);
310 310
     
311
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
312
-		if ( false !== array_search( $country, $countries, true ) ) {
311
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
312
+		if (false !== array_search($country, $countries, true)) {
313 313
 			return $continent_code;
314 314
 		}
315 315
 	}
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
  * @param string $country Country code. If no code is specified, defaults to the default country.
326 326
  * @return array
327 327
  */
328
-function wpinv_get_country_calling_code( $country = null) {
328
+function wpinv_get_country_calling_code($country = null) {
329 329
 
330
-    $country = wpinv_sanitize_country( $country );
331
-    $codes   = wpinv_get_data( 'phone-codes' );
332
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
330
+    $country = wpinv_sanitize_country($country);
331
+    $codes   = wpinv_get_data('phone-codes');
332
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
333 333
 
334
-    if ( is_array( $code ) ) {
334
+    if (is_array($code)) {
335 335
         return $code[0];
336 336
     }
337 337
     return $code;
@@ -344,8 +344,8 @@  discard block
 block discarded – undo
344 344
  * @param bool $first_empty Whether or not the first item in the list should be empty
345 345
  * @return array
346 346
  */
347
-function wpinv_get_country_list( $first_empty = false ) {
348
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
347
+function wpinv_get_country_list($first_empty = false) {
348
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
349 349
 }
350 350
 
351 351
 /**
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
  * @param bool $first_empty Whether or not the first item in the list should be empty
356 356
  * @return array
357 357
  */
358
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
358
+function wpinv_get_country_states($country = null, $first_empty = false) {
359 359
     
360 360
     // Prepare the country.
361
-    $country = wpinv_sanitize_country( $country );
361
+    $country = wpinv_sanitize_country($country);
362 362
 
363 363
     // Fetch all states.
364
-    $all_states = wpinv_get_data( 'states' );
364
+    $all_states = wpinv_get_data('states');
365 365
 
366 366
     // Fetch the specified country's states.
367
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ;
368
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
369
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
367
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
368
+    $states     = apply_filters("wpinv_{$country}_states", $states);
369
+    $states     = apply_filters('wpinv_country_states', $states, $country);
370 370
 
371
-    asort( $states );
371
+    asort($states);
372 372
      
373
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
373
+    return wpinv_maybe_add_empty_option($states, $first_empty);
374 374
 }
375 375
 
376 376
 /**
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
  * @return array
381 381
  */
382 382
 function wpinv_get_us_states_list() {
383
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
383
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
384 384
 }
385 385
 
386 386
 /**
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
  * @return array
391 391
  */
392 392
 function wpinv_get_canada_states_list() {
393
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
393
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
394 394
 }
395 395
 
396 396
 /**
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
  * @return array
401 401
  */
402 402
 function wpinv_get_australia_states_list() {
403
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
403
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
404 404
 }
405 405
 
406 406
 /**
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
  * @return array
411 411
  */
412 412
 function wpinv_get_bangladesh_states_list() {
413
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
413
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
414 414
 }
415 415
 
416 416
 /**
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
  * @return array
421 421
  */
422 422
 function wpinv_get_brazil_states_list() {
423
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
423
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
424 424
 }
425 425
 
426 426
 /**
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
  * @return array
431 431
  */
432 432
 function wpinv_get_bulgaria_states_list() {
433
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
433
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
434 434
 }
435 435
 
436 436
 /**
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
  * @return array
441 441
  */
442 442
 function wpinv_get_hong_kong_states_list() {
443
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
443
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
444 444
 }
445 445
 
446 446
 /**
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
  * @return array
451 451
  */
452 452
 function wpinv_get_hungary_states_list() {
453
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
453
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
454 454
 }
455 455
 
456 456
 /**
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
  * @return array
461 461
  */
462 462
 function wpinv_get_japan_states_list() {
463
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
463
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
464 464
 }
465 465
 
466 466
 /**
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
  * @return array
471 471
  */
472 472
 function wpinv_get_china_states_list() {
473
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
473
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
474 474
 }
475 475
 
476 476
 /**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
  * @return array
481 481
  */
482 482
 function wpinv_get_new_zealand_states_list() {
483
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
483
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
484 484
 }
485 485
 
486 486
 /**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
  * @return array
491 491
  */
492 492
 function wpinv_get_peru_states_list() {
493
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
493
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
494 494
 }
495 495
 
496 496
 /**
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
  * @return array
501 501
  */
502 502
 function wpinv_get_indonesia_states_list() {
503
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
503
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
504 504
 }
505 505
 
506 506
 /**
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
  * @return array
511 511
  */
512 512
 function wpinv_get_india_states_list() {
513
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
513
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
514 514
 }
515 515
 
516 516
 /**
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
  * @return array
521 521
  */
522 522
 function wpinv_get_iran_states_list() {
523
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
523
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
524 524
 }
525 525
 
526 526
 /**
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
  * @return array
531 531
  */
532 532
 function wpinv_get_italy_states_list() {
533
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
533
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
534 534
 }
535 535
 
536 536
 /**
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
  * @return array
541 541
  */
542 542
 function wpinv_get_malaysia_states_list() {
543
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
543
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
544 544
 }
545 545
 
546 546
 /**
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
  * @return array
551 551
  */
552 552
 function wpinv_get_mexico_states_list() {
553
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
553
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
554 554
 }
555 555
 
556 556
 /**
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
  * @return array
561 561
  */
562 562
 function wpinv_get_nepal_states_list() {
563
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
563
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
564 564
 }
565 565
 
566 566
 /**
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
  * @return array
571 571
  */
572 572
 function wpinv_get_south_africa_states_list() {
573
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
573
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
574 574
 }
575 575
 
576 576
 /**
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
  * @return array
581 581
  */
582 582
 function wpinv_get_thailand_states_list() {
583
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
583
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
584 584
 }
585 585
 
586 586
 /**
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
  * @return array
591 591
  */
592 592
 function wpinv_get_turkey_states_list() {
593
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
593
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
594 594
 }
595 595
 
596 596
 /**
@@ -600,31 +600,31 @@  discard block
 block discarded – undo
600 600
  * @return array
601 601
  */
602 602
 function wpinv_get_spain_states_list() {
603
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
603
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
604 604
 }
605 605
 
606 606
 function wpinv_get_states_field() {
607
-	if( empty( $_POST['country'] ) ) {
607
+	if (empty($_POST['country'])) {
608 608
 		$_POST['country'] = wpinv_get_default_country();
609 609
 	}
610
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
610
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
611 611
 
612
-	if( !empty( $states ) ) {
613
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
612
+	if (!empty($states)) {
613
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
614 614
 
615
-        $class  = isset( $_POST['class'] ) ? esc_attr( sanitize_text_field( $_POST['class'] ) ) : '';
615
+        $class  = isset($_POST['class']) ? esc_attr(sanitize_text_field($_POST['class'])) : '';
616 616
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
617 617
 
618
-        $args  = array(
618
+        $args = array(
619 619
 			'name'    => $sanitized_field_name,
620 620
 			'id'      => $sanitized_field_name,
621
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
622
-			'options' => array_merge( array( '' => '' ), $states ),
621
+			'class'   => implode(' ', array_unique(explode(' ', $class))),
622
+			'options' => array_merge(array('' => ''), $states),
623 623
 			'show_option_all'  => false,
624 624
 			'show_option_none' => false
625 625
 		);
626 626
 
627
-		$response = wpinv_html_select( $args );
627
+		$response = wpinv_html_select($args);
628 628
 
629 629
 	} else {
630 630
 		$response = 'nostates';
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 	return $response;
634 634
 }
635 635
 
636
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
637
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
636
+function wpinv_default_billing_country($country = '', $user_id = 0) {
637
+    $country = !empty($country) ? $country : wpinv_get_default_country();
638 638
     
639
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
639
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
640 640
 }
641 641
 
642 642
 /**
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
  */
649 649
 function wpinv_get_address_formats() {
650 650
 
651
-		return apply_filters( 'wpinv_localisation_address_formats',
651
+		return apply_filters('wpinv_localisation_address_formats',
652 652
 			array(
653 653
 				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
654 654
 				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
@@ -697,9 +697,9 @@  discard block
 block discarded – undo
697 697
  * @see `wpinv_get_invoice_address_replacements`
698 698
  * @return string
699 699
  */
700
-function wpinv_get_full_address_format( $country = false) {
700
+function wpinv_get_full_address_format($country = false) {
701 701
 
702
-    if( empty( $country ) ) {
702
+    if (empty($country)) {
703 703
         $country = wpinv_get_default_country();
704 704
     }
705 705
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 	$formats = wpinv_get_address_formats();
708 708
 
709 709
 	// Get format for the specified country.
710
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
710
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
711 711
     
712 712
     /**
713 713
 	 * Filters the address format to use on Invoices.
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 * @param string $format  The address format to use.
720 720
      * @param string $country The country who's address format is being retrieved.
721 721
 	 */
722
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
722
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
723 723
 }
724 724
 
725 725
 /**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
  * @param array $billing_details customer's billing details
731 731
  * @return array
732 732
  */
733
-function wpinv_get_invoice_address_replacements( $billing_details ) {
733
+function wpinv_get_invoice_address_replacements($billing_details) {
734 734
 
735 735
     $default_args = array(
736 736
         'address'           => '',
@@ -743,22 +743,22 @@  discard block
 block discarded – undo
743 743
 		'company'           => '',
744 744
     );
745 745
 
746
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
746
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
747 747
     $state   = $args['state'];
748 748
     $country = $args['country'];
749 749
 
750 750
     // Handle full country name.
751
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
751
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
752 752
 
753 753
     // Handle full state name.
754
-    $full_state   = ( $country && $state ) ?  wpinv_state_name( $state, $country ) : $state;
754
+    $full_state   = ($country && $state) ?  wpinv_state_name($state, $country) : $state;
755 755
 
756 756
     $args['postcode']    = $args['zip'];
757 757
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
758 758
     $args['state']       = $full_state;
759 759
     $args['state_code']  = $state;
760 760
     $args['country']     = $full_country;
761
-    $args['country_code']= $country;
761
+    $args['country_code'] = $country;
762 762
 
763 763
     /**
764 764
 	 * Filters the address format replacements to use on Invoices.
@@ -769,14 +769,14 @@  discard block
 block discarded – undo
769 769
 	 * @param array $replacements  The address replacements to use.
770 770
      * @param array $billing_details  The billing details to use.
771 771
 	 */
772
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
772
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
773 773
 
774 774
     $return = array();
775 775
 
776
-    foreach( $replacements as $key => $value ) {
777
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
776
+    foreach ($replacements as $key => $value) {
777
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
778 778
         $return['{{' . $key . '}}'] = $value;
779
-        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value );
779
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
780 780
     }
781 781
 
782 782
     return $return;
@@ -790,6 +790,6 @@  discard block
 block discarded – undo
790 790
  * @since 1.0.14
791 791
  * @return string
792 792
  */
793
-function wpinv_trim_formatted_address_line( $line ) {
794
-	return trim( $line, ', ' );
793
+function wpinv_trim_formatted_address_line($line) {
794
+	return trim($line, ', ');
795 795
 }
796 796
\ No newline at end of file
Please login to merge, or discard this patch.
includes/invoice-functions.php 1 patch
Spacing   +370 added lines, -370 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves the current invoice.
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 function getpaid_get_current_invoice_id() {
15 15
 
16 16
     // Ensure that we have an invoice key.
17
-    if ( empty( $_GET['invoice_key'] ) ) {
17
+    if (empty($_GET['invoice_key'])) {
18 18
         return 0;
19 19
     }
20 20
 
21 21
     // Retrieve an invoice using the key.
22
-    $invoice = new WPInv_Invoice( sanitize_text_field( $_GET['invoice_key'] ) );
22
+    $invoice = new WPInv_Invoice(sanitize_text_field($_GET['invoice_key']));
23 23
 
24 24
     // Compare the invoice key and the parsed key.
25
-    if ( $invoice->get_id() != 0 && $invoice->get_key() == sanitize_text_field( $_GET['invoice_key'] ) ) {
25
+    if ($invoice->get_id() != 0 && $invoice->get_key() == sanitize_text_field($_GET['invoice_key'])) {
26 26
         return $invoice->get_id();
27 27
     }
28 28
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * Checks if the current user cna view an invoice.
34 34
  */
35
-function wpinv_user_can_view_invoice( $invoice ) {
36
-    $invoice = new WPInv_Invoice( $invoice );
35
+function wpinv_user_can_view_invoice($invoice) {
36
+    $invoice = new WPInv_Invoice($invoice);
37 37
 
38 38
     // Abort if the invoice does not exist.
39
-    if ( 0 == $invoice->get_id() ) {
39
+    if (0 == $invoice->get_id()) {
40 40
         return false;
41 41
     }
42 42
 
43 43
     // Don't allow trash, draft status
44
-    if ( $invoice->is_draft() ) {
44
+    if ($invoice->is_draft()) {
45 45
         return false;
46 46
     }
47 47
 
48 48
     // If users are not required to login to check out, compare the invoice keys.
49
-    if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && sanitize_text_field( $_GET['invoice_key'] ) == $invoice->get_key() ) {
49
+    if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && sanitize_text_field($_GET['invoice_key']) == $invoice->get_key()) {
50 50
         return true;
51 51
     }
52 52
 
53 53
     // Always enable for admins..
54
-    if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user
54
+    if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user
55 55
         return true;
56 56
     }
57 57
 
58 58
     // Else, ensure that this is their invoice.
59
-    if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) {
59
+    if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) {
60 60
         return true;
61 61
     }
62 62
 
63
-    return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice );
63
+    return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice);
64 64
 }
65 65
 
66 66
 /**
67 67
  * Checks if the current user cna view an invoice receipt.
68 68
  */
69
-function wpinv_can_view_receipt( $invoice ) {
70
-	return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
69
+function wpinv_can_view_receipt($invoice) {
70
+	return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice);
71 71
 }
72 72
 
73 73
 /**
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function getpaid_get_invoice_post_types() {
79 79
     $post_types = array(
80
-        'wpi_quote'   => __( 'Quote', 'invoicing' ),
81
-        'wpi_invoice' => __( 'Invoice', 'invoicing' ),
80
+        'wpi_quote'   => __('Quote', 'invoicing'),
81
+        'wpi_invoice' => __('Invoice', 'invoicing'),
82 82
     );
83 83
 
84 84
     // Ensure the quotes addon is installed.
85
-    if ( ! defined( 'WPINV_QUOTES_VERSION' ) ) {
86
-        unset( $post_types['wpi_quote'] );
85
+    if (!defined('WPINV_QUOTES_VERSION')) {
86
+        unset($post_types['wpi_quote']);
87 87
     }
88 88
 
89
-    return apply_filters( 'getpaid_invoice_post_types', $post_types );
89
+    return apply_filters('getpaid_invoice_post_types', $post_types);
90 90
 }
91 91
 
92 92
 /**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
  *
96 96
  * @param string $post_type The post type to check for.
97 97
  */
98
-function getpaid_is_invoice_post_type( $post_type ) {
99
-    return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() );
98
+function getpaid_is_invoice_post_type($post_type) {
99
+    return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types());
100 100
 }
101 101
 
102 102
 /**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
107 107
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
108 108
  */
109
-function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) {
110
-    $data[ 'invoice_id' ] = 0;
111
-    return wpinv_insert_invoice( $data, $wp_error );
109
+function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) {
110
+    $data['invoice_id'] = 0;
111
+    return wpinv_insert_invoice($data, $wp_error);
112 112
 }
113 113
 
114 114
 /**
@@ -118,36 +118,36 @@  discard block
 block discarded – undo
118 118
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
119 119
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
120 120
  */
121
-function wpinv_update_invoice( $data = array(), $wp_error = false ) {
121
+function wpinv_update_invoice($data = array(), $wp_error = false) {
122 122
 
123 123
     // Backwards compatibility.
124
-    if ( ! empty( $data['ID'] ) ) {
124
+    if (!empty($data['ID'])) {
125 125
         $data['invoice_id'] = $data['ID'];
126 126
     }
127 127
 
128 128
     // Do we have an invoice id?
129
-    if ( empty( $data['invoice_id'] ) ) {
130
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0;
129
+    if (empty($data['invoice_id'])) {
130
+        return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0;
131 131
     }
132 132
 
133 133
     // Retrieve the invoice.
134
-    $invoice = wpinv_get_invoice( $data['invoice_id'] );
134
+    $invoice = wpinv_get_invoice($data['invoice_id']);
135 135
 
136 136
     // And abort if it does not exist.
137
-    if ( empty( $invoice ) ) {
138
-        return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0;
137
+    if (empty($invoice)) {
138
+        return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0;
139 139
     }
140 140
 
141 141
     // Do not update totals for paid / refunded invoices.
142
-    if ( $invoice->is_paid() || $invoice->is_refunded() ) {
142
+    if ($invoice->is_paid() || $invoice->is_refunded()) {
143 143
 
144
-        if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) {
145
-            return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0;
144
+        if (!empty($data['items']) || !empty($data['cart_details'])) {
145
+            return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0;
146 146
         }
147 147
 
148 148
     }
149 149
 
150
-    return wpinv_insert_invoice( $data, $wp_error );
150
+    return wpinv_insert_invoice($data, $wp_error);
151 151
 
152 152
 }
153 153
 
@@ -158,34 +158,34 @@  discard block
 block discarded – undo
158 158
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
159 159
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
160 160
  */
161
-function wpinv_insert_invoice( $data = array(), $wp_error = false ) {
161
+function wpinv_insert_invoice($data = array(), $wp_error = false) {
162 162
 
163 163
     // Ensure that we have invoice data.
164
-    if ( empty( $data ) ) {
164
+    if (empty($data)) {
165 165
         return false;
166 166
     }
167 167
 
168 168
     // The invoice id will be provided when updating an invoice.
169
-    $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false;
169
+    $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false;
170 170
 
171 171
     // Retrieve the invoice.
172
-    $invoice = new WPInv_Invoice( $data['invoice_id'] );
172
+    $invoice = new WPInv_Invoice($data['invoice_id']);
173 173
 
174 174
     // Do we have an error?
175
-    if ( ! empty( $invoice->last_error ) ) {
176
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0;
175
+    if (!empty($invoice->last_error)) {
176
+        return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0;
177 177
     }
178 178
 
179 179
     // Backwards compatibility (billing address).
180
-    if ( ! empty( $data['user_info'] ) ) {
180
+    if (!empty($data['user_info'])) {
181 181
 
182
-        foreach ( $data['user_info'] as $key => $value ) {
182
+        foreach ($data['user_info'] as $key => $value) {
183 183
 
184
-            if ( $key == 'discounts' ) {
184
+            if ($key == 'discounts') {
185 185
                 $value = (array) $value;
186
-                $data[ 'discount_code' ] = empty( $value ) ? null : $value[0];
186
+                $data['discount_code'] = empty($value) ? null : $value[0];
187 187
             } else {
188
-                $data[ $key ] = $value;
188
+                $data[$key] = $value;
189 189
             }
190 190
 
191 191
         }
@@ -193,30 +193,30 @@  discard block
 block discarded – undo
193 193
     }
194 194
 
195 195
     // Backwards compatibility.
196
-    if ( ! empty( $data['payment_details'] ) ) {
196
+    if (!empty($data['payment_details'])) {
197 197
 
198
-        foreach ( $data['payment_details'] as $key => $value ) {
199
-            $data[ $key ] = $value;
198
+        foreach ($data['payment_details'] as $key => $value) {
199
+            $data[$key] = $value;
200 200
         }
201 201
 
202 202
     }
203 203
 
204 204
     // Set up the owner of the invoice.
205
-    $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id();
205
+    $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id();
206 206
 
207 207
     // Make sure the user exists.
208
-    if ( ! get_userdata( $user_id ) ) {
209
-        return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0;
208
+    if (!get_userdata($user_id)) {
209
+        return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0;
210 210
     }
211 211
 
212
-    $address = wpinv_get_user_address( $user_id );
212
+    $address = wpinv_get_user_address($user_id);
213 213
 
214
-    foreach ( $address as $key => $value ) {
214
+    foreach ($address as $key => $value) {
215 215
 
216
-        if ( $value == '' ) {
217
-            $address[ $key ] = null;
216
+        if ($value == '') {
217
+            $address[$key] = null;
218 218
         } else {
219
-            $address[ $key ] = wpinv_clean( $value );
219
+            $address[$key] = wpinv_clean($value);
220 220
         }
221 221
 
222 222
     }
@@ -227,103 +227,103 @@  discard block
 block discarded – undo
227 227
         array(
228 228
 
229 229
             // Basic info.
230
-            'template'             => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null,
231
-            'email_cc'             => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null,
232
-            'date_created'         => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null,
233
-            'due_date'             => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null,
234
-            'date_completed'       => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null,
235
-            'number'               => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null,
236
-            'key'                  => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null,
237
-            'status'               => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null,
238
-            'post_type'            => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null,
239
-            'user_ip'              => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(),
240
-            'parent_id'            => isset( $data['parent'] ) ? intval( $data['parent'] ) : null,
241
-            'mode'                 => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null,
242
-            'description'          => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null,
230
+            'template'             => isset($data['template']) ? wpinv_clean($data['template']) : null,
231
+            'email_cc'             => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null,
232
+            'date_created'         => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null,
233
+            'due_date'             => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null,
234
+            'date_completed'       => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null,
235
+            'number'               => isset($data['number']) ? wpinv_clean($data['number']) : null,
236
+            'key'                  => isset($data['key']) ? wpinv_clean($data['key']) : null,
237
+            'status'               => isset($data['status']) ? wpinv_clean($data['status']) : null,
238
+            'post_type'            => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null,
239
+            'user_ip'              => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(),
240
+            'parent_id'            => isset($data['parent']) ? intval($data['parent']) : null,
241
+            'mode'                 => isset($data['mode']) ? wpinv_clean($data['mode']) : null,
242
+            'description'          => isset($data['description']) ? wp_kses_post($data['description']) : null,
243 243
 
244 244
             // Payment info.
245
-            'disable_taxes'        => ! empty( $data['disable_taxes'] ),
246
-            'currency'             => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(),
247
-            'gateway'              => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null,
248
-            'transaction_id'       => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null,
249
-            'discount_code'        => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null,
250
-            'payment_form'         => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null,
251
-            'submission_id'        => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null,
252
-            'subscription_id'      => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null,
253
-            'is_viewed'            => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null,
254
-            'fees'                 => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null,
255
-            'discounts'            => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null,
256
-            'taxes'                => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null,
245
+            'disable_taxes'        => !empty($data['disable_taxes']),
246
+            'currency'             => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(),
247
+            'gateway'              => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null,
248
+            'transaction_id'       => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null,
249
+            'discount_code'        => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null,
250
+            'payment_form'         => isset($data['payment_form']) ? intval($data['payment_form']) : null,
251
+            'submission_id'        => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null,
252
+            'subscription_id'      => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null,
253
+            'is_viewed'            => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null,
254
+            'fees'                 => isset($data['fees']) ? wpinv_clean($data['fees']) : null,
255
+            'discounts'            => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null,
256
+            'taxes'                => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null,
257 257
 
258 258
 
259 259
             // Billing details.
260 260
             'user_id'              => $data['user_id'],
261
-            'first_name'           => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'],
262
-            'last_name'            => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'],
263
-            'address'              => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] ,
264
-            'vat_number'           => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'],
265
-            'company'              => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'],
266
-            'zip'                  => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'],
267
-            'state'                => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'],
268
-            'city'                 => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'],
269
-            'country'              => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'],
270
-            'phone'                => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'],
271
-            'address_confirmed'    => ! empty( $data['address_confirmed'] ),
261
+            'first_name'           => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'],
262
+            'last_name'            => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'],
263
+            'address'              => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'],
264
+            'vat_number'           => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'],
265
+            'company'              => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'],
266
+            'zip'                  => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'],
267
+            'state'                => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'],
268
+            'city'                 => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'],
269
+            'country'              => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'],
270
+            'phone'                => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'],
271
+            'address_confirmed'    => !empty($data['address_confirmed']),
272 272
 
273 273
         )
274 274
 
275 275
     );
276 276
 
277 277
     // Backwards compatibililty.
278
-    if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) {
278
+    if (!empty($data['cart_details']) && is_array($data['cart_details'])) {
279 279
         $data['items'] = array();
280 280
 
281
-        foreach( $data['cart_details'] as $_item ) {
281
+        foreach ($data['cart_details'] as $_item) {
282 282
 
283 283
             // Ensure that we have an item id.
284
-            if ( empty(  $_item['id']  ) ) {
284
+            if (empty($_item['id'])) {
285 285
                 continue;
286 286
             }
287 287
 
288 288
             // Retrieve the item.
289
-            $item = new GetPaid_Form_Item(  $_item['id']  );
289
+            $item = new GetPaid_Form_Item($_item['id']);
290 290
 
291 291
             // Ensure that it is purchasable.
292
-            if ( ! $item->can_purchase() ) {
292
+            if (!$item->can_purchase()) {
293 293
                 continue;
294 294
             }
295 295
 
296 296
             // Set quantity.
297
-            if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) {
298
-                $item->set_quantity( $_item['quantity'] );
297
+            if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) {
298
+                $item->set_quantity($_item['quantity']);
299 299
             }
300 300
 
301 301
             // Set price.
302
-            if ( isset( $_item['item_price'] ) ) {
303
-                $item->set_price( $_item['item_price'] );
302
+            if (isset($_item['item_price'])) {
303
+                $item->set_price($_item['item_price']);
304 304
             }
305 305
 
306
-            if ( isset( $_item['custom_price'] ) ) {
307
-                $item->set_price( $_item['custom_price'] );
306
+            if (isset($_item['custom_price'])) {
307
+                $item->set_price($_item['custom_price']);
308 308
             }
309 309
 
310 310
             // Set name.
311
-            if ( ! empty( $_item['name'] ) ) {
312
-                $item->set_name( $_item['name'] );
311
+            if (!empty($_item['name'])) {
312
+                $item->set_name($_item['name']);
313 313
             }
314 314
 
315 315
             // Set description.
316
-            if ( isset( $_item['description'] ) ) {
317
-                $item->set_custom_description( $_item['description'] );
316
+            if (isset($_item['description'])) {
317
+                $item->set_custom_description($_item['description']);
318 318
             }
319 319
 
320 320
             // Set meta.
321
-            if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) {
321
+            if (isset($_item['meta']) && is_array($_item['meta'])) {
322 322
 
323
-                $item->set_item_meta( $_item['meta'] );
323
+                $item->set_item_meta($_item['meta']);
324 324
 
325
-                if ( isset( $_item['meta']['description'] ) ) {
326
-                    $item->set_custom_description( $_item['meta']['description'] );
325
+                if (isset($_item['meta']['description'])) {
326
+                    $item->set_custom_description($_item['meta']['description']);
327 327
                 }
328 328
 
329 329
             }
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
     }
335 335
 
336 336
     // Add invoice items.
337
-    if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) {
337
+    if (!empty($data['items']) && is_array($data['items'])) {
338 338
 
339
-        $invoice->set_items( array() );
339
+        $invoice->set_items(array());
340 340
 
341
-        foreach ( $data['items'] as $item ) {
341
+        foreach ($data['items'] as $item) {
342 342
 
343
-            if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) {
344
-                $invoice->add_item( $item );
343
+            if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) {
344
+                $invoice->add_item($item);
345 345
             }
346 346
 
347 347
         }
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
     $invoice->recalculate_total();
353 353
     $invoice->save();
354 354
 
355
-    if ( ! $invoice->get_id() ) {
356
-        return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0;
355
+    if (!$invoice->get_id()) {
356
+        return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0;
357 357
     }
358 358
 
359 359
     // Add private note.
360
-    if ( ! empty( $data['private_note'] ) ) {
361
-        $invoice->add_note( $data['private_note'] );
360
+    if (!empty($data['private_note'])) {
361
+        $invoice->add_note($data['private_note']);
362 362
     }
363 363
 
364 364
     // User notes.
365
-    if ( !empty( $data['user_note'] ) ) {
366
-        $invoice->add_note( $data['user_note'], true );
365
+    if (!empty($data['user_note'])) {
366
+        $invoice->add_note($data['user_note'], true);
367 367
     }
368 368
 
369 369
     // Created via.
370
-    if ( isset( $data['created_via'] ) ) {
371
-        update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] );
370
+    if (isset($data['created_via'])) {
371
+        update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']);
372 372
     }
373 373
 
374 374
     // Backwards compatiblity.
375
-    if ( $invoice->is_quote() ) {
375
+    if ($invoice->is_quote()) {
376 376
 
377
-        if ( isset( $data['valid_until'] ) ) {
378
-            update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] );
377
+        if (isset($data['valid_until'])) {
378
+            update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']);
379 379
         }
380 380
 
381 381
     }
@@ -390,20 +390,20 @@  discard block
 block discarded – undo
390 390
  * @param $bool $deprecated
391 391
  * @return WPInv_Invoice|null
392 392
  */
393
-function wpinv_get_invoice( $invoice = 0, $deprecated = false ) {
393
+function wpinv_get_invoice($invoice = 0, $deprecated = false) {
394 394
 
395 395
     // If we are retrieving the invoice from the cart...
396
-    if ( $deprecated && empty( $invoice ) ) {
396
+    if ($deprecated && empty($invoice)) {
397 397
         $invoice = (int) getpaid_get_current_invoice_id();
398 398
     }
399 399
 
400 400
     // Retrieve the invoice.
401
-    if ( ! is_a( $invoice, 'WPInv_Invoice' ) ) {
402
-        $invoice = new WPInv_Invoice( $invoice );
401
+    if (!is_a($invoice, 'WPInv_Invoice')) {
402
+        $invoice = new WPInv_Invoice($invoice);
403 403
     }
404 404
 
405 405
     // Check if it exists.
406
-    if ( $invoice->exists() ) {
406
+    if ($invoice->exists()) {
407 407
         return $invoice;
408 408
     }
409 409
 
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
  * @param array $args Args to search for.
417 417
  * @return WPInv_Invoice[]|int[]|object
418 418
  */
419
-function wpinv_get_invoices( $args ) {
419
+function wpinv_get_invoices($args) {
420 420
 
421 421
     // Prepare args.
422 422
     $args = wp_parse_args(
423 423
         $args,
424 424
         array(
425
-            'status'   => array_keys( wpinv_get_invoice_statuses() ),
425
+            'status'   => array_keys(wpinv_get_invoice_statuses()),
426 426
             'type'     => 'wpi_invoice',
427
-            'limit'    => get_option( 'posts_per_page' ),
427
+            'limit'    => get_option('posts_per_page'),
428 428
             'return'   => 'objects',
429 429
         )
430 430
     );
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
         'post__in'       => 'include',
443 443
     );
444 444
 
445
-    foreach ( $map_legacy as $to => $from ) {
446
-        if ( isset( $args[ $from ] ) ) {
447
-            $args[ $to ] = $args[ $from ];
448
-            unset( $args[ $from ] );
445
+    foreach ($map_legacy as $to => $from) {
446
+        if (isset($args[$from])) {
447
+            $args[$to] = $args[$from];
448
+            unset($args[$from]);
449 449
         }
450 450
     }
451 451
 
452 452
     // Backwards compatibility.
453
-    if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) {
453
+    if (!empty($args['email']) && empty($args['user'])) {
454 454
         $args['user'] = $args['email'];
455
-        unset( $args['email'] );
455
+        unset($args['email']);
456 456
     }
457 457
 
458 458
     // Handle cases where the user is set as an email.
459
-    if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) {
460
-        $user = get_user_by( 'email', $args['user'] );
459
+    if (!empty($args['author']) && is_email($args['author'])) {
460
+        $user = get_user_by('email', $args['user']);
461 461
 
462
-        if ( $user ) {
462
+        if ($user) {
463 463
             $args['author'] = $user->user_email;
464 464
         }
465 465
 
@@ -470,31 +470,31 @@  discard block
 block discarded – undo
470 470
 
471 471
     // Show all posts.
472 472
     $paginate = true;
473
-    if ( isset( $args['paginate'] ) ) {
473
+    if (isset($args['paginate'])) {
474 474
 
475 475
         $paginate = $args['paginate'];
476
-        $args['no_found_rows'] = empty( $args['paginate'] );
477
-        unset( $args['paginate'] );
476
+        $args['no_found_rows'] = empty($args['paginate']);
477
+        unset($args['paginate']);
478 478
 
479 479
     }
480 480
 
481 481
     // Whether to return objects or fields.
482 482
     $return = $args['return'];
483
-    unset( $args['return'] );
483
+    unset($args['return']);
484 484
 
485 485
     // Get invoices.
486
-    $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) );
486
+    $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args));
487 487
 
488 488
     // Prepare the results.
489
-    if ( 'objects' === $return ) {
490
-        $results = array_map( 'wpinv_get_invoice', $invoices->posts );
491
-    } elseif ( 'self' === $return ) {
489
+    if ('objects' === $return) {
490
+        $results = array_map('wpinv_get_invoice', $invoices->posts);
491
+    } elseif ('self' === $return) {
492 492
         return $invoices;
493 493
     } else {
494 494
         $results = $invoices->posts;
495 495
     }
496 496
 
497
-    if ( $paginate ) {
497
+    if ($paginate) {
498 498
         return (object) array(
499 499
             'invoices'      => $results,
500 500
             'total'         => $invoices->found_posts,
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
  * @param string $transaction_id The transaction id to check.
513 513
  * @return int Invoice id on success or 0 on failure
514 514
  */
515
-function wpinv_get_id_by_transaction_id( $transaction_id ) {
516
-    return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' );
515
+function wpinv_get_id_by_transaction_id($transaction_id) {
516
+    return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id');
517 517
 }
518 518
 
519 519
 /**
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
  * @param string $invoice_number The invoice number to check.
523 523
  * @return int Invoice id on success or 0 on failure
524 524
  */
525
-function wpinv_get_id_by_invoice_number( $invoice_number ) {
526
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' );
525
+function wpinv_get_id_by_invoice_number($invoice_number) {
526
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number');
527 527
 }
528 528
 
529 529
 /**
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
  * @param string $invoice_key The invoice key to check.
533 533
  * @return int Invoice id on success or 0 on failure
534 534
  */
535
-function wpinv_get_invoice_id_by_key( $invoice_key ) {
536
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' );
535
+function wpinv_get_invoice_id_by_key($invoice_key) {
536
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key');
537 537
 }
538 538
 
539 539
 /**
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
  * @param string $type Optionally filter by type i.e customer|system
544 544
  * @return array|null
545 545
  */
546
-function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) {
546
+function wpinv_get_invoice_notes($invoice = 0, $type = '') {
547 547
 
548 548
     // Prepare the invoice.
549
-    $invoice = wpinv_get_invoice( $invoice );
550
-    if ( empty( $invoice ) ) {
549
+    $invoice = wpinv_get_invoice($invoice);
550
+    if (empty($invoice)) {
551 551
         return NULL;
552 552
     }
553 553
 
554 554
     // Fetch notes.
555
-    $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type );
555
+    $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type);
556 556
 
557 557
     // Filter the notes.
558
-    return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type );
558
+    return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type);
559 559
 }
560 560
 
561 561
 /**
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
  *
564 564
  * @param string $post_type
565 565
  */
566
-function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) {
566
+function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') {
567 567
 
568
-    $label   = getpaid_get_post_type_label( $post_type, false );
569
-    $label   = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label );
568
+    $label   = getpaid_get_post_type_label($post_type, false);
569
+    $label   = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label);
570 570
     $columns = array(
571 571
 
572 572
             'invoice-number'  => array(
@@ -575,22 +575,22 @@  discard block
 block discarded – undo
575 575
             ),
576 576
 
577 577
             'created-date'    => array(
578
-                'title' => __( 'Created Date', 'invoicing' ),
578
+                'title' => __('Created Date', 'invoicing'),
579 579
                 'class' => 'text-left'
580 580
             ),
581 581
 
582 582
             'payment-date'    => array(
583
-                'title' => __( 'Payment Date', 'invoicing' ),
583
+                'title' => __('Payment Date', 'invoicing'),
584 584
                 'class' => 'text-left'
585 585
             ),
586 586
 
587 587
             'invoice-status'  => array(
588
-                'title' => __( 'Status', 'invoicing' ),
588
+                'title' => __('Status', 'invoicing'),
589 589
                 'class' => 'text-center'
590 590
             ),
591 591
 
592 592
             'invoice-total'   => array(
593
-                'title' => __( 'Total', 'invoicing' ),
593
+                'title' => __('Total', 'invoicing'),
594 594
                 'class' => 'text-right'
595 595
             ),
596 596
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
         );
603 603
 
604
-    return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type );
604
+    return apply_filters('wpinv_user_invoices_columns', $columns, $post_type);
605 605
 }
606 606
 
607 607
 /**
@@ -611,59 +611,59 @@  discard block
 block discarded – undo
611 611
 
612 612
     // Find the invoice.
613 613
     $invoice_id = getpaid_get_current_invoice_id();
614
-    $invoice = new WPInv_Invoice( $invoice_id );
614
+    $invoice = new WPInv_Invoice($invoice_id);
615 615
 
616 616
     // Abort if non was found.
617
-    if ( empty( $invoice_id ) || $invoice->is_draft() ) {
617
+    if (empty($invoice_id) || $invoice->is_draft()) {
618 618
 
619 619
         return aui()->alert(
620 620
             array(
621 621
                 'type'    => 'warning',
622
-                'content' => __( 'We could not find your invoice', 'invoicing' ),
622
+                'content' => __('We could not find your invoice', 'invoicing'),
623 623
             )
624 624
         );
625 625
 
626 626
     }
627 627
 
628 628
     // Can the user view this invoice?
629
-    if ( ! wpinv_can_view_receipt( $invoice_id ) ) {
629
+    if (!wpinv_can_view_receipt($invoice_id)) {
630 630
 
631 631
         return aui()->alert(
632 632
             array(
633 633
                 'type'    => 'warning',
634
-                'content' => __( 'You are not allowed to view this receipt', 'invoicing' ),
634
+                'content' => __('You are not allowed to view this receipt', 'invoicing'),
635 635
             )
636 636
         );
637 637
 
638 638
     }
639 639
 
640 640
     // Load the template.
641
-    return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) );
641
+    return wpinv_get_template_html('invoice-receipt.php', compact('invoice'));
642 642
 
643 643
 }
644 644
 
645 645
 /**
646 646
  * Displays the invoice history.
647 647
  */
648
-function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) {
648
+function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') {
649 649
 
650 650
     // Ensure that we have a user id.
651
-    if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
651
+    if (empty($user_id) || !is_numeric($user_id)) {
652 652
         $user_id = get_current_user_id();
653 653
     }
654 654
 
655
-    $label = getpaid_get_post_type_label( $post_type );
656
-    $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label );
655
+    $label = getpaid_get_post_type_label($post_type);
656
+    $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label);
657 657
 
658 658
     // View user id.
659
-    if ( empty( $user_id ) ) {
659
+    if (empty($user_id)) {
660 660
 
661 661
         return aui()->alert(
662 662
             array(
663 663
                 'type'    => 'warning',
664 664
                 'content' => sprintf(
665
-                    __( 'You must be logged in to view your %s.', 'invoicing' ),
666
-                    strtolower( $label )
665
+                    __('You must be logged in to view your %s.', 'invoicing'),
666
+                    strtolower($label)
667 667
                 )
668 668
             )
669 669
         );
@@ -674,23 +674,23 @@  discard block
 block discarded – undo
674 674
     $invoices = wpinv_get_invoices(
675 675
 
676 676
         array(
677
-            'page'      => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1,
677
+            'page'      => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1,
678 678
             'user'      => $user_id,
679 679
             'paginate'  => true,
680 680
             'type'      => $post_type,
681
-            'status'    => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ),
681
+            'status'    => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)),
682 682
         )
683 683
 
684 684
     );
685 685
 
686
-    if ( empty( $invoices->total ) ) {
686
+    if (empty($invoices->total)) {
687 687
 
688 688
         return aui()->alert(
689 689
             array(
690 690
                 'type'    => 'info',
691 691
                 'content' => sprintf(
692
-                    __( 'No %s found.', 'invoicing' ),
693
-                    strtolower( $label )
692
+                    __('No %s found.', 'invoicing'),
693
+                    strtolower($label)
694 694
                 )
695 695
             )
696 696
         );
@@ -698,38 +698,38 @@  discard block
 block discarded – undo
698 698
     }
699 699
 
700 700
     // Load the template.
701
-    return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) );
701
+    return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type'));
702 702
 
703 703
 }
704 704
 
705 705
 /**
706 706
  * Formats an invoice number given an invoice type.
707 707
  */
708
-function wpinv_format_invoice_number( $number, $type = '' ) {
708
+function wpinv_format_invoice_number($number, $type = '') {
709 709
 
710 710
     // Allow other plugins to overide this.
711
-    $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type );
712
-    if ( null !== $check ) {
711
+    $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type);
712
+    if (null !== $check) {
713 713
         return $check;
714 714
     }
715 715
 
716 716
     // Ensure that we have a numeric number.
717
-    if ( ! is_numeric( $number ) ) {
717
+    if (!is_numeric($number)) {
718 718
         return $number;
719 719
     }
720 720
 
721 721
     // Format the number.
722
-    $padd             = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) );
723
-    $prefix           = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) );
724
-    $prefix           = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) );
725
-    $postfix          = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) );
726
-    $postfix          = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) );
727
-    $formatted_number = zeroise( absint( $number ), $padd );
722
+    $padd             = absint((int) wpinv_get_option('invoice_number_padd', 5));
723
+    $prefix           = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-'));
724
+    $prefix           = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type));
725
+    $postfix          = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix'));
726
+    $postfix          = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type));
727
+    $formatted_number = zeroise(absint($number), $padd);
728 728
 
729 729
     // Add the prefix and post fix.
730 730
     $formatted_number = $prefix . $formatted_number . $postfix;
731 731
 
732
-    return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd );
732
+    return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd);
733 733
 }
734 734
 
735 735
 /**
@@ -738,58 +738,58 @@  discard block
 block discarded – undo
738 738
  * @param string $type.
739 739
  * @return int|null|bool
740 740
  */
741
-function wpinv_get_next_invoice_number( $type = '' ) {
741
+function wpinv_get_next_invoice_number($type = '') {
742 742
 
743 743
     // Allow plugins to overide this.
744
-    $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type );
745
-    if ( null !== $check ) {
744
+    $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type);
745
+    if (null !== $check) {
746 746
         return $check;
747 747
     }
748 748
 
749 749
     // Ensure sequential invoice numbers is active.
750
-    if ( ! wpinv_sequential_number_active() ) {
750
+    if (!wpinv_sequential_number_active()) {
751 751
         return false;
752 752
     }
753 753
 
754 754
     // Retrieve the current number and the start number.
755
-    $number = (int) get_option( 'wpinv_last_invoice_number', 0 );
756
-    $start  = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) );
755
+    $number = (int) get_option('wpinv_last_invoice_number', 0);
756
+    $start  = absint((int) wpinv_get_option('invoice_sequence_start', 1));
757 757
 
758 758
     // Ensure that we are starting at a positive integer.
759
-    $start  = max( $start, 1 );
759
+    $start  = max($start, 1);
760 760
 
761 761
     // If this is the first invoice, use the start number.
762
-    $number = max( $start, $number );
762
+    $number = max($start, $number);
763 763
 
764 764
     // Format the invoice number.
765
-    $formatted_number = wpinv_format_invoice_number( $number, $type );
765
+    $formatted_number = wpinv_format_invoice_number($number, $type);
766 766
 
767 767
     // Ensure that this number is unique.
768
-    $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' );
768
+    $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number');
769 769
 
770 770
     // We found a match. Nice.
771
-    if ( empty( $invoice_id ) ) {
772
-        update_option( 'wpinv_last_invoice_number', $number );
773
-        return apply_filters( 'wpinv_get_next_invoice_number', $number );
771
+    if (empty($invoice_id)) {
772
+        update_option('wpinv_last_invoice_number', $number);
773
+        return apply_filters('wpinv_get_next_invoice_number', $number);
774 774
     }
775 775
 
776
-    update_option( 'wpinv_last_invoice_number', $number + 1 );
777
-    return wpinv_get_next_invoice_number( $type );
776
+    update_option('wpinv_last_invoice_number', $number + 1);
777
+    return wpinv_get_next_invoice_number($type);
778 778
 
779 779
 }
780 780
 
781 781
 /**
782 782
  * The prefix used for invoice paths.
783 783
  */
784
-function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) {
785
-    return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type );
784
+function wpinv_post_name_prefix($post_type = 'wpi_invoice') {
785
+    return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type);
786 786
 }
787 787
 
788
-function wpinv_generate_post_name( $post_ID ) {
789
-    $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) );
790
-    $post_name = sanitize_title( $prefix . $post_ID );
788
+function wpinv_generate_post_name($post_ID) {
789
+    $prefix = wpinv_post_name_prefix(get_post_type($post_ID));
790
+    $post_name = sanitize_title($prefix . $post_ID);
791 791
 
792
-    return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix );
792
+    return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix);
793 793
 }
794 794
 
795 795
 /**
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
  *
798 798
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
799 799
  */
800
-function wpinv_is_invoice_viewed( $invoice ) {
801
-    $invoice = new WPInv_Invoice( $invoice );
800
+function wpinv_is_invoice_viewed($invoice) {
801
+    $invoice = new WPInv_Invoice($invoice);
802 802
     return (bool) $invoice->get_is_viewed();
803 803
 }
804 804
 
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
  *
808 808
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
809 809
  */
810
-function getpaid_maybe_mark_invoice_as_viewed( $invoice ) {
811
-    $invoice = new WPInv_Invoice( $invoice );
810
+function getpaid_maybe_mark_invoice_as_viewed($invoice) {
811
+    $invoice = new WPInv_Invoice($invoice);
812 812
 
813
-    if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) {
814
-        $invoice->set_is_viewed( true );
813
+    if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) {
814
+        $invoice->set_is_viewed(true);
815 815
         $invoice->save();
816 816
     }
817 817
 
818 818
 }
819
-add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' );
820
-add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' );
819
+add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed');
820
+add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed');
821 821
 
822 822
 /**
823 823
  * Processes an invoice refund.
@@ -826,27 +826,27 @@  discard block
 block discarded – undo
826 826
  * @param array $status_transition
827 827
  * @todo: descrease customer/store earnings
828 828
  */
829
-function getpaid_maybe_process_refund( $invoice, $status_transition ) {
829
+function getpaid_maybe_process_refund($invoice, $status_transition) {
830 830
 
831
-    if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) {
831
+    if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) {
832 832
         return;
833 833
     }
834 834
 
835 835
     $discount_code = $invoice->get_discount_code();
836
-    if ( ! empty( $discount_code ) ) {
837
-        $discount = wpinv_get_discount_obj( $discount_code );
836
+    if (!empty($discount_code)) {
837
+        $discount = wpinv_get_discount_obj($discount_code);
838 838
 
839
-        if ( $discount->exists() ) {
839
+        if ($discount->exists()) {
840 840
             $discount->increase_usage( -1 );
841 841
         }
842 842
 
843 843
     }
844 844
 
845
-    do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() );
846
-    do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() );
847
-    do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() );
845
+    do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id());
846
+    do_action('wpinv_refund_invoice', $invoice, $invoice->get_id());
847
+    do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id());
848 848
 }
849
-add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 );
849
+add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2);
850 850
 
851 851
 
852 852
 /**
@@ -854,49 +854,49 @@  discard block
 block discarded – undo
854 854
  *
855 855
  * @param int $invoice_id
856 856
  */
857
-function getpaid_process_invoice_payment( $invoice_id ) {
857
+function getpaid_process_invoice_payment($invoice_id) {
858 858
 
859 859
     // Fetch the invoice.
860
-    $invoice = new WPInv_Invoice( $invoice_id );
860
+    $invoice = new WPInv_Invoice($invoice_id);
861 861
 
862 862
     // We only want to do this once.
863
-    if ( 1 ==  get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) {
863
+    if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) {
864 864
         return;
865 865
     }
866 866
 
867
-    update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 );
867
+    update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1);
868 868
 
869 869
     // Fires when processing a payment.
870
-    do_action( 'getpaid_process_payment', $invoice );
870
+    do_action('getpaid_process_payment', $invoice);
871 871
 
872 872
     // Fire an action for each invoice item.
873
-    foreach( $invoice->get_items() as $item ) {
874
-        do_action( 'getpaid_process_item_payment', $item, $invoice );
873
+    foreach ($invoice->get_items() as $item) {
874
+        do_action('getpaid_process_item_payment', $item, $invoice);
875 875
     }
876 876
 
877 877
     // Increase discount usage.
878 878
     $discount_code = $invoice->get_discount_code();
879
-    if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) {
880
-        $discount = wpinv_get_discount_obj( $discount_code );
879
+    if (!empty($discount_code) && !$invoice->is_renewal()) {
880
+        $discount = wpinv_get_discount_obj($discount_code);
881 881
 
882
-        if ( $discount->exists() ) {
882
+        if ($discount->exists()) {
883 883
             $discount->increase_usage();
884 884
         }
885 885
 
886 886
     }
887 887
 
888 888
     // Record reverse vat.
889
-    if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
889
+    if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
890 890
 
891 891
         $taxes = $invoice->get_total_tax();
892
-        if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) {
893
-            $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true );
892
+        if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) {
893
+            $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true);
894 894
         }
895 895
 
896 896
     }
897 897
 
898 898
 }
899
-add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' );
899
+add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment');
900 900
 
901 901
 /**
902 902
  * Returns an array of invoice item columns
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
  * @param int|WPInv_Invoice $invoice
905 905
  * @return array
906 906
  */
907
-function getpaid_invoice_item_columns( $invoice ) {
907
+function getpaid_invoice_item_columns($invoice) {
908 908
 
909 909
     // Prepare the invoice.
910
-    $invoice = new WPInv_Invoice( $invoice );
910
+    $invoice = new WPInv_Invoice($invoice);
911 911
 
912 912
     // Abort if there is no invoice.
913
-    if ( 0 == $invoice->get_id() ) {
913
+    if (0 == $invoice->get_id()) {
914 914
         return array();
915 915
     }
916 916
 
@@ -918,57 +918,57 @@  discard block
 block discarded – undo
918 918
     $columns = apply_filters(
919 919
         'getpaid_invoice_item_columns',
920 920
         array(
921
-            'name'     => __( 'Item', 'invoicing' ),
922
-            'price'    => __( 'Price', 'invoicing' ),
923
-            'tax_rate' => __( 'Tax Rate', 'invoicing' ),
924
-            'quantity' => __( 'Quantity', 'invoicing' ),
925
-            'subtotal' => __( 'Item Subtotal', 'invoicing' ),
921
+            'name'     => __('Item', 'invoicing'),
922
+            'price'    => __('Price', 'invoicing'),
923
+            'tax_rate' => __('Tax Rate', 'invoicing'),
924
+            'quantity' => __('Quantity', 'invoicing'),
925
+            'subtotal' => __('Item Subtotal', 'invoicing'),
926 926
         ),
927 927
         $invoice
928 928
     );
929 929
 
930 930
     // Quantities.
931
-    if ( isset( $columns[ 'quantity' ] ) ) {
931
+    if (isset($columns['quantity'])) {
932 932
 
933
-        if ( 'hours' == $invoice->get_template() ) {
934
-            $columns[ 'quantity' ] = __( 'Hours', 'invoicing' );
933
+        if ('hours' == $invoice->get_template()) {
934
+            $columns['quantity'] = __('Hours', 'invoicing');
935 935
         }
936 936
 
937
-        if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) {
938
-            unset( $columns[ 'quantity' ] );
937
+        if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) {
938
+            unset($columns['quantity']);
939 939
         }
940 940
 
941 941
     }
942 942
 
943 943
 
944 944
     // Price.
945
-    if ( isset( $columns[ 'price' ] ) ) {
945
+    if (isset($columns['price'])) {
946 946
 
947
-        if ( 'amount' == $invoice->get_template() ) {
948
-            $columns[ 'price' ] = __( 'Amount', 'invoicing' );
947
+        if ('amount' == $invoice->get_template()) {
948
+            $columns['price'] = __('Amount', 'invoicing');
949 949
         }
950 950
 
951
-        if ( 'hours' == $invoice->get_template() ) {
952
-            $columns[ 'price' ] = __( 'Rate', 'invoicing' );
951
+        if ('hours' == $invoice->get_template()) {
952
+            $columns['price'] = __('Rate', 'invoicing');
953 953
         }
954 954
 
955 955
     }
956 956
 
957 957
 
958 958
     // Sub total.
959
-    if ( isset( $columns[ 'subtotal' ] ) ) {
959
+    if (isset($columns['subtotal'])) {
960 960
 
961
-        if ( 'amount' == $invoice->get_template() ) {
962
-            unset( $columns[ 'subtotal' ] );
961
+        if ('amount' == $invoice->get_template()) {
962
+            unset($columns['subtotal']);
963 963
         }
964 964
 
965 965
     }
966 966
 
967 967
     // Tax rates.
968
-    if ( isset( $columns[ 'tax_rate' ] ) ) {
968
+    if (isset($columns['tax_rate'])) {
969 969
 
970
-        if ( 0 == $invoice->get_tax() ) {
971
-            unset( $columns[ 'tax_rate' ] );
970
+        if (0 == $invoice->get_tax()) {
971
+            unset($columns['tax_rate']);
972 972
         }
973 973
 
974 974
     }
@@ -982,43 +982,43 @@  discard block
 block discarded – undo
982 982
  * @param int|WPInv_Invoice $invoice
983 983
  * @return array
984 984
  */
985
-function getpaid_invoice_totals_rows( $invoice ) {
985
+function getpaid_invoice_totals_rows($invoice) {
986 986
 
987 987
     // Prepare the invoice.
988
-    $invoice = new WPInv_Invoice( $invoice );
988
+    $invoice = new WPInv_Invoice($invoice);
989 989
 
990 990
     // Abort if there is no invoice.
991
-    if ( 0 == $invoice->get_id() ) {
991
+    if (0 == $invoice->get_id()) {
992 992
         return array();
993 993
     }
994 994
 
995 995
     $totals = apply_filters(
996 996
         'getpaid_invoice_totals_rows',
997 997
         array(
998
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
999
-            'shipping' => __( 'Shipping', 'invoicing' ),
1000
-            'tax'      => __( 'Tax', 'invoicing' ),
1001
-            'fee'      => __( 'Fee', 'invoicing' ),
1002
-            'discount' => __( 'Discount', 'invoicing' ),
1003
-            'total'    => __( 'Total', 'invoicing' ),
998
+            'subtotal' => __('Subtotal', 'invoicing'),
999
+            'shipping' => __('Shipping', 'invoicing'),
1000
+            'tax'      => __('Tax', 'invoicing'),
1001
+            'fee'      => __('Fee', 'invoicing'),
1002
+            'discount' => __('Discount', 'invoicing'),
1003
+            'total'    => __('Total', 'invoicing'),
1004 1004
         ),
1005 1005
         $invoice
1006 1006
     );
1007 1007
 
1008
-    if ( ! $invoice->has_shipping() ) {
1009
-        unset( $totals['shipping'] );
1008
+    if (!$invoice->has_shipping()) {
1009
+        unset($totals['shipping']);
1010 1010
     }
1011 1011
 
1012
-    if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) {
1013
-        unset( $totals['tax'] );
1012
+    if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) {
1013
+        unset($totals['tax']);
1014 1014
     }
1015 1015
 
1016
-    if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) {
1017
-        unset( $totals['fee'] );
1016
+    if (0 == $invoice->get_total_fees() && isset($totals['fee'])) {
1017
+        unset($totals['fee']);
1018 1018
     }
1019 1019
 
1020
-    if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) {
1021
-        unset( $totals['discount'] );
1020
+    if (0 == $invoice->get_total_discount() && isset($totals['discount'])) {
1021
+        unset($totals['discount']);
1022 1022
     }
1023 1023
 
1024 1024
     return $totals;
@@ -1029,47 +1029,47 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @param WPInv_Invoice $invoice
1031 1031
  */
1032
-function getpaid_new_invoice( $invoice ) {
1032
+function getpaid_new_invoice($invoice) {
1033 1033
 
1034
-    if ( ! $invoice->get_status() ) {
1034
+    if (!$invoice->get_status()) {
1035 1035
         return;
1036 1036
     }
1037 1037
 
1038 1038
     // Add an invoice created note.
1039 1039
     $invoice->add_note(
1040 1040
         sprintf(
1041
-            __( '%s created with the status "%s".', 'invoicing' ),
1042
-            ucfirst( $invoice->get_invoice_quote_type() ),
1043
-            wpinv_status_nicename( $invoice->get_status(), $invoice  )
1041
+            __('%s created with the status "%s".', 'invoicing'),
1042
+            ucfirst($invoice->get_invoice_quote_type()),
1043
+            wpinv_status_nicename($invoice->get_status(), $invoice)
1044 1044
         )
1045 1045
     );
1046 1046
 
1047 1047
 }
1048
-add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' );
1048
+add_action('getpaid_new_invoice', 'getpaid_new_invoice');
1049 1049
 
1050 1050
 /**
1051 1051
  * This function updates invoice caches.
1052 1052
  *
1053 1053
  * @param WPInv_Invoice $invoice
1054 1054
  */
1055
-function getpaid_update_invoice_caches( $invoice ) {
1055
+function getpaid_update_invoice_caches($invoice) {
1056 1056
 
1057 1057
     // Cache invoice number.
1058
-    wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" );
1058
+    wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids");
1059 1059
 
1060 1060
     // Cache invoice key.
1061
-    wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" );
1061
+    wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids");
1062 1062
 
1063 1063
     // (Maybe) cache transaction id.
1064 1064
     $transaction_id = $invoice->get_transaction_id();
1065 1065
 
1066
-    if ( ! empty( $transaction_id ) ) {
1067
-        wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" );
1066
+    if (!empty($transaction_id)) {
1067
+        wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids");
1068 1068
     }
1069 1069
 
1070 1070
 }
1071
-add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 );
1072
-add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 );
1071
+add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5);
1072
+add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5);
1073 1073
 
1074 1074
 /**
1075 1075
  * Duplicates an invoice.
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
  * @param  WPInv_Invoice $old_invoice The invoice to duplicate
1080 1080
  * @return WPInv_Invoice The new invoice.
1081 1081
  */
1082
-function getpaid_duplicate_invoice( $old_invoice ) {
1082
+function getpaid_duplicate_invoice($old_invoice) {
1083 1083
 
1084 1084
     // Create the new invoice.
1085 1085
     $invoice = new WPInv_Invoice();
@@ -1141,138 +1141,138 @@  discard block
 block discarded – undo
1141 1141
  * @param WPInv_Invoice $invoice
1142 1142
  * @return array
1143 1143
  */
1144
-function getpaid_get_invoice_meta( $invoice ) {
1144
+function getpaid_get_invoice_meta($invoice) {
1145 1145
 
1146 1146
     // Load the invoice meta.
1147 1147
     $meta = array(
1148 1148
 
1149 1149
         'number' => array(
1150 1150
             'label' => sprintf(
1151
-                __( '%s Number', 'invoicing' ),
1152
-                ucfirst( $invoice->get_invoice_quote_type() )
1151
+                __('%s Number', 'invoicing'),
1152
+                ucfirst($invoice->get_invoice_quote_type())
1153 1153
             ),
1154
-            'value' => sanitize_text_field( $invoice->get_number() ),
1154
+            'value' => sanitize_text_field($invoice->get_number()),
1155 1155
         ),
1156 1156
 
1157 1157
         'status' => array(
1158 1158
             'label' => sprintf(
1159
-                __( '%s Status', 'invoicing' ),
1160
-                ucfirst( $invoice->get_invoice_quote_type() )
1159
+                __('%s Status', 'invoicing'),
1160
+                ucfirst($invoice->get_invoice_quote_type())
1161 1161
             ),
1162 1162
             'value' => $invoice->get_status_label_html(),
1163 1163
         ),
1164 1164
 
1165 1165
         'date' => array(
1166 1166
             'label' => sprintf(
1167
-                __( '%s Date', 'invoicing' ),
1168
-                ucfirst( $invoice->get_invoice_quote_type() )
1167
+                __('%s Date', 'invoicing'),
1168
+                ucfirst($invoice->get_invoice_quote_type())
1169 1169
             ),
1170
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
1170
+            'value' => getpaid_format_date($invoice->get_created_date()),
1171 1171
         ),
1172 1172
 
1173 1173
         'date_paid' => array(
1174
-            'label' => __( 'Paid On', 'invoicing' ),
1175
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
1174
+            'label' => __('Paid On', 'invoicing'),
1175
+            'value' => getpaid_format_date($invoice->get_completed_date()),
1176 1176
         ),
1177 1177
 
1178 1178
         'gateway'   => array(
1179
-            'label' => __( 'Payment Method', 'invoicing' ),
1180
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
1179
+            'label' => __('Payment Method', 'invoicing'),
1180
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
1181 1181
         ),
1182 1182
 
1183 1183
         'transaction_id' => array(
1184
-            'label' => __( 'Transaction ID', 'invoicing' ),
1185
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
1184
+            'label' => __('Transaction ID', 'invoicing'),
1185
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
1186 1186
         ),
1187 1187
 
1188 1188
         'due_date'  => array(
1189
-            'label' => __( 'Due Date', 'invoicing' ),
1190
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
1189
+            'label' => __('Due Date', 'invoicing'),
1190
+            'value' => getpaid_format_date($invoice->get_due_date()),
1191 1191
         ),
1192 1192
 
1193 1193
         'vat_number' => array(
1194
-            'label' => __( 'VAT Number', 'invoicing' ),
1195
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
1194
+            'label' => __('VAT Number', 'invoicing'),
1195
+            'value' => sanitize_text_field($invoice->get_vat_number()),
1196 1196
         ),
1197 1197
 
1198 1198
     );
1199 1199
 
1200
-    $additional_meta = get_post_meta( $invoice->get_id(), 'additional_meta_data', true );
1200
+    $additional_meta = get_post_meta($invoice->get_id(), 'additional_meta_data', true);
1201 1201
 
1202
-    if ( ! empty( $additional_meta ) ) {
1202
+    if (!empty($additional_meta)) {
1203 1203
 
1204
-        foreach ( $additional_meta as $label => $value ) {
1205
-            $meta[ sanitize_key( $label ) ] = array(
1206
-                'label' => esc_html( $label ),
1207
-                'value' => esc_html( $value ),
1204
+        foreach ($additional_meta as $label => $value) {
1205
+            $meta[sanitize_key($label)] = array(
1206
+                'label' => esc_html($label),
1207
+                'value' => esc_html($value),
1208 1208
             );
1209 1209
         }
1210 1210
 
1211 1211
     }
1212 1212
     // If it is not paid, remove the date of payment.
1213
-    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
1214
-        unset( $meta[ 'date_paid' ] );
1215
-        unset( $meta[ 'transaction_id' ] );
1213
+    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1214
+        unset($meta['date_paid']);
1215
+        unset($meta['transaction_id']);
1216 1216
     }
1217 1217
 
1218
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
1219
-        unset( $meta[ 'gateway' ] );
1218
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
1219
+        unset($meta['gateway']);
1220 1220
     }
1221 1221
 
1222 1222
     // Only display the due date if due dates are enabled.
1223
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
1224
-        unset( $meta[ 'due_date' ] );
1223
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
1224
+        unset($meta['due_date']);
1225 1225
     }
1226 1226
 
1227 1227
     // Only display the vat number if taxes are enabled.
1228
-    if ( ! wpinv_use_taxes() ) {
1229
-        unset( $meta[ 'vat_number' ] );
1228
+    if (!wpinv_use_taxes()) {
1229
+        unset($meta['vat_number']);
1230 1230
     }
1231 1231
 
1232 1232
     // Link to the parent invoice.
1233
-    if ( $invoice->get_parent_id() > 0 ) {
1233
+    if ($invoice->get_parent_id() > 0) {
1234 1234
 
1235
-        $meta[ 'parent' ] = array(
1235
+        $meta['parent'] = array(
1236 1236
 
1237 1237
             'label' => sprintf(
1238
-                __( 'Parent %s', 'invoicing' ),
1239
-                ucfirst( $invoice->get_invoice_quote_type() )
1238
+                __('Parent %s', 'invoicing'),
1239
+                ucfirst($invoice->get_invoice_quote_type())
1240 1240
             ),
1241 1241
 
1242
-            'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
1242
+            'value' => wpinv_invoice_link($invoice->get_parent_id()),
1243 1243
 
1244 1244
         );
1245 1245
 
1246 1246
     }
1247 1247
 
1248 1248
     
1249
-    if ( $invoice->is_recurring() ) {
1249
+    if ($invoice->is_recurring()) {
1250 1250
 
1251
-        $subscription = getpaid_get_invoice_subscriptions( $invoice );
1252
-        if ( ! empty ( $subscription ) && ! is_array( $subscription ) && $subscription->exists() ) {
1251
+        $subscription = getpaid_get_invoice_subscriptions($invoice);
1252
+        if (!empty ($subscription) && !is_array($subscription) && $subscription->exists()) {
1253 1253
 
1254 1254
             // Display the renewal date.
1255
-            if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) {
1255
+            if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) {
1256 1256
 
1257
-                $meta[ 'renewal_date' ] = array(
1258
-                    'label' => __( 'Renews On', 'invoicing' ),
1259
-                    'value' => getpaid_format_date( $subscription->get_expiration() ) . 
1257
+                $meta['renewal_date'] = array(
1258
+                    'label' => __('Renews On', 'invoicing'),
1259
+                    'value' => getpaid_format_date($subscription->get_expiration()) . 
1260 1260
                     sprintf(
1261 1261
                        ' <a class="small" href="%s">%s<a>',
1262 1262
                        $subscription->get_view_url(),
1263
-                       __( '(View Subscription)', 'invoicing' )
1263
+                       __('(View Subscription)', 'invoicing')
1264 1264
                     ),
1265 1265
                 );
1266 1266
 
1267 1267
             }
1268 1268
 
1269
-            if ( $invoice->is_parent() ) {
1269
+            if ($invoice->is_parent()) {
1270 1270
 
1271 1271
                 // Display the recurring amount.
1272
-                $meta[ 'recurring_total' ] = array(
1272
+                $meta['recurring_total'] = array(
1273 1273
 
1274
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
1275
-                    'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ),
1274
+                    'label' => __('Recurring Amount', 'invoicing'),
1275
+                    'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()),
1276 1276
 
1277 1277
                 );
1278 1278
 
@@ -1282,15 +1282,15 @@  discard block
 block discarded – undo
1282 1282
     }
1283 1283
 
1284 1284
     // Add the invoice total to the meta.
1285
-    $meta[ 'invoice_total' ] = array(
1285
+    $meta['invoice_total'] = array(
1286 1286
 
1287
-        'label' => __( 'Total Amount', 'invoicing' ),
1288
-        'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
1287
+        'label' => __('Total Amount', 'invoicing'),
1288
+        'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
1289 1289
 
1290 1290
     );
1291 1291
 
1292 1292
     // Provide a way for third party plugins to filter the meta.
1293
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
1293
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
1294 1294
 
1295 1295
     return $meta;
1296 1296
 
@@ -1329,12 +1329,12 @@  discard block
 block discarded – undo
1329 1329
  * @param GetPaid_Form_Item $item
1330 1330
  * @return float
1331 1331
  */
1332
-function getpaid_get_invoice_tax_rate( $invoice, $item ) {
1332
+function getpaid_get_invoice_tax_rate($invoice, $item) {
1333 1333
 
1334
-    $rates   = getpaid_get_item_tax_rates( $item, $invoice->get_country(), $invoice->get_state() );
1335
-	$rates   = getpaid_filter_item_tax_rates( $item, $rates );
1336
-    $rates   = wp_list_pluck( $rates, 'rate' );
1334
+    $rates   = getpaid_get_item_tax_rates($item, $invoice->get_country(), $invoice->get_state());
1335
+	$rates = getpaid_filter_item_tax_rates($item, $rates);
1336
+    $rates   = wp_list_pluck($rates, 'rate');
1337 1337
 
1338
-    return array_sum( $rates );
1338
+    return array_sum($rates);
1339 1339
 
1340 1340
 }
Please login to merge, or discard this patch.
includes/class-getpaid-invoice-notification-emails.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles invoice notificaiton emails.
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$this->invoice_actions = apply_filters(
29 29
 			'getpaid_notification_email_invoice_triggers',
30 30
 			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
31
+				'getpaid_new_invoice'                   => array('new_invoice', 'user_invoice'),
32 32
 				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33 33
 				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34 34
 				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function init_hooks() {
52 52
 
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
53
+		add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2);
54
+		add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2);
55 55
 
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
56
+		foreach ($this->invoice_actions as $hook => $email_type) {
57
+			$this->init_email_type_hook($hook, $email_type);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,25 +64,25 @@  discard block
 block discarded – undo
64 64
 	 * @param string $hook
65 65
 	 * @param string|array $email_type
66 66
 	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
67
+	public function init_email_type_hook($hook, $email_type) {
68 68
 
69
-		$email_type = wpinv_parse_list( $email_type );
69
+		$email_type = wpinv_parse_list($email_type);
70 70
 
71
-		foreach ( $email_type as $type ) {
71
+		foreach ($email_type as $type) {
72 72
 
73
-			$email = new GetPaid_Notification_Email( $type );
73
+			$email = new GetPaid_Notification_Email($type);
74 74
 
75 75
 			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
76
+			if (!$email->is_active()) {
77 77
 				continue;
78 78
 			}
79 79
 
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
80
+			if (method_exists($this, $type)) {
81
+				add_action($hook, array($this, $type), 100, 2);
82 82
 				continue;
83 83
 			}
84 84
 
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
85
+			do_action('getpaid_invoice_init_email_type_hook', $type, $hook);
86 86
 		}
87 87
 
88 88
 	}
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 * @param array $merge_tags
94 94
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95 95
 	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
96
+	public function invoice_merge_tags($merge_tags, $object) {
97 97
 
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
98
+		if (is_a($object, 'WPInv_Invoice')) {
99 99
 			return array_merge(
100 100
 				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
101
+				$this->get_invoice_merge_tags($object)
102 102
 			);
103 103
 		}
104 104
 
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
105
+		if (is_a($object, 'WPInv_Subscription')) {
106 106
 			return array_merge(
107 107
 				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
108
+				$this->get_invoice_merge_tags($object->get_parent_payment())
109 109
 			);
110 110
 		}
111 111
 
@@ -119,52 +119,52 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
122
+	public function get_invoice_merge_tags($invoice) {
123 123
 
124 124
 		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
125
+		if (!$invoice->get_id()) {
126 126
 			return array();
127 127
 		}
128 128
 
129 129
 		$merge_tags = array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
130
+			'{name}'                => sanitize_text_field($invoice->get_user_full_name()),
131
+			'{full_name}'           => sanitize_text_field($invoice->get_user_full_name()),
132
+			'{first_name}'          => sanitize_text_field($invoice->get_first_name()),
133
+			'{last_name}'           => sanitize_text_field($invoice->get_last_name()),
134
+			'{email}'               => sanitize_email($invoice->get_email()),
135
+			'{invoice_number}'      => sanitize_text_field($invoice->get_number()),
136
+			'{invoice_currency}'    => sanitize_text_field($invoice->get_currency()),
137
+			'{invoice_total}'       => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())),
138
+			'{invoice_link}'        => esc_url($invoice->get_view_url()),
139
+			'{invoice_pay_link}'    => esc_url($invoice->get_checkout_payment_url()),
140
+			'{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()),
141
+			'{invoice_date}'        => getpaid_format_date_value($invoice->get_date_created()),
142
+			'{invoice_due_date}'    => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')),
143
+			'{invoice_quote}'       => sanitize_text_field(strtolower($invoice->get_label())),
144
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_label())),
145
+			'{invoice_description}' => wp_kses_post($invoice->get_description()),
146
+			'{subscription_name}'   => wp_kses_post($invoice->get_subscription_name()),
147
+			'{is_was}'              => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
148 148
 		);
149 149
 
150
-		$payment_form_data = $invoice->get_meta( 'payment_form_data', true );
150
+		$payment_form_data = $invoice->get_meta('payment_form_data', true);
151 151
 
152
-		if ( is_array( $payment_form_data ) ) {
152
+		if (is_array($payment_form_data)) {
153 153
 
154
-			foreach ( $payment_form_data as $label => $value ) {
154
+			foreach ($payment_form_data as $label => $value) {
155 155
 
156
-				$label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
-				$value = is_array( $value ) ? implode( ', ', $value ) : $value;
156
+				$label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label));
157
+				$value = is_array($value) ? implode(', ', $value) : $value;
158 158
 
159
-				if ( is_scalar ( $value ) ) {
160
-					$merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
159
+				if (is_scalar($value)) {
160
+					$merge_tags["{{$label}}"] = wp_kses_post($value);
161 161
 				}
162 162
 
163 163
 			}
164 164
 
165 165
 		}
166 166
 
167
-		return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
167
+		return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice);
168 168
 	}
169 169
 
170 170
 	/**
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 	 * @param string|array $recipients
177 177
 	 * @param array $extra_args Extra template args.
178 178
 	 */
179
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
179
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
180 180
 
181
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
181
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
182 182
 
183
-		$skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
-		if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
183
+		$skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice');
184
+		if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) {
185 185
 			return;
186 186
 		}
187 187
 
@@ -189,41 +189,41 @@  discard block
 block discarded – undo
189 189
 		$merge_tags = $email->get_merge_tags();
190 190
 
191 191
 		$result = $mailer->send(
192
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
-			$email->get_content( $merge_tags, $extra_args ),
192
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
193
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
194
+			$email->get_content($merge_tags, $extra_args),
195 195
 			$email->get_attachments()
196 196
 		);
197 197
 
198 198
 		// Maybe send a copy to the admin.
199
-		if ( $email->include_admin_bcc() ) {
199
+		if ($email->include_admin_bcc()) {
200 200
 			$mailer->send(
201 201
 				wpinv_get_admin_email(),
202
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
-				$email->get_content( $merge_tags ),
202
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
203
+				$email->get_content($merge_tags),
204 204
 				$email->get_attachments()
205 205
 			);
206 206
 		}
207 207
 
208
-		if ( $result ) {
208
+		if ($result) {
209 209
 			$invoice->add_system_note(
210 210
 				sprintf(
211
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
-					sanitize_key( $type ),
213
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
211
+					__('Successfully sent %s notification email to %s.', 'invoicing'),
212
+					sanitize_key($type),
213
+					$email->is_admin_email() ? __('admin') : __('the customer')
214 214
 				)
215 215
 			);
216 216
 		} else {
217 217
 			$invoice->add_system_note(
218 218
 				sprintf(
219
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
-					sanitize_key( $type ),
221
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
219
+					__('Failed sending %s notification email to %s.', 'invoicing'),
220
+					sanitize_key($type),
221
+					$email->is_admin_email() ? __('admin') : __('the customer')
222 222
 				)
223 223
 			);	
224 224
 		}
225 225
 
226
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
226
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
227 227
 
228 228
 		return $result;
229 229
 	}
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 	 * @param array $recipients
235 235
 	 * @param GetPaid_Notification_Email $email
236 236
 	 */
237
-	public function filter_email_recipients( $recipients, $email ) {
237
+	public function filter_email_recipients($recipients, $email) {
238 238
 
239
-		if ( ! $email->is_admin_email() ) {
239
+		if (!$email->is_admin_email()) {
240 240
 			$cc   = $email->object->get_email_cc();
241
-			$cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
241
+			$cc_2 = get_user_meta($email->object->get_user_id(), '_wpinv_email_cc', true);
242 242
 
243
-			if ( ! empty( $cc ) ) {
244
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
243
+			if (!empty($cc)) {
244
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
245
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
246 246
 			}
247 247
 
248
-			if ( ! empty( $cc_2 ) ) {
249
-				$cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
248
+			if (!empty($cc_2)) {
249
+				$cc_2 = array_map('sanitize_email', wpinv_parse_list($cc_2));
250
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc_2)));
251 251
 			}
252 252
 
253 253
 		}
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param WPInv_Invoice $invoice
263 263
 	 */
264
-	public function new_invoice( $invoice ) {
264
+	public function new_invoice($invoice) {
265 265
 
266 266
 		// Only send this email for invoices created via the admin page.
267
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
267
+		if (!$invoice->is_type('invoice') || $invoice->is_paid() || $this->is_payment_form_invoice($invoice->get_id())) {
268 268
 			return;
269 269
 		}
270 270
 
271
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
271
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
272 272
 		$recipient = wpinv_get_admin_email();
273 273
 
274
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
274
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
275 275
 
276 276
 	}
277 277
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param WPInv_Invoice $invoice
282 282
 	 */
283
-	public function cancelled_invoice( $invoice ) {
283
+	public function cancelled_invoice($invoice) {
284 284
 
285
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
285
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
286 286
 		$recipient = $invoice->get_email();
287 287
 
288
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
288
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
289 289
 	}
290 290
 
291 291
 	/**
@@ -293,12 +293,12 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @param WPInv_Invoice $invoice
295 295
 	 */
296
-	public function failed_invoice( $invoice ) {
296
+	public function failed_invoice($invoice) {
297 297
 
298
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
298
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
299 299
 		$recipient = wpinv_get_admin_email();
300 300
 
301
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
301
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
302 302
 
303 303
 	}
304 304
 
@@ -307,12 +307,12 @@  discard block
 block discarded – undo
307 307
 	 *
308 308
 	 * @param WPInv_Invoice $invoice
309 309
 	 */
310
-	public function onhold_invoice( $invoice ) {
310
+	public function onhold_invoice($invoice) {
311 311
 
312
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
312
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
313 313
 		$recipient = $invoice->get_email();
314 314
 
315
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
315
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
316 316
 
317 317
 	}
318 318
 
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
 	 *
322 322
 	 * @param WPInv_Invoice $invoice
323 323
 	 */
324
-	public function processing_invoice( $invoice ) {
324
+	public function processing_invoice($invoice) {
325 325
 
326
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
326
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
327 327
 		$recipient = $invoice->get_email();
328 328
 
329
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
329
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
330 330
 
331 331
 	}
332 332
 
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
 	 *
336 336
 	 * @param WPInv_Invoice $invoice
337 337
 	 */
338
-	public function completed_invoice( $invoice ) {
338
+	public function completed_invoice($invoice) {
339 339
 
340 340
 		// (Maybe) abort if it is a renewal invoice.
341
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
341
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
342 342
 			return;
343 343
 		}
344 344
 
345
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
345
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
346 346
 		$recipient = $invoice->get_email();
347 347
 
348
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
348
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
349 349
 
350 350
 	}
351 351
 
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @param WPInv_Invoice $invoice
356 356
 	 */
357
-	public function refunded_invoice( $invoice ) {
357
+	public function refunded_invoice($invoice) {
358 358
 
359
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
359
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
360 360
 		$recipient = $invoice->get_email();
361 361
 
362
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
362
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
363 363
 
364 364
 	}
365 365
 
@@ -369,21 +369,21 @@  discard block
 block discarded – undo
369 369
 	 * @param WPInv_Invoice $invoice
370 370
 	 * @param bool $force
371 371
 	 */
372
-	public function user_invoice( $invoice, $force = false ) {
372
+	public function user_invoice($invoice, $force = false) {
373 373
 
374
-		if ( ! $force && ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
374
+		if (!$force && !empty($GLOBALS['wpinv_skip_invoice_notification'])) {
375 375
 			return;
376 376
 		}
377 377
 
378 378
 		// Only send this email for invoices created via the admin page.
379
-		if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $invoice->is_paid() ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
379
+		if (!$invoice->is_type('invoice') || (empty($force) && $invoice->is_paid()) || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) {
380 380
 			return;
381 381
 		}
382 382
 
383
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
383
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
384 384
 		$recipient = $invoice->get_email();
385 385
 
386
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
386
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
387 387
 
388 388
 	}
389 389
 
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 	 * @param int $invoice
394 394
 	 * @return bool
395 395
 	 */
396
-	public function is_payment_form_invoice( $invoice ) {
397
-		$is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' === get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' === get_post_meta( $invoice, 'wpinv_created_via', true ) );
398
-		return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
396
+	public function is_payment_form_invoice($invoice) {
397
+		$is_payment_form_invoice = empty($_GET['getpaid-admin-action']) && ('payment_form' === get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' === get_post_meta($invoice, 'wpinv_created_via', true));
398
+		return apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice);
399 399
 	}
400 400
 
401 401
 	/**
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	 * @param WPInv_Invoice $invoice
405 405
 	 * @param string $note
406 406
 	 */
407
-	public function user_note( $invoice, $note ) {
407
+	public function user_note($invoice, $note) {
408 408
 
409
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
409
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
410 410
 		$recipient = $invoice->get_email();
411 411
 
412
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
412
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
413 413
 
414 414
 	}
415 415
 
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @param WPInv_Invoice $invoice
420 420
 	 */
421
-	public function force_send_overdue_notice( $invoice ) {
422
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
423
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
421
+	public function force_send_overdue_notice($invoice) {
422
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
423
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
424 424
 	}
425 425
 
426 426
 	/**
@@ -431,37 +431,37 @@  discard block
 block discarded – undo
431 431
 	public function overdue() {
432 432
 		global $wpdb;
433 433
 
434
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
434
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
435 435
 
436 436
 		// Fetch reminder days.
437
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
437
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
438 438
 
439 439
 		// Abort if non is set.
440
-		if ( empty( $reminder_days ) ) {
440
+		if (empty($reminder_days)) {
441 441
 			return;
442 442
 		}
443 443
 
444 444
 		// Retrieve date query.
445
-		$date_query = $this->get_date_query( $reminder_days );
445
+		$date_query = $this->get_date_query($reminder_days);
446 446
 
447 447
 		// Invoices table.
448 448
 		$table = $wpdb->prefix . 'getpaid_invoices';
449 449
 
450 450
 		// Fetch invoices.
451
-		$invoices  = $wpdb->get_col(
451
+		$invoices = $wpdb->get_col(
452 452
 			"SELECT posts.ID FROM $wpdb->posts as posts
453 453
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
454 454
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
455 455
 
456
-		foreach ( $invoices as $invoice ) {
456
+		foreach ($invoices as $invoice) {
457 457
 
458 458
 			// Only send this email for invoices created via the admin page.
459
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
460
-				$invoice       = new WPInv_Invoice( $invoice );
459
+			if (!$this->is_payment_form_invoice($invoice)) {
460
+				$invoice       = new WPInv_Invoice($invoice);
461 461
 				$email->object = $invoice;
462 462
 
463
-				if ( $invoice->needs_payment() ) {
464
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
463
+				if ($invoice->needs_payment()) {
464
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
465 465
 				}
466 466
 
467 467
 			}
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 	 * @param array $reminder_days
477 477
 	 * @return string
478 478
 	 */
479
-	public function get_date_query( $reminder_days ) {
479
+	public function get_date_query($reminder_days) {
480 480
 
481 481
 		$date_query = array(
482 482
 			'relation'  => 'OR'
483 483
 		);
484 484
 
485
-		foreach ( $reminder_days as $days ) {
486
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
485
+		foreach ($reminder_days as $days) {
486
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
487 487
 
488 488
 			$date_query[] = array(
489 489
 				'year'  => $date['year'],
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 
494 494
 		}
495 495
 
496
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
496
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
497 497
 
498 498
 		return $date_query->get_sql();
499 499
 
Please login to merge, or discard this patch.