Passed
Push — master ( 55fff1...2692d4 )
by Brian
16:18
created
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
 		 * @return WP_Font_Awesome_Settings - Main instance.
97 97
 		 */
98 98
 		public static function instance() {
99
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
99
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
100 100
 				self::$instance = new WP_Font_Awesome_Settings;
101 101
 
102
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
102
+				add_action('init', array(self::$instance, 'init')); // set settings
103 103
 
104
-				if ( is_admin() ) {
105
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
106
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
107
-					add_action( 'admin_init', array( self::$instance, 'constants' ) );
108
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
104
+				if (is_admin()) {
105
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
106
+					add_action('admin_init', array(self::$instance, 'register_settings'));
107
+					add_action('admin_init', array(self::$instance, 'constants'));
108
+					add_action('admin_notices', array(self::$instance, 'admin_notices'));
109 109
 				}
110 110
 
111
-				do_action( 'wp_font_awesome_settings_loaded' );
111
+				do_action('wp_font_awesome_settings_loaded');
112 112
 			}
113 113
 
114 114
 			return self::$instance;
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
          *
120 120
 		 * @return void
121 121
 		 */
122
-		public function constants(){
122
+		public function constants() {
123 123
 
124 124
 			// register iconpicker constant
125
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
125
+			if (!defined('FAS_ICONPICKER_JS_URL')) {
126 126
 				$url = $this->get_path_url();
127 127
 				$version = $this->settings['version'];
128 128
 
129
-				if( !$version || version_compare($version,'5.999','>')){
129
+				if (!$version || version_compare($version, '5.999', '>')) {
130 130
 					$url .= 'assets/js/fa-iconpicker-v6.min.js';
131
-				}else{
131
+				} else {
132 132
 					$url .= 'assets/js/fa-iconpicker-v5.min.js';
133 133
 				}
134 134
 
135
-				define( 'FAS_ICONPICKER_JS_URL', $url );
135
+				define('FAS_ICONPICKER_JS_URL', $url);
136 136
 
137 137
 			}
138 138
 
139 139
             // Set a constant if pro enbaled
140
-			if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
141
-				define( 'FAS_PRO', true );
140
+			if (!defined('FAS_PRO') && $this->settings['pro']) {
141
+				define('FAS_PRO', true);
142 142
 			}
143 143
 		}
144 144
 
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 		 * @return string
149 149
 		 */
150 150
 		public function get_path_url() {
151
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
152
-			$content_url = untrailingslashit( WP_CONTENT_URL );
151
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
152
+			$content_url = untrailingslashit(WP_CONTENT_URL);
153 153
 
154 154
 			// Replace http:// to https://.
155
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
156
-				$content_url = str_replace( 'http://', 'https://', $content_url );
155
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
156
+				$content_url = str_replace('http://', 'https://', $content_url);
157 157
 			}
158 158
 
159 159
 			// Check if we are inside a plugin
160
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
161
-			$url = str_replace( $content_dir, $content_url, $file_dir );
160
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
161
+			$url = str_replace($content_dir, $content_url, $file_dir);
162 162
 
163
-			return trailingslashit( $url );
163
+			return trailingslashit($url);
164 164
 		}
165 165
 
166 166
 		/**
@@ -170,41 +170,41 @@  discard block
 block discarded – undo
170 170
 		 */
171 171
 		public function init() {
172 172
 			// Download fontawesome locally.
173
-			add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
174
-			add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
173
+			add_action('add_option_wp-font-awesome-settings', array($this, 'add_option_wp_font_awesome_settings'), 10, 2);
174
+			add_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2);
175 175
 
176 176
 			$this->settings = $this->get_settings();
177 177
 
178 178
 			// check if the official plugin is active and use that instead if so.
179
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
179
+			if (!defined('FONTAWESOME_PLUGIN_FILE')) {
180 180
 
181
-				if ( $this->settings['type'] == 'CSS' ) {
181
+				if ($this->settings['type'] == 'CSS') {
182 182
 
183
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
184
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
183
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
184
+						add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
185 185
 //						add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
186 186
 					}
187 187
 
188
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
189
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
190
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
188
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
189
+						add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
190
+						add_filter('block_editor_settings_all', array($this, 'enqueue_editor_styles'), 10, 2);
191 191
 					}
192 192
 
193 193
 				} else {
194 194
 
195
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
196
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
195
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
196
+						add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
197 197
 					}
198 198
 
199
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
200
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
201
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
199
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
200
+						add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
201
+						add_filter('block_editor_settings_all', array($this, 'enqueue_editor_scripts'), 10, 2);
202 202
 					}
203 203
 				}
204 204
 
205 205
 				// remove font awesome if set to do so
206
-				if ( $this->settings['dequeue'] == '1' ) {
207
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
206
+				if ($this->settings['dequeue'] == '1') {
207
+					add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
208 208
 				}
209 209
 			}
210 210
 
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 		 *
219 219
 		 * @return array
220 220
 		 */
221
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
221
+		public function enqueue_editor_styles($editor_settings, $block_editor_context) {
222 222
 
223
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
223
+			if (!empty($editor_settings['__unstableResolvedAssets']['styles'])) {
224 224
 				$url = $this->get_url();
225 225
 				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
226 226
 			}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		 *
237 237
 		 * @return array
238 238
 		 */
239
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
239
+		public function enqueue_editor_scripts($editor_settings, $block_editor_context) {
240 240
 
241 241
 			$url = $this->get_url();
242 242
 			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
@@ -250,22 +250,22 @@  discard block
 block discarded – undo
250 250
 		public function enqueue_style() {
251 251
 			// build url
252 252
 			$url = $this->get_url();
253
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
253
+			$version = !empty($this->settings['local']) && empty($this->settings['pro']) ? strip_tags($this->settings['local_version']) : null;
254 254
 
255
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
256
-			wp_register_style( 'font-awesome', $url, array(), $version );
257
-			wp_enqueue_style( 'font-awesome' );
255
+			wp_deregister_style('font-awesome'); // deregister in case its already there
256
+			wp_register_style('font-awesome', $url, array(), $version);
257
+			wp_enqueue_style('font-awesome');
258 258
 
259 259
 			// RTL language support CSS.
260
-			if ( is_rtl() ) {
261
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
260
+			if (is_rtl()) {
261
+				wp_add_inline_style('font-awesome', $this->rtl_inline_css());
262 262
 			}
263 263
 
264
-			if ( $this->settings['shims'] ) {
265
-				$url = $this->get_url( true );
266
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
267
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
268
-				wp_enqueue_style( 'font-awesome-shims' );
264
+			if ($this->settings['shims']) {
265
+				$url = $this->get_url(true);
266
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
267
+				wp_register_style('font-awesome-shims', $url, array(), $version);
268
+				wp_enqueue_style('font-awesome-shims');
269 269
 			}
270 270
 		}
271 271
 
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 			$url = $this->get_url();
278 278
 
279 279
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
280
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
281
-			wp_register_script( 'font-awesome', $url, array(), null );
282
-			wp_enqueue_script( 'font-awesome' );
280
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
281
+			wp_register_script('font-awesome', $url, array(), null);
282
+			wp_enqueue_script('font-awesome');
283 283
 
284
-			if ( $this->settings['shims'] ) {
285
-				$url = $this->get_url( true );
286
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
287
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
288
-				wp_enqueue_script( 'font-awesome-shims' );
284
+			if ($this->settings['shims']) {
285
+				$url = $this->get_url(true);
286
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
287
+				wp_register_script('font-awesome-shims', $url, array(), null);
288
+				wp_enqueue_script('font-awesome-shims');
289 289
 			}
290 290
 		}
291 291
 
@@ -297,16 +297,16 @@  discard block
 block discarded – undo
297 297
 		 *
298 298
 		 * @return string The url to the file.
299 299
 		 */
300
-		public function get_url( $shims = false, $local = true ) {
300
+		public function get_url($shims = false, $local = true) {
301 301
 			$script  = $shims ? 'v4-shims' : 'all';
302 302
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
303 303
 			$type    = $this->settings['type'];
304 304
 			$version = $this->settings['version'];
305
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
305
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
306 306
 			$url     = '';
307 307
 
308
-			if ( $type == 'KIT' && $kit_url ) {
309
-				if ( $shims ) {
308
+			if ($type == 'KIT' && $kit_url) {
309
+				if ($shims) {
310 310
 					// if its a kit then we don't add shims here
311 311
 					return '';
312 312
 				}
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
 			} else {
316 316
 				$v = '';
317 317
 				// Check and load locally.
318
-				if ( $local && $this->has_local() ) {
318
+				if ($local && $this->has_local()) {
319 319
 					$script .= ".min";
320
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
320
+					$v .= '&ver=' . strip_tags($this->settings['local_version']);
321 321
 					$url .= $this->get_fonts_url(); // Local fonts url.
322 322
 				} else {
323 323
 					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
324
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
324
+					$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
325 325
 				}
326 326
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
327 327
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
 		 *
343 343
 		 * @return string The filtered url.
344 344
 		 */
345
-		public function remove_font_awesome( $url, $original_url, $_context ) {
345
+		public function remove_font_awesome($url, $original_url, $_context) {
346 346
 
347
-			if ( $_context == 'display'
348
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
349
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
347
+			if ($_context == 'display'
348
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
349
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
350 350
 			) {// it's a font-awesome-url (probably)
351 351
 
352
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
353
-					if ( $this->settings['type'] == 'JS' ) {
354
-						if ( $this->settings['js-pseudo'] ) {
352
+				if (strstr($url, "wpfas=true") !== false) {
353
+					if ($this->settings['type'] == 'JS') {
354
+						if ($this->settings['js-pseudo']) {
355 355
 							$url .= "' data-search-pseudo-elements defer='defer";
356 356
 						} else {
357 357
 							$url .= "' defer='defer";
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 		 * Register the database settings with WordPress.
371 371
 		 */
372 372
 		public function register_settings() {
373
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
373
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
374 374
 		}
375 375
 
376 376
 		/**
@@ -379,10 +379,10 @@  discard block
 block discarded – undo
379 379
 		 */
380 380
 		public function menu_item() {
381 381
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
382
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
382
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
383 383
 				$this,
384 384
 				'settings_page'
385
-			) );
385
+			));
386 386
 		}
387 387
 
388 388
 		/**
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		 * @return array The array of settings.
392 392
 		 */
393 393
 		public function get_settings() {
394
-			$db_settings = get_option( 'wp-font-awesome-settings' );
394
+			$db_settings = get_option('wp-font-awesome-settings');
395 395
 
396 396
 			$defaults = array(
397 397
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -406,30 +406,30 @@  discard block
 block discarded – undo
406 406
 				'kit-url'   => '', // the kit url
407 407
 			);
408 408
 
409
-			$settings = wp_parse_args( $db_settings, $defaults );
409
+			$settings = wp_parse_args($db_settings, $defaults);
410 410
 
411 411
 			/**
412 412
 			 * Filter the Font Awesome settings.
413 413
 			 *
414 414
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
415 415
 			 */
416
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
416
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
417 417
 		}
418 418
 
419 419
 		/**
420 420
 		 * The settings page html output.
421 421
 		 */
422 422
 		public function settings_page() {
423
-			if ( ! current_user_can( 'manage_options' ) ) {
424
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) );
423
+			if (!current_user_can('manage_options')) {
424
+				wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings'));
425 425
 			}
426 426
 
427 427
 			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
428
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
429
-				$this->get_latest_version( $force_api = true );
428
+			if (isset($_REQUEST['force-version-check'])) {
429
+				$this->get_latest_version($force_api = true);
430 430
 			}
431 431
 
432
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
432
+			if (!defined('FONTAWESOME_PLUGIN_FILE')) {
433 433
 				?>
434 434
                 <style>
435 435
                     .wpfas-kit-show {
@@ -456,42 +456,42 @@  discard block
 block discarded – undo
456 456
                     <h1><?php echo $this->name; ?></h1>
457 457
                     <form method="post" action="options.php" class="fas-settings-form">
458 458
 						<?php
459
-						settings_fields( 'wp-font-awesome-settings' );
460
-						do_settings_sections( 'wp-font-awesome-settings' );
459
+						settings_fields('wp-font-awesome-settings');
460
+						do_settings_sections('wp-font-awesome-settings');
461 461
 						$table_class = '';
462
-						if ( $this->settings['type'] ) {
463
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
462
+						if ($this->settings['type']) {
463
+							$table_class .= 'wpfas-' . sanitize_html_class(strtolower($this->settings['type'])) . '-set';
464 464
 						}
465
-						if ( ! empty( $this->settings['pro'] ) ) {
465
+						if (!empty($this->settings['pro'])) {
466 466
 							$table_class .= ' wpfas-has-pro';
467 467
 						}
468 468
 						?>
469
-						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
470
-							<?php if ( $this->has_local() ) { ?>
471
-                                <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'font-awesome-settings' ); ?></strong></p></div>
469
+						<?php if ($this->settings['type'] != 'KIT' && !empty($this->settings['local']) && empty($this->settings['pro'])) { ?>
470
+							<?php if ($this->has_local()) { ?>
471
+                                <div class="notice notice-info"><p><strong><?php _e('Font Awesome fonts are loading locally.', 'font-awesome-settings'); ?></strong></p></div>
472 472
 							<?php } else { ?>
473
-                                <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'font-awesome-settings' ); ?></strong></p></div>
473
+                                <div class="notice notice-error"><p><strong><?php _e('Font Awesome fonts are not loading locally!', 'font-awesome-settings'); ?></strong></p></div>
474 474
 							<?php } ?>
475 475
 						<?php } ?>
476
-                        <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>">
476
+                        <table class="form-table wpfas-table-settings <?php echo esc_attr($table_class); ?>">
477 477
                             <tr valign="top">
478
-                                <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th>
478
+                                <th scope="row"><label for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th>
479 479
                                 <td>
480 480
                                     <select name="wp-font-awesome-settings[type]" id="wpfas-type" onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}">
481
-                                        <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option>
482
-                                        <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
483
-                                        <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option>
481
+                                        <option value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option>
482
+                                        <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
483
+                                        <option value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option>
484 484
                                     </select>
485 485
                                 </td>
486 486
                             </tr>
487 487
 
488 488
                             <tr valign="top" class="wpfas-kit-show">
489
-                                <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th>
489
+                                <th scope="row"><label for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th>
490 490
                                 <td>
491
-                                    <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
491
+                                    <input class="regular-text" id="wpfas-kit-url" type="url" name="wp-font-awesome-settings[kit-url]" value="<?php echo esc_attr($this->settings['kit-url']); ?>" placeholder="<?php echo 'https://kit.font'; echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/>
492 492
                                     <span><?php
493 493
 										echo sprintf(
494
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ),
494
+											__('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'),
495 495
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
496 496
 											'</a>'
497 497
 										);
@@ -500,44 +500,44 @@  discard block
 block discarded – undo
500 500
                             </tr>
501 501
 
502 502
                             <tr valign="top" class="wpfas-kit-hide">
503
-                                <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th>
503
+                                <th scope="row"><label for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th>
504 504
                                 <td>
505 505
                                     <select name="wp-font-awesome-settings[version]" id="wpfas-version">
506
-                                        <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?></option>
507
-                                        <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option>
508
-                                        <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option>
509
-                                        <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option>
510
-                                        <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option>
511
-                                        <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option>
512
-                                        <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option>
513
-                                        <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option>
514
-                                        <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option>
515
-                                        <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option>
516
-                                        <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option>
506
+                                        <option value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?></option>
507
+                                        <option value="6.1.0" <?php selected($this->settings['version'], '6.1.0'); ?>>6.1.0</option>
508
+                                        <option value="6.0.0" <?php selected($this->settings['version'], '6.0.0'); ?>>6.0.0</option>
509
+                                        <option value="5.15.4" <?php selected($this->settings['version'], '5.15.4'); ?>>5.15.4</option>
510
+                                        <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>5.6.0</option>
511
+                                        <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>5.5.0</option>
512
+                                        <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>5.4.0</option>
513
+                                        <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>5.3.0</option>
514
+                                        <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>5.2.0</option>
515
+                                        <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>5.1.0</option>
516
+                                        <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>4.7.1 (CSS only)</option>
517 517
                                     </select>
518 518
                                 </td>
519 519
                             </tr>
520 520
 
521 521
                             <tr valign="top">
522
-                                <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th>
522
+                                <th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th>
523 523
                                 <td>
524 524
                                     <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
525
-                                        <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option>
526
-                                        <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option>
527
-                                        <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option>
525
+                                        <option value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option>
526
+                                        <option value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option>
527
+                                        <option value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option>
528 528
                                     </select>
529 529
                                 </td>
530 530
                             </tr>
531 531
 
532 532
                             <tr valign="top" class="wpfas-kit-hide">
533 533
                                 <th scope="row"><label
534
-                                            for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th>
534
+                                            for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th>
535 535
                                 <td>
536 536
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
537
-                                    <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/>
537
+                                    <input type="checkbox" name="wp-font-awesome-settings[pro]" value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro" onchange="if(jQuery(this).is(':checked')){jQuery('.wpfas-table-settings').addClass('wpfas-has-pro')}else{jQuery('.wpfas-table-settings').removeClass('wpfas-has-pro')}"/>
538 538
                                     <span><?php
539 539
 										echo wp_sprintf(
540
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'font-awesome-settings' ),
540
+											__('Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'font-awesome-settings'),
541 541
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
542 542
 											' <i class="fas fa-external-link-alt"></i></a>',
543 543
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
@@ -548,49 +548,49 @@  discard block
 block discarded – undo
548 548
                             </tr>
549 549
 
550 550
                             <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro">
551
-                                <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'font-awesome-settings' ); ?></label></th>
551
+                                <th scope="row"><label for="wpfas-local"><?php _e('Load Fonts Locally', 'font-awesome-settings'); ?></label></th>
552 552
                                 <td>
553 553
                                     <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/>
554
-                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/>
555
-                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/>
556
-                                    <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'font-awesome-settings' ); ?></span>
554
+                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr($this->settings['local_version']); ?>"/>
555
+                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked($this->settings['local'], '1'); ?> id="wpfas-local"/>
556
+                                    <span><?php _e('(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'font-awesome-settings'); ?></span>
557 557
                                 </td>
558 558
                             </tr>
559 559
 
560 560
                             <tr valign="top" class="wpfas-kit-hide">
561 561
                                 <th scope="row"><label
562
-                                            for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label>
562
+                                            for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label>
563 563
                                 </th>
564 564
                                 <td>
565 565
                                     <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
566 566
                                     <input type="checkbox" name="wp-font-awesome-settings[shims]"
567
-                                           value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
568
-                                    <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span>
567
+                                           value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
568
+                                    <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span>
569 569
                                 </td>
570 570
                             </tr>
571 571
 
572 572
                             <tr valign="top" class="wpfas-kit-hide">
573 573
                                 <th scope="row"><label
574
-                                            for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label>
574
+                                            for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label>
575 575
                                 </th>
576 576
                                 <td>
577 577
                                     <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
578 578
                                     <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
579
-                                           value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
579
+                                           value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
580 580
                                            id="wpfas-js-pseudo"/>
581
-                                    <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span>
581
+                                    <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span>
582 582
                                 </td>
583 583
                             </tr>
584 584
 
585 585
                             <tr valign="top">
586 586
                                 <th scope="row"><label
587
-                                            for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th>
587
+                                            for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th>
588 588
                                 <td>
589 589
                                     <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
590 590
                                     <input type="checkbox" name="wp-font-awesome-settings[dequeue]"
591
-                                           value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
591
+                                           value="1" <?php checked($this->settings['dequeue'], '1'); ?>
592 592
                                            id="wpfas-dequeue"/>
593
-                                    <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span>
593
+                                    <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span>
594 594
                                 </td>
595 595
                             </tr>
596 596
 
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 							<?php
600 600
 							submit_button();
601 601
 							?>
602
-                            <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro','font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p>
602
+                            <p class="submit"><a href="https://fontawesome.com/referral?a=c9b89e1418" class="button button-secondary"><?php _e('Get 24,000+ more icons with Font Awesome Pro', 'font-awesome-settings'); ?> <i class="fas fa-external-link-alt"></i></a></p>
603 603
 
604 604
                         </div>
605 605
                     </form>
606 606
 
607
-                    <div id="wpfas-version"><?php echo sprintf(__( 'Version: %s (affiliate links provided)', 'font-awesome-settings' ), $this->version ); ?></div>
607
+                    <div id="wpfas-version"><?php echo sprintf(__('Version: %s (affiliate links provided)', 'font-awesome-settings'), $this->version); ?></div>
608 608
                 </div>
609 609
 				<?php
610 610
 			}
@@ -619,12 +619,12 @@  discard block
 block discarded – undo
619 619
 		 *
620 620
 		 * @return string Either a valid version number or an empty string.
621 621
 		 */
622
-		public function validate_version_number( $version ) {
622
+		public function validate_version_number($version) {
623 623
 
624
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
624
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
625 625
 				// valid
626 626
 			} else {
627
-				$version = '';// not validated
627
+				$version = ''; // not validated
628 628
 			}
629 629
 
630 630
 			return $version;
@@ -639,27 +639,27 @@  discard block
 block discarded – undo
639 639
 		 * @since 1.0.7
640 640
 		 * @return mixed|string The latest version number found.
641 641
 		 */
642
-		public function get_latest_version( $force_api = false ) {
642
+		public function get_latest_version($force_api = false) {
643 643
 			$latest_version = $this->latest;
644 644
 
645
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
645
+			$cache = get_transient('wp-font-awesome-settings-version');
646 646
 
647
-			if ( $cache === false || $force_api ) { // its not set
647
+			if ($cache === false || $force_api) { // its not set
648 648
 				$api_ver = $this->get_latest_version_from_api();
649
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
649
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
650 650
 					$latest_version = $api_ver;
651
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
651
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
652 652
 				}
653
-			} elseif ( $this->validate_version_number( $cache ) ) {
654
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
653
+			} elseif ($this->validate_version_number($cache)) {
654
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
655 655
 					$latest_version = $cache;
656 656
 				}
657 657
 			}
658 658
 
659 659
 			// Check and auto download fonts locally.
660
-			if ( empty( $this->settings['pro'] ) && empty( $this->settings['version'] ) && $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && ! empty( $this->settings['local_version'] ) && ! empty( $latest_version ) ) {
661
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
662
-					$this->download_package( $latest_version );
660
+			if (empty($this->settings['pro']) && empty($this->settings['version']) && $this->settings['type'] != 'KIT' && !empty($this->settings['local']) && !empty($this->settings['local_version']) && !empty($latest_version)) {
661
+				if (version_compare($latest_version, $this->settings['local_version'], '>') && is_admin() && !wp_doing_ajax()) {
662
+					$this->download_package($latest_version);
663 663
 				}
664 664
 			}
665 665
 
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 		 */
675 675
 		public function get_latest_version_from_api() {
676 676
 			$version  = "0";
677
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
678
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
679
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
680
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
677
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
678
+			if (!is_wp_error($response) && is_array($response)) {
679
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
680
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
681 681
 					$version = $api_response['tag_name'];
682 682
 				}
683 683
 			}
@@ -705,21 +705,21 @@  discard block
 block discarded – undo
705 705
 		public function admin_notices() {
706 706
 			$settings = $this->settings;
707 707
 
708
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
709
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
708
+			if (defined('FONTAWESOME_PLUGIN_FILE')) {
709
+				if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-font-awesome-settings') {
710 710
 					?>
711 711
                     <div class="notice  notice-error is-dismissible">
712
-                        <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings' ); ?></p>
712
+                        <p><?php _e('The Official Font Awesome Plugin is active, please adjust your settings there.', 'font-awesome-settings'); ?></p>
713 713
                     </div>
714 714
 					<?php
715 715
 				}
716 716
 			} else {
717
-				if ( ! empty( $settings ) ) {
718
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
717
+				if (!empty($settings)) {
718
+					if ($settings['type'] != 'KIT' && $settings['pro'] && ($settings['version'] == '' || version_compare($settings['version'], '6', '>='))) {
719 719
 						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
720 720
 						?>
721 721
                         <div class="notice  notice-error is-dismissible">
722
-                            <p><?php echo sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
722
+                            <p><?php echo sprintf(__('Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'font-awesome-settings'), "<a href='" . esc_url_raw($link) . "'>", "</a>"); ?></p>
723 723
                         </div>
724 724
 						<?php
725 725
 					}
@@ -735,20 +735,20 @@  discard block
 block discarded – undo
735 735
 		 * @param string $option The option name.
736 736
 		 * @param mixed  $value  The option value.
737 737
 		 */
738
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
738
+		public function add_option_wp_font_awesome_settings($option, $value) {
739 739
 			// Do nothing if WordPress is being installed.
740
-			if ( wp_installing() ) {
740
+			if (wp_installing()) {
741 741
 				return;
742 742
 			}
743 743
 
744
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
745
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
744
+			if (!empty($value['local']) && empty($value['pro']) && !(!empty($value['type']) && $value['type'] == 'KIT')) {
745
+				$version = isset($value['version']) && $value['version'] ? $value['version'] : $this->get_latest_version();
746 746
 
747
-				if ( ! empty( $version ) ) {
748
-					$response = $this->download_package( $version, $value );
747
+				if (!empty($version)) {
748
+					$response = $this->download_package($version, $value);
749 749
 
750
-					if ( is_wp_error( $response ) ) {
751
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' );
750
+					if (is_wp_error($response)) {
751
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'font-awesome-settings') . ' ' . $response->get_error_message(), 'error');
752 752
 					}
753 753
 				}
754 754
 			}
@@ -762,25 +762,25 @@  discard block
 block discarded – undo
762 762
 		 * @param mixed $old_value The old option value.
763 763
 		 * @param mixed $value     The new option value.
764 764
 		 */
765
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
765
+		public function update_option_wp_font_awesome_settings($old_value, $new_value) {
766 766
 			// Do nothing if WordPress is being installed.
767
-			if ( wp_installing() ) {
767
+			if (wp_installing()) {
768 768
 				return;
769 769
 			}
770 770
 
771
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
771
+			if (!empty($new_value['local']) && empty($new_value['pro']) && !(!empty($new_value['type']) && $new_value['type'] == 'KIT')) {
772 772
 				// Old values
773
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
774
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
773
+				$old_version = isset($old_value['version']) && $old_value['version'] ? $old_value['version'] : (isset($old_value['local_version']) ? $old_value['local_version'] : '');
774
+				$old_local = isset($old_value['local']) ? (int) $old_value['local'] : 0;
775 775
 
776 776
 				// New values
777
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
777
+				$new_version = isset($new_value['version']) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
778 778
 
779
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
780
-					$response = $this->download_package( $new_version, $new_value );
779
+				if (empty($old_local) || $old_version !== $new_version || !file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) {
780
+					$response = $this->download_package($new_version, $new_value);
781 781
 
782
-					if ( is_wp_error( $response ) ) {
783
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'font-awesome-settings' ) . ' ' . $response->get_error_message(), 'error' );
782
+					if (is_wp_error($response)) {
783
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'font-awesome-settings') . ' ' . $response->get_error_message(), 'error');
784 784
 					}
785 785
 				}
786 786
 			}
@@ -794,9 +794,9 @@  discard block
 block discarded – undo
794 794
 		 * @param string Fonts directory local path.
795 795
 		 */
796 796
 		public function get_fonts_dir() {
797
-			$upload_dir = wp_upload_dir( null, false );
797
+			$upload_dir = wp_upload_dir(null, false);
798 798
 
799
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
799
+			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
800 800
 		}
801 801
 
802 802
 		/**
@@ -807,9 +807,9 @@  discard block
 block discarded – undo
807 807
 		 * @param string Fonts directory local url.
808 808
 		 */
809 809
 		public function get_fonts_url() {
810
-			$upload_dir = wp_upload_dir( null, false );
810
+			$upload_dir = wp_upload_dir(null, false);
811 811
 
812
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
812
+			return $upload_dir['baseurl'] . '/ayefonts/fa/';
813 813
 		}
814 814
 
815 815
 		/**
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 		 * @return bool True if active else false.
821 821
 		 */
822 822
 		public function has_local() {
823
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
823
+			if (!empty($this->settings['local']) && empty($this->settings['pro']) && file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) {
824 824
 				return true;
825 825
 			}
826 826
 
@@ -835,18 +835,18 @@  discard block
 block discarded – undo
835 835
 		 * @return object The WP Filesystem.
836 836
 		 */
837 837
 		public function get_wp_filesystem() {
838
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
839
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
838
+			if (!function_exists('get_filesystem_method')) {
839
+				require_once(ABSPATH . "/wp-admin/includes/file.php");
840 840
 			}
841 841
 
842 842
 			$access_type = get_filesystem_method();
843 843
 
844
-			if ( $access_type === 'direct' ) {
844
+			if ($access_type === 'direct') {
845 845
 				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
846
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
846
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
847 847
 
848 848
 				/* Initialize the API */
849
-				if ( ! WP_Filesystem( $creds ) ) {
849
+				if (!WP_Filesystem($creds)) {
850 850
 					/* Any problems and we exit */
851 851
 					return false;
852 852
 				}
@@ -855,11 +855,11 @@  discard block
 block discarded – undo
855 855
 
856 856
 				return $wp_filesystem;
857 857
 				/* Do our file manipulations below */
858
-			} else if ( defined( 'FTP_USER' ) ) {
859
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
858
+			} else if (defined('FTP_USER')) {
859
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
860 860
 
861 861
 				/* Initialize the API */
862
-				if ( ! WP_Filesystem( $creds ) ) {
862
+				if (!WP_Filesystem($creds)) {
863 863
 					/* Any problems and we exit */
864 864
 					return false;
865 865
 				}
@@ -882,38 +882,38 @@  discard block
 block discarded – undo
882 882
 		 * @param array $option Fontawesome settings.
883 883
 		 * @return WP_ERROR|bool Error on fail and true on success.
884 884
 		 */
885
-		public function download_package( $version, $option = array() ) {
885
+		public function download_package($version, $option = array()) {
886 886
 			$filename = 'fontawesome-free-' . $version . '-web';
887 887
 			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
888 888
 
889
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
889
+			if (!function_exists('wp_handle_upload')) {
890 890
 				require_once ABSPATH . 'wp-admin/includes/file.php';
891 891
 			}
892 892
 
893
-			$download_file = download_url( esc_url_raw( $url ) );
893
+			$download_file = download_url(esc_url_raw($url));
894 894
 
895
-			if ( is_wp_error( $download_file ) ) {
896
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'font-awesome-settings' ) );
897
-			} else if ( empty( $download_file ) ) {
898
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings' ) );
895
+			if (is_wp_error($download_file)) {
896
+				return new WP_Error('fontawesome_download_failed', __($download_file->get_error_message(), 'font-awesome-settings'));
897
+			} else if (empty($download_file)) {
898
+				return new WP_Error('fontawesome_download_failed', __('Something went wrong in downloading the font awesome to store locally.', 'font-awesome-settings'));
899 899
 			}
900 900
 
901
-			$response = $this->extract_package( $download_file, $filename, true );
901
+			$response = $this->extract_package($download_file, $filename, true);
902 902
 
903 903
 			// Update local version.
904
-			if ( is_wp_error( $response ) ) {
904
+			if (is_wp_error($response)) {
905 905
 				return $response;
906
-			} else if ( $response ) {
907
-				if ( empty( $option ) ) {
908
-					$option = get_option( 'wp-font-awesome-settings' );
906
+			} else if ($response) {
907
+				if (empty($option)) {
908
+					$option = get_option('wp-font-awesome-settings');
909 909
 				}
910 910
 
911 911
 				$option['local_version'] = $version;
912 912
 
913 913
 				// Remove action to prevent looping.
914
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
914
+				remove_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2);
915 915
 
916
-				update_option( 'wp-font-awesome-settings', $option );
916
+				update_option('wp-font-awesome-settings', $option);
917 917
 
918 918
 				return true;
919 919
 			}
@@ -931,60 +931,60 @@  discard block
 block discarded – undo
931 931
 		 * @param bool   $delete_package Delete temp file or not.
932 932
 		 * @return WP_Error|bool True on success WP_Error on fail.
933 933
 		 */
934
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
934
+		public function extract_package($package, $dirname = '', $delete_package = false) {
935 935
 			global $wp_filesystem;
936 936
 
937 937
 			$wp_filesystem = $this->get_wp_filesystem();
938 938
 
939
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
940
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'font-awesome-settings' ) );
941
-			} else if ( empty( $wp_filesystem ) ) {
942
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings' ) );
939
+			if (empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
940
+				return new WP_Error('fontawesome_filesystem_error', __($wp_filesystem->errors->get_error_message(), 'font-awesome-settings'));
941
+			} else if (empty($wp_filesystem)) {
942
+				return new WP_Error('fontawesome_filesystem_error', __('Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'font-awesome-settings'));
943 943
 			}
944 944
 
945 945
 			$fonts_dir = $this->get_fonts_dir();
946
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
946
+			$fonts_tmp_dir = dirname($fonts_dir) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
947 947
 
948
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
949
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
948
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
949
+				$wp_filesystem->delete($fonts_tmp_dir, true);
950 950
 			}
951 951
 
952 952
 			// Unzip package to working directory.
953
-			$result = unzip_file( $package, $fonts_tmp_dir );
953
+			$result = unzip_file($package, $fonts_tmp_dir);
954 954
 
955
-			if ( is_wp_error( $result ) ) {
956
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
955
+			if (is_wp_error($result)) {
956
+				$wp_filesystem->delete($fonts_tmp_dir, true);
957 957
 
958
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
959
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'font-awesome-settings' ) );
958
+				if ('incompatible_archive' === $result->get_error_code()) {
959
+					return new WP_Error('fontawesome_incompatible_archive', __($result->get_error_message(), 'font-awesome-settings'));
960 960
 				}
961 961
 
962 962
 				return $result;
963 963
 			}
964 964
 
965
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
966
-				$wp_filesystem->delete( $fonts_dir, true );
965
+			if ($wp_filesystem->is_dir($fonts_dir)) {
966
+				$wp_filesystem->delete($fonts_dir, true);
967 967
 			}
968 968
 
969 969
 			$extract_dir = $fonts_tmp_dir;
970 970
 
971
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
971
+			if ($dirname && $wp_filesystem->is_dir($extract_dir . $dirname . DIRECTORY_SEPARATOR)) {
972 972
 				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
973 973
 			}
974 974
 
975 975
 			try {
976
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
977
-			} catch ( Exception $e ) {
978
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'font-awesome-settings' ) );
976
+				$return = $wp_filesystem->move($extract_dir, $fonts_dir, true);
977
+			} catch (Exception $e) {
978
+				$return = new WP_Error('fontawesome_move_package', __('Fail to move font awesome package!', 'font-awesome-settings'));
979 979
 			}
980 980
 
981
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
982
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
981
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
982
+				$wp_filesystem->delete($fonts_tmp_dir, true);
983 983
 			}
984 984
 
985 985
 			// Once extracted, delete the package if required.
986
-			if ( $delete_package ) {
987
-				unlink( $package );
986
+			if ($delete_package) {
987
+				unlink($package);
988 988
 			}
989 989
 
990 990
 			return $return;
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 1 patch
Spacing   +700 added lines, -700 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
22
+if (!class_exists('AyeCode_UI_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -99,27 +99,27 @@  discard block
 block discarded – undo
99 99
 		 * @return AyeCode_UI_Settings - Main instance.
100 100
 		 */
101 101
 		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) {
103 103
 
104 104
 				self::$instance = new AyeCode_UI_Settings;
105 105
 
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
106
+				add_action('init', array(self::$instance, 'init')); // set settings
107 107
 
108
-				if ( is_admin() ) {
109
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
110
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
108
+				if (is_admin()) {
109
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
110
+					add_action('admin_init', array(self::$instance, 'register_settings'));
111 111
 
112 112
 					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
113
+					add_action('template_redirect', array(self::$instance, 'maybe_show_examples'));
114 114
 
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
115
+					if (defined('BLOCKSTRAP_VERSION')) {
116
+						add_filter('sd_aui_colors', array(self::$instance, 'sd_aui_colors'), 10, 3);
117 117
 					}
118 118
 				}
119 119
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
120
+				add_action('customize_register', array(self::$instance, 'customizer_settings'));
121 121
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
122
+				do_action('ayecode_ui_settings_loaded');
123 123
 			}
124 124
 
125 125
 			return self::$instance;
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 		 *
135 135
 		 * @return mixed
136 136
 		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
137
+		public function sd_aui_colors($theme_colors, $include_outlines, $include_branding) {
138 138
 
139 139
 
140 140
 			$setting = wp_get_global_settings();
141 141
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
142
+			if (!empty($setting['color']['palette']['custom'])) {
143
+				foreach ($setting['color']['palette']['custom'] as $color) {
144 144
 					$theme_colors[$color['slug']] = esc_attr($color['name']);
145 145
 				}
146 146
 			}
@@ -151,81 +151,81 @@  discard block
 block discarded – undo
151 151
 		/**
152 152
 		 * Setup some constants.
153 153
 		 */
154
-		public function constants(){
155
-			define( 'AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be" );
156
-			define( 'AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d' );
157
-			define( 'AUI_INFO_COLOR_ORIGINAL', '#17a2b8' );
158
-			define( 'AUI_WARNING_COLOR_ORIGINAL', '#ffc107' );
159
-			define( 'AUI_DANGER_COLOR_ORIGINAL', '#dc3545' );
160
-			define( 'AUI_SUCCESS_COLOR_ORIGINAL', '#44c553' );
161
-			define( 'AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa' );
162
-			define( 'AUI_DARK_COLOR_ORIGINAL', '#343a40' );
163
-			define( 'AUI_WHITE_COLOR_ORIGINAL', '#fff' );
164
-			define( 'AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd' );
165
-			define( 'AUI_SALMON_COLOR_ORIGINAL', '#ff977a' );
166
-			define( 'AUI_CYAN_COLOR_ORIGINAL', '#35bdff' );
167
-			define( 'AUI_GRAY_COLOR_ORIGINAL', '#ced4da' );
168
-			define( 'AUI_INDIGO_COLOR_ORIGINAL', '#502c6c' );
169
-			define( 'AUI_ORANGE_COLOR_ORIGINAL', '#orange' );
170
-			define( 'AUI_BLACK_COLOR_ORIGINAL', '#000' );
154
+		public function constants() {
155
+			define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be");
156
+			define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d');
157
+			define('AUI_INFO_COLOR_ORIGINAL', '#17a2b8');
158
+			define('AUI_WARNING_COLOR_ORIGINAL', '#ffc107');
159
+			define('AUI_DANGER_COLOR_ORIGINAL', '#dc3545');
160
+			define('AUI_SUCCESS_COLOR_ORIGINAL', '#44c553');
161
+			define('AUI_LIGHT_COLOR_ORIGINAL', '#f8f9fa');
162
+			define('AUI_DARK_COLOR_ORIGINAL', '#343a40');
163
+			define('AUI_WHITE_COLOR_ORIGINAL', '#fff');
164
+			define('AUI_PURPLE_COLOR_ORIGINAL', '#ad6edd');
165
+			define('AUI_SALMON_COLOR_ORIGINAL', '#ff977a');
166
+			define('AUI_CYAN_COLOR_ORIGINAL', '#35bdff');
167
+			define('AUI_GRAY_COLOR_ORIGINAL', '#ced4da');
168
+			define('AUI_INDIGO_COLOR_ORIGINAL', '#502c6c');
169
+			define('AUI_ORANGE_COLOR_ORIGINAL', '#orange');
170
+			define('AUI_BLACK_COLOR_ORIGINAL', '#000');
171 171
 
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
172
+			if (!defined('AUI_PRIMARY_COLOR')) {
173
+				define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL);
174 174
 			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
175
+			if (!defined('AUI_SECONDARY_COLOR')) {
176
+				define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL);
177 177
 			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
178
+			if (!defined('AUI_INFO_COLOR')) {
179
+				define('AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL);
180 180
 			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
181
+			if (!defined('AUI_WARNING_COLOR')) {
182
+				define('AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL);
183 183
 			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
184
+			if (!defined('AUI_DANGER_COLOR')) {
185
+				define('AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL);
186 186
 			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
187
+			if (!defined('AUI_SUCCESS_COLOR')) {
188
+				define('AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL);
189 189
 			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
190
+			if (!defined('AUI_LIGHT_COLOR')) {
191
+				define('AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL);
192 192
 			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
193
+			if (!defined('AUI_DARK_COLOR')) {
194
+				define('AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL);
195 195
 			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
196
+			if (!defined('AUI_WHITE_COLOR')) {
197
+				define('AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL);
198 198
 			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
199
+			if (!defined('AUI_PURPLE_COLOR')) {
200
+				define('AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL);
201 201
 			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
202
+			if (!defined('AUI_SALMON_COLOR')) {
203
+				define('AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL);
204 204
 			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
205
+			if (!defined('AUI_CYAN_COLOR')) {
206
+				define('AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL);
207 207
 			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
208
+			if (!defined('AUI_GRAY_COLOR')) {
209
+				define('AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL);
210 210
 			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
211
+			if (!defined('AUI_INDIGO_COLOR')) {
212
+				define('AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL);
213 213
 			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
214
+			if (!defined('AUI_ORANGE_COLOR')) {
215
+				define('AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL);
216 216
 			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
217
+			if (!defined('AUI_BLACK_COLOR')) {
218
+				define('AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL);
219 219
 			}
220 220
 
221 221
 		}
222 222
 
223
-		public static function get_colors( $original = false){
223
+		public static function get_colors($original = false) {
224 224
 
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
225
+			if (!defined('AUI_PRIMARY_COLOR')) {
226 226
 				return array();
227 227
 			}
228
-			if ( $original ) {
228
+			if ($original) {
229 229
 				return array(
230 230
 					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231 231
 					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 *
274 274
 		 * @return mixed
275 275
 		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
276
+		public function add_bs5_admin_body_class($classes = '') {
277 277
 			$classes .= ' aui_bs5';
278 278
 
279 279
 			return $classes;
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 		 *
287 287
 		 * @return mixed
288 288
 		 */
289
-		public function add_bs5_body_class( $classes ) {
289
+		public function add_bs5_body_class($classes) {
290 290
 			$classes[] = 'aui_bs5';
291 291
 
292 292
 			return $classes;
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
             global $aui_bs5;
300 300
 
301 301
 			// Maybe fix settings
302
-			if ( ! empty( $_REQUEST['aui-fix-admin'] ) && !empty($_REQUEST['nonce']) && wp_verify_nonce( $_REQUEST['nonce'], "aui-fix-admin" ) ) {
303
-				$db_settings = get_option( 'ayecode-ui-settings' );
304
-				if ( ! empty( $db_settings ) ) {
302
+			if (!empty($_REQUEST['aui-fix-admin']) && !empty($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], "aui-fix-admin")) {
303
+				$db_settings = get_option('ayecode-ui-settings');
304
+				if (!empty($db_settings)) {
305 305
 					$db_settings['css_backend'] = 'compatibility';
306 306
 					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
307
+					update_option('ayecode-ui-settings', $db_settings);
308 308
 					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309 309
 				}
310 310
 			}
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
             // define the version
317 317
 			$aui_bs5 = $this->settings['bs_ver'] === '5';
318 318
 
319
-			if ( $aui_bs5 ) {
320
-				include_once( dirname( __FILE__ ) . '/inc/bs-conversion.php' );
321
-				add_filter( 'admin_body_class', array( $this, 'add_bs5_admin_body_class' ), 99, 1 );
322
-				add_filter( 'body_class', array( $this, 'add_bs5_body_class' ) );
319
+			if ($aui_bs5) {
320
+				include_once(dirname(__FILE__) . '/inc/bs-conversion.php');
321
+				add_filter('admin_body_class', array($this, 'add_bs5_admin_body_class'), 99, 1);
322
+				add_filter('body_class', array($this, 'add_bs5_body_class'));
323 323
 			}
324 324
 
325 325
 			/**
@@ -327,32 +327,32 @@  discard block
 block discarded – undo
327 327
 			 *
328 328
 			 * We load super early in case there is a theme version that might change the colors
329 329
 			 */
330
-			if ( $this->settings['css'] ) {
330
+			if ($this->settings['css']) {
331 331
 				$priority = $this->is_bs3_compat() ? 100 : 1;
332 332
                 $priority = $aui_bs5 ? 10 : $priority;
333
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
333
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), $priority);
334 334
 			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
335
+			if ($this->settings['css_backend'] && $this->load_admin_scripts()) {
336
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1);
337 337
 			}
338 338
 
339 339
 			// maybe load JS
340
-			if ( $this->settings['js'] ) {
340
+			if ($this->settings['js']) {
341 341
 				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
342
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority);
343 343
 			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
344
+			if ($this->settings['js_backend'] && $this->load_admin_scripts()) {
345
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
346 346
 			}
347 347
 
348 348
 			// Maybe set the HTML font size
349
-			if ( $this->settings['html_font_size'] ) {
350
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
349
+			if ($this->settings['html_font_size']) {
350
+				add_action('wp_footer', array($this, 'html_font_size'), 10);
351 351
 			}
352 352
 
353 353
 			// Maybe show backend style error
354
-			if( $this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper' ){
355
-				add_action( 'admin_notices', array( $this, 'show_admin_style_notice' ) );
354
+			if ($this->settings['css_backend'] != 'compatibility' || $this->settings['js_backend'] != 'core-popper') {
355
+				add_action('admin_notices', array($this, 'show_admin_style_notice'));
356 356
 			}
357 357
 
358 358
 		}
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
 		/**
361 361
 		 * Show admin notice if backend scripts not loaded.
362 362
 		 */
363
-		public function show_admin_style_notice(){
364
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=".wp_create_nonce('aui-fix-admin'));
365
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">Fix Now</a>';
366
-			$message = __( '<b>Style Issue:</b> AyeCode UI is disable or set wrong.')." " .$button;
367
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'.$message.'</p></div>';
363
+		public function show_admin_style_notice() {
364
+			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings&aui-fix-admin=true&nonce=" . wp_create_nonce('aui-fix-admin'));
365
+			$button = '<a href="' . esc_url($fix_url) . '" class="button-primary">Fix Now</a>';
366
+			$message = __('<b>Style Issue:</b> AyeCode UI is disable or set wrong.') . " " . $button;
367
+			echo '<div class="notice notice-error aui-settings-error-notice"><p>' . $message . '</p></div>';
368 368
 		}
369 369
 
370 370
 		/**
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 		 *
373 373
 		 * @return bool
374 374
 		 */
375
-		public function load_admin_scripts(){
375
+		public function load_admin_scripts() {
376 376
 			$result = true;
377 377
 
378 378
 			// check if specifically disabled
379
-			if(!empty($this->settings['disable_admin'])){
380
-				$url_parts = explode("\n",$this->settings['disable_admin']);
381
-				foreach($url_parts as $part){
382
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
379
+			if (!empty($this->settings['disable_admin'])) {
380
+				$url_parts = explode("\n", $this->settings['disable_admin']);
381
+				foreach ($url_parts as $part) {
382
+					if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) {
383 383
 						return false; // return early, no point checking further
384 384
 					}
385 385
 				}
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 		/**
392 392
 		 * Add a html font size to the footer.
393 393
 		 */
394
-		public function html_font_size(){
394
+		public function html_font_size() {
395 395
 			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
396
+			echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>";
397 397
 		}
398 398
 
399 399
 		/**
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 		 *
402 402
 		 * @return bool
403 403
 		 */
404
-		public function is_aui_screen(){
404
+		public function is_aui_screen() {
405 405
 //			echo '###';exit;
406 406
 			$load = false;
407 407
 			// check if we should load or not
408
-			if ( is_admin() ) {
408
+			if (is_admin()) {
409 409
 				// Only enable on set pages
410 410
 				$aui_screens = array(
411 411
 					'page',
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
 					'ayecode-ui-settings',
418 418
 					'site-editor'
419 419
 				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
420
+				$screen_ids = apply_filters('aui_screen_ids', $aui_screens);
421 421
 
422 422
 				$screen = get_current_screen();
423 423
 
424 424
 //				echo '###'.$screen->id;
425 425
 
426 426
 				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
427
+				if ($screen && in_array($screen->id, $screen_ids)) {
428 428
 					$load = true;
429 429
 				}
430 430
 
431 431
 				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
432
+				if (!empty($_REQUEST['legacy-widget-preview'])) {
433 433
 					$load = true;
434 434
 				}
435 435
 			}
436 436
 
437 437
 
438 438
 
439
-			return apply_filters( 'aui_load_on_admin' , $load );
439
+			return apply_filters('aui_load_on_admin', $load);
440 440
 		}
441 441
 
442 442
 		/**
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		 * @return bool
446 446
 		 */
447 447
 		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
448
+			if (function_exists('wp_is_block_theme' && wp_is_block_theme())) {
449 449
 				return true;
450 450
 			}
451 451
 
@@ -460,40 +460,40 @@  discard block
 block discarded – undo
460 460
 
461 461
             $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
463
+			if (is_admin() && !$this->is_aui_screen()) {
464 464
 				// don't add wp-admin scripts if not requested to
465
-			}else{
465
+			} else {
466 466
 				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
467 467
 
468
-				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
468
+				$rtl = is_rtl() && !$aui_bs5 ? '-rtl' : '';
469 469
 
470 470
                 $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
471 471
 
472
-				if($this->settings[$css_setting]){
473
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
474
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets'.$bs_ver.'/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets'.$bs_ver.'/css/ayecode-ui-compatibility'.$rtl.'.css';
472
+				if ($this->settings[$css_setting]) {
473
+					$compatibility = $this->settings[$css_setting] == 'core' ? false : true;
474
+					$url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets' . $bs_ver . '/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets' . $bs_ver . '/css/ayecode-ui-compatibility' . $rtl . '.css';
475 475
 
476 476
 
477 477
 
478
-					wp_register_style( 'ayecode-ui', $url, array(), $this->version );
479
-					wp_enqueue_style( 'ayecode-ui' );
478
+					wp_register_style('ayecode-ui', $url, array(), $this->version);
479
+					wp_enqueue_style('ayecode-ui');
480 480
 
481
-					$current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
481
+					$current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
482 482
 
483 483
 //					if ( is_admin() && !empty($_REQUEST['postType']) ) {
484
-					if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
485
-						$url = $this->url.'assets'.$bs_ver.'/css/ayecode-ui-fse.css';
486
-						wp_register_style( 'ayecode-ui-fse', $url, array(), $this->version );
487
-						wp_enqueue_style( 'ayecode-ui-fse' );
484
+					if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
485
+						$url = $this->url . 'assets' . $bs_ver . '/css/ayecode-ui-fse.css';
486
+						wp_register_style('ayecode-ui-fse', $url, array(), $this->version);
487
+						wp_enqueue_style('ayecode-ui-fse');
488 488
 						$load_fse = true;
489 489
 					}
490 490
 
491 491
 
492 492
 					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
493
+					wp_register_style('flatpickr', $this->url . 'assets' . $bs_ver . '/css/flatpickr.min.css', array(), $this->version);
494 494
 
495 495
 					// fix some wp-admin issues
496
-					if(is_admin()){
496
+					if (is_admin()) {
497 497
 						$custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
 						    padding: 0;
547 547
 						}
548 548
 					";
549
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
549
+						wp_add_inline_style('ayecode-ui', $custom_css);
550 550
 					}
551 551
 
552 552
 					// custom changes
553
-					if ( $load_fse ) {
554
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
555
-					}else{
556
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
553
+					if ($load_fse) {
554
+						wp_add_inline_style('ayecode-ui-fse', self::custom_css($compatibility));
555
+					} else {
556
+						wp_add_inline_style('ayecode-ui', self::custom_css($compatibility));
557 557
 
558 558
 					}
559 559
 
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
 			$flatpickr_locale = self::flatpickr_locale();
575 575
 
576 576
 			ob_start();
577
-			if ( $aui_bs5 ) {
578
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
579
-			}else{
580
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
577
+			if ($aui_bs5) {
578
+				include_once(dirname(__FILE__) . '/inc/bs5-js.php');
579
+			} else {
580
+				include_once(dirname(__FILE__) . '/inc/bs4-js.php');
581 581
             }
582 582
 
583 583
 			$output = ob_get_clean();
@@ -585,10 +585,10 @@  discard block
 block discarded – undo
585 585
 			/*
586 586
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
587 587
 			 */
588
-			return str_replace( array(
588
+			return str_replace(array(
589 589
 				'<script>',
590 590
 				'</script>'
591
-			), '', self::minify_js($output) );
591
+			), '', self::minify_js($output));
592 592
 		}
593 593
 
594 594
 
@@ -602,13 +602,13 @@  discard block
 block discarded – undo
602 602
 			ob_start();
603 603
 			?>
604 604
             <script>
605
-				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
605
+				<?php if (defined('FUSION_BUILDER_VERSION')) { ?>
606 606
                 /* With Avada builder */
607 607
 
608 608
 				<?php } ?>
609 609
             </script>
610 610
 			<?php
611
-			return str_replace( array(
611
+			return str_replace(array(
612 612
 				'<script>',
613 613
 				'</script>'
614 614
 			), '', ob_get_clean());
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 		 *
620 620
 		 * If this remains small then its best to use this than to add another JS file.
621 621
 		 */
622
-		public function inline_script_file_browser(){
622
+		public function inline_script_file_browser() {
623 623
 			ob_start();
624 624
 			?>
625 625
             <script>
@@ -634,10 +634,10 @@  discard block
 block discarded – undo
634 634
 			/*
635 635
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
636 636
 			 */
637
-			return str_replace( array(
637
+			return str_replace(array(
638 638
 				'<script>',
639 639
 				'</script>'
640
-			), '', $output );
640
+			), '', $output);
641 641
 		}
642 642
 
643 643
 		/**
@@ -645,59 +645,59 @@  discard block
 block discarded – undo
645 645
 		 */
646 646
 		public function enqueue_scripts() {
647 647
 
648
-			if( is_admin() && !$this->is_aui_screen()){
648
+			if (is_admin() && !$this->is_aui_screen()) {
649 649
 				// don't add wp-admin scripts if not requested to
650
-			}else {
650
+			} else {
651 651
 
652 652
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
653 653
 
654 654
 				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
655 655
 
656 656
 				// select2
657
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
657
+				wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version);
658 658
 
659 659
 				// flatpickr
660
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
660
+				wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version);
661 661
 
662 662
 				// iconpicker
663
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
664
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
665
-				}else{
666
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
663
+				if (defined('FAS_ICONPICKER_JS_URL')) {
664
+					wp_register_script('iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version);
665
+				} else {
666
+					wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version);
667 667
 				}
668 668
 
669 669
 				// Bootstrap file browser
670
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
671
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
670
+				wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version);
671
+				wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser());
672 672
 
673 673
 				$load_inline = false;
674 674
 
675
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
675
+				if ($this->settings[$js_setting] == 'core-popper') {
676 676
 					// Bootstrap bundle
677 677
 					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
678
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
678
+					wp_register_script('bootstrap-js-bundle', $url, array(
679 679
 						'select2',
680 680
 						'jquery'
681
-					), $this->version, $this->is_bs3_compat() );
681
+					), $this->version, $this->is_bs3_compat());
682 682
 					// if in admin then add to footer for compatibility.
683
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
683
+					is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle');
684 684
 					$script = $this->inline_script();
685
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
686
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
685
+					wp_add_inline_script('bootstrap-js-bundle', $script);
686
+				} elseif ($this->settings[$js_setting] == 'popper') {
687 687
 					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
688
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
689
-					wp_enqueue_script( 'bootstrap-js-popper' );
688
+					wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version);
689
+					wp_enqueue_script('bootstrap-js-popper');
690 690
 					$load_inline = true;
691 691
 				} else {
692 692
 					$load_inline = true;
693 693
 				}
694 694
 
695 695
 				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
696
-				if ( $load_inline ) {
697
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
698
-					wp_enqueue_script( 'bootstrap-dummy' );
696
+				if ($load_inline) {
697
+					wp_register_script('bootstrap-dummy', '', array('select2', 'jquery'));
698
+					wp_enqueue_script('bootstrap-dummy');
699 699
 					$script = $this->inline_script();
700
-					wp_add_inline_script( 'bootstrap-dummy', $script );
700
+					wp_add_inline_script('bootstrap-dummy', $script);
701 701
 				}
702 702
 			}
703 703
 
@@ -706,17 +706,17 @@  discard block
 block discarded – undo
706 706
 		/**
707 707
 		 * Enqueue flatpickr if called.
708 708
 		 */
709
-		public function enqueue_flatpickr(){
710
-			wp_enqueue_style( 'flatpickr' );
711
-			wp_enqueue_script( 'flatpickr' );
709
+		public function enqueue_flatpickr() {
710
+			wp_enqueue_style('flatpickr');
711
+			wp_enqueue_script('flatpickr');
712 712
 		}
713 713
 
714 714
 		/**
715 715
 		 * Enqueue iconpicker if called.
716 716
 		 */
717
-		public function enqueue_iconpicker(){
718
-			wp_enqueue_style( 'iconpicker' );
719
-			wp_enqueue_script( 'iconpicker' );
717
+		public function enqueue_iconpicker() {
718
+			wp_enqueue_style('iconpicker');
719
+			wp_enqueue_script('iconpicker');
720 720
 		}
721 721
 
722 722
 		/**
@@ -725,19 +725,19 @@  discard block
 block discarded – undo
725 725
 		 * @return string
726 726
 		 */
727 727
 		public function get_url() {
728
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
729
-			$content_url = untrailingslashit( WP_CONTENT_URL );
728
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
729
+			$content_url = untrailingslashit(WP_CONTENT_URL);
730 730
 
731 731
 			// Replace http:// to https://.
732
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
733
-				$content_url = str_replace( 'http://', 'https://', $content_url );
732
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
733
+				$content_url = str_replace('http://', 'https://', $content_url);
734 734
 			}
735 735
 
736 736
 			// Check if we are inside a plugin
737
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
738
-			$url = str_replace( $content_dir, $content_url, $file_dir );
737
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
738
+			$url = str_replace($content_dir, $content_url, $file_dir);
739 739
 
740
-			return trailingslashit( $url );
740
+			return trailingslashit($url);
741 741
 		}
742 742
 
743 743
 		/**
@@ -749,15 +749,15 @@  discard block
 block discarded – undo
749 749
 
750 750
 			$url = '';
751 751
 			// check if we are inside a plugin
752
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
752
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
753 753
 
754 754
 			// add check in-case user has changed wp-content dir name.
755 755
 			$wp_content_folder_name = basename(WP_CONTENT_DIR);
756
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
757
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
756
+			$dir_parts = explode("/$wp_content_folder_name/", $file_dir);
757
+			$url_parts = explode("/$wp_content_folder_name/", plugins_url());
758 758
 
759
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
760
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
759
+			if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
760
+				$url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]);
761 761
 			}
762 762
 
763 763
 			return $url;
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		 * Register the database settings with WordPress.
768 768
 		 */
769 769
 		public function register_settings() {
770
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
770
+			register_setting('ayecode-ui-settings', 'ayecode-ui-settings');
771 771
 		}
772 772
 
773 773
 		/**
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 		 */
777 777
 		public function menu_item() {
778 778
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
779
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
779
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
780 780
 				$this,
781 781
 				'settings_page'
782
-			) );
782
+			));
783 783
 		}
784 784
 
785 785
 		/**
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		 *
788 788
 		 * @return array
789 789
 		 */
790
-		public function theme_js_settings(){
790
+		public function theme_js_settings() {
791 791
 			return array(
792 792
 				'ayetheme' => 'popper',
793 793
 				'listimia' => 'required',
@@ -803,24 +803,24 @@  discard block
 block discarded – undo
803 803
 		 */
804 804
 		public function get_settings() {
805 805
 
806
-			$db_settings = get_option( 'ayecode-ui-settings' );
806
+			$db_settings = get_option('ayecode-ui-settings');
807 807
 			$js_default = 'core-popper';
808 808
 			$js_default_backend = $js_default;
809 809
 
810 810
 			// maybe set defaults (if no settings set)
811
-			if(empty($db_settings)){
812
-				$active_theme = strtolower( get_template() ); // active parent theme.
811
+			if (empty($db_settings)) {
812
+				$active_theme = strtolower(get_template()); // active parent theme.
813 813
 				$theme_js_settings = self::theme_js_settings();
814
-				if(isset($theme_js_settings[$active_theme])){
814
+				if (isset($theme_js_settings[$active_theme])) {
815 815
 					$js_default = $theme_js_settings[$active_theme];
816
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
816
+					$js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default;
817 817
 				}
818 818
 			}
819 819
 
820 820
 			/**
821 821
 			 * Filter the default settings.
822 822
 			 */
823
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
823
+			$defaults = apply_filters('ayecode-ui-default-settings', array(
824 824
 				'css'            => 'compatibility', // core, compatibility
825 825
 				'js'             => $js_default, // js to load, core-popper, popper
826 826
 				'html_font_size' => '16', // js to load, core-popper, popper
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
 				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
829 829
 				'disable_admin'  => '', // URL snippets to disable loading on admin
830 830
                 'bs_ver'         => '4', // The default bootstrap version to sue by default
831
-			), $db_settings );
831
+			), $db_settings);
832 832
 
833
-			$settings = wp_parse_args( $db_settings, $defaults );
833
+			$settings = wp_parse_args($db_settings, $defaults);
834 834
 
835 835
 			/**
836 836
 			 * Filter the Bootstrap settings.
837 837
 			 *
838 838
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
839 839
 			 */
840
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
840
+			return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults);
841 841
 		}
842 842
 
843 843
 
@@ -845,28 +845,28 @@  discard block
 block discarded – undo
845 845
 		 * The settings page html output.
846 846
 		 */
847 847
 		public function settings_page() {
848
-			if ( ! current_user_can( 'manage_options' ) ) {
849
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
848
+			if (!current_user_can('manage_options')) {
849
+				wp_die(__('You do not have sufficient permissions to access this page.', 'aui'));
850 850
 			}
851
-            $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
851
+            $overrides = apply_filters('ayecode-ui-settings', array(), array(), array());
852 852
 
853 853
 			?>
854 854
             <div class="wrap">
855 855
                 <h1><?php echo $this->name; ?></h1>
856
-                <p><?php echo apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.",'aui') );?></p>
856
+                <p><?php echo apply_filters('ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'aui')); ?></p>
857 857
                 <form method="post" action="options.php">
858 858
 					<?php
859
-					settings_fields( 'ayecode-ui-settings' );
860
-					do_settings_sections( 'ayecode-ui-settings' );
859
+					settings_fields('ayecode-ui-settings');
860
+					do_settings_sections('ayecode-ui-settings');
861 861
 					?>
862 862
 
863
-                    <h2><?php _e( 'BootStrap Version', 'aui' ); ?></h2>
864
-                    <p><?php echo apply_filters( 'ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.",'aui') );?></p>
863
+                    <h2><?php _e('BootStrap Version', 'aui'); ?></h2>
864
+                    <p><?php echo apply_filters('ayecode-ui-version-settings-message', __("V5 is recommended, however if you have another plugin installed using v4, you may need to use v4 also.", 'aui')); ?></p>
865 865
 	                <div class="bsui"><?php
866
-	                if ( ! empty( $overrides ) ) {
866
+	                if (!empty($overrides)) {
867 867
 		                echo aui()->alert(array(
868 868
 			                'type'=> 'info',
869
-			                'content'=> __("Some options are disabled as your current theme is overriding them.",'aui')
869
+			                'content'=> __("Some options are disabled as your current theme is overriding them.", 'aui')
870 870
 		                ));
871 871
 	                }
872 872
 	                ?>
@@ -874,87 +874,87 @@  discard block
 block discarded – undo
874 874
                     <table class="form-table wpbs-table-version-settings">
875 875
                         <tr valign="top">
876 876
                             <th scope="row"><label
877
-                                        for="wpbs-css"><?php _e( 'Version', 'aui' ); ?></label></th>
877
+                                        for="wpbs-css"><?php _e('Version', 'aui'); ?></label></th>
878 878
                             <td>
879 879
                                 <select name="ayecode-ui-settings[bs_ver]" id="wpbs-css" <?php echo !empty($overrides['bs_ver']) ? 'disabled' : ''; ?>>
880
-                                    <option	value="5" <?php selected( $this->settings['bs_ver'], '5' ); ?>><?php _e( 'v5 (recommended)', 'aui' ); ?></option>
881
-                                    <option value="4" <?php selected( $this->settings['bs_ver'], '4' ); ?>><?php _e( 'v4 (legacy)', 'aui' ); ?></option>
880
+                                    <option	value="5" <?php selected($this->settings['bs_ver'], '5'); ?>><?php _e('v5 (recommended)', 'aui'); ?></option>
881
+                                    <option value="4" <?php selected($this->settings['bs_ver'], '4'); ?>><?php _e('v4 (legacy)', 'aui'); ?></option>
882 882
                                 </select>
883 883
                             </td>
884 884
                         </tr>
885 885
                     </table>
886 886
 
887
-                    <h2><?php _e( 'Frontend', 'aui' ); ?></h2>
887
+                    <h2><?php _e('Frontend', 'aui'); ?></h2>
888 888
                     <table class="form-table wpbs-table-settings">
889 889
                         <tr valign="top">
890 890
                             <th scope="row"><label
891
-                                        for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
891
+                                        for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th>
892 892
                             <td>
893 893
                                 <select name="ayecode-ui-settings[css]" id="wpbs-css" <?php echo !empty($overrides['css']) ? 'disabled' : ''; ?>>
894
-                                    <option	value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option>
895
-                                    <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option>
896
-                                    <option	value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
894
+                                    <option	value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option>
895
+                                    <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option>
896
+                                    <option	value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
897 897
                                 </select>
898 898
                             </td>
899 899
                         </tr>
900 900
 
901 901
                         <tr valign="top">
902 902
                             <th scope="row"><label
903
-                                        for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th>
903
+                                        for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th>
904 904
                             <td>
905 905
                                 <select name="ayecode-ui-settings[js]" id="wpbs-js" <?php echo !empty($overrides['js']) ? 'disabled' : ''; ?>>
906
-                                    <option	value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
907
-                                    <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
908
-                                    <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
909
-                                    <option	value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
906
+                                    <option	value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
907
+                                    <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
908
+                                    <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
909
+                                    <option	value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
910 910
                                 </select>
911 911
                             </td>
912 912
                         </tr>
913 913
 
914 914
                         <tr valign="top">
915 915
                             <th scope="row"><label
916
-                                        for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th>
916
+                                        for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th>
917 917
                             <td>
918
-                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" <?php echo !empty($overrides['html_font_size']) ? 'disabled' : ''; ?> />
919
-                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.",'aui');?></p>
918
+                                <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" <?php echo !empty($overrides['html_font_size']) ? 'disabled' : ''; ?> />
919
+                                <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", 'aui'); ?></p>
920 920
                             </td>
921 921
                         </tr>
922 922
 
923 923
                     </table>
924 924
 
925
-                    <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2>
925
+                    <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2>
926 926
                     <table class="form-table wpbs-table-settings">
927 927
                         <tr valign="top">
928 928
                             <th scope="row"><label
929
-                                        for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
929
+                                        for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th>
930 930
                             <td>
931 931
                                 <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin" <?php echo !empty($overrides['css_backend']) ? 'disabled' : ''; ?>>
932
-                                    <option	value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option>
933
-                                    <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option>
934
-                                    <option	value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
932
+                                    <option	value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option>
933
+                                    <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option>
934
+                                    <option	value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
935 935
                                 </select>
936 936
                             </td>
937 937
                         </tr>
938 938
 
939 939
                         <tr valign="top">
940 940
                             <th scope="row"><label
941
-                                        for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th>
941
+                                        for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th>
942 942
                             <td>
943 943
                                 <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin" <?php echo !empty($overrides['js_backend']) ? 'disabled' : ''; ?>>
944
-                                    <option	value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
945
-                                    <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
946
-                                    <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
947
-                                    <option	value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
944
+                                    <option	value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
945
+                                    <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
946
+                                    <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
947
+                                    <option	value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
948 948
                                 </select>
949 949
                             </td>
950 950
                         </tr>
951 951
 
952 952
                         <tr valign="top">
953 953
                             <th scope="row"><label
954
-                                        for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th>
954
+                                        for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th>
955 955
                             <td>
956
-                                <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p>
957
-                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin'];?></textarea>
956
+                                <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p>
957
+                                <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin']; ?></textarea>
958 958
 
959 959
                             </td>
960 960
                         </tr>
@@ -966,34 +966,34 @@  discard block
 block discarded – undo
966 966
 					?>
967 967
                 </form>
968 968
 
969
-                <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo $this->version; ?></div>
969
+                <div id="wpbs-version" data-aui-source="<?php echo esc_attr($this->get_load_source()); ?>"><?php echo $this->version; ?></div>
970 970
             </div>
971 971
 
972 972
 			<?php
973 973
 		}
974 974
 
975
-        public function get_load_source(){
976
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
977
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
975
+        public function get_load_source() {
976
+	        $file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
977
+	        $plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
978 978
 
979 979
 	        // Find source plugin/theme of SD
980 980
 	        $source = array();
981
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
982
-		        $source = explode( "/", plugin_basename( $file ) );
983
-	        } else if ( function_exists( 'get_theme_root' ) ) {
984
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
981
+	        if (strpos($file, $plugins_dir) !== false) {
982
+		        $source = explode("/", plugin_basename($file));
983
+	        } else if (function_exists('get_theme_root')) {
984
+		        $themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
985 985
 
986
-		        if ( strpos( $file, $themes_dir ) !== false ) {
987
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
986
+		        if (strpos($file, $themes_dir) !== false) {
987
+			        $source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
988 988
 		        }
989 989
 	        }
990 990
 
991 991
             return isset($source[0]) ? esc_attr($source[0]) : '';
992 992
         }
993 993
 
994
-		public function customizer_settings($wp_customize){
994
+		public function customizer_settings($wp_customize) {
995 995
 			$wp_customize->add_section('aui_settings', array(
996
-				'title'    => __('AyeCode UI','aui'),
996
+				'title'    => __('AyeCode UI', 'aui'),
997 997
 				'priority' => 120,
998 998
 			));
999 999
 
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
 				'type'              => 'option',
1008 1008
 				'transport'         => 'refresh',
1009 1009
 			));
1010
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1011
-				'label'    => __('Primary Color','aui'),
1010
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1011
+				'label'    => __('Primary Color', 'aui'),
1012 1012
 				'section'  => 'aui_settings',
1013 1013
 				'settings' => 'aui_options[color_primary]',
1014 1014
 			)));
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
 				'type'              => 'option',
1021 1021
 				'transport'         => 'refresh',
1022 1022
 			));
1023
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1024
-				'label'    => __('Secondary Color','aui'),
1023
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1024
+				'label'    => __('Secondary Color', 'aui'),
1025 1025
 				'section'  => 'aui_settings',
1026 1026
 				'settings' => 'aui_options[color_secondary]',
1027 1027
 			)));
@@ -1047,12 +1047,12 @@  discard block
 block discarded – undo
1047 1047
                 .collapse.show:not(.in){display: inherit;}
1048 1048
                 .fade.show{opacity: 1;}
1049 1049
 
1050
-                <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?>
1050
+                <?php if (defined('SVQ_THEME_VERSION')) { ?>
1051 1051
                 /* KLEO theme specific */
1052 1052
                 .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;}
1053 1053
                 <?php } ?>
1054 1054
 
1055
-                <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1055
+                <?php if (defined('FUSION_BUILDER_VERSION')) { ?>
1056 1056
                 /* With Avada builder */
1057 1057
                 body.modal-open .modal.in  {opacity:1;z-index: 99999}
1058 1058
                 body.modal-open .modal.bsui.in .modal-content  {box-shadow: none;}
@@ -1063,10 +1063,10 @@  discard block
 block discarded – undo
1063 1063
                 <?php } ?>
1064 1064
             </style>
1065 1065
 			<?php
1066
-			return str_replace( array(
1066
+			return str_replace(array(
1067 1067
 				'<style>',
1068 1068
 				'</style>'
1069
-			), '', self::minify_css( ob_get_clean() ) );
1069
+			), '', self::minify_css(ob_get_clean()));
1070 1070
 		}
1071 1071
 
1072 1072
 
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
             global $aui_bs5;
1075 1075
 
1076 1076
 			$colors = array();
1077
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1077
+			if (defined('BLOCKSTRAP_VERSION')) {
1078 1078
 
1079 1079
 
1080 1080
 				$setting = wp_get_global_settings();
@@ -1083,22 +1083,22 @@  discard block
 block discarded – undo
1083 1083
 //                print_r(get_default_block_editor_settings());exit;
1084 1084
 
1085 1085
 //                print_r($setting);echo  '###';exit;
1086
-				if(!empty($setting['color']['palette']['theme'])){
1087
-					foreach($setting['color']['palette']['theme'] as $color){
1086
+				if (!empty($setting['color']['palette']['theme'])) {
1087
+					foreach ($setting['color']['palette']['theme'] as $color) {
1088 1088
 						$colors[$color['slug']] = esc_attr($color['color']);
1089 1089
 					}
1090 1090
 				}
1091 1091
 
1092
-				if(!empty($setting['color']['palette']['custom'])){
1093
-					foreach($setting['color']['palette']['custom'] as $color){
1092
+				if (!empty($setting['color']['palette']['custom'])) {
1093
+					foreach ($setting['color']['palette']['custom'] as $color) {
1094 1094
 						$colors[$color['slug']] = esc_attr($color['color']);
1095 1095
 					}
1096 1096
 				}
1097
-			}else{
1097
+			} else {
1098 1098
 				$settings = get_option('aui_options');
1099 1099
 				$colors = array(
1100
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1101
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1100
+					'primary'   => !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1101
+					'secondary' => !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1102 1102
 				);
1103 1103
 			}
1104 1104
 
@@ -1109,25 +1109,25 @@  discard block
 block discarded – undo
1109 1109
                 <?php
1110 1110
 
1111 1111
 					// BS v3 compat
1112
-					if( self::is_bs3_compat() ){
1112
+					if (self::is_bs3_compat()) {
1113 1113
 						echo self::bs3_compat_css();
1114 1114
 					}
1115 1115
 
1116
-					if(!empty($colors)){
1116
+					if (!empty($colors)) {
1117 1117
 						$d_colors = self::get_colors(true);
1118 1118
 
1119
-                        $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1119
+                        $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
1120 1120
                         $is_fse = false;
1121
-                        if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
1121
+                        if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
1122 1122
                             $is_fse = true;
1123 1123
                         }
1124 1124
 
1125 1125
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1126
-						foreach($colors as $key => $color ){
1127
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1126
+						foreach ($colors as $key => $color) {
1127
+							if ((empty($d_colors[$key]) || $d_colors[$key] != $color) || $is_fse) {
1128 1128
 								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1129 1129
 								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1130
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color);
1130
+								echo $aui_bs5 ? self::css_overwrite_bs5($key, $var, $compat, $color) : self::css_overwrite($key, $var, $compat, $color);
1131 1131
 							}
1132 1132
 						}
1133 1133
 					   // exit;
@@ -1136,17 +1136,17 @@  discard block
 block discarded – undo
1136 1136
 					// Set admin bar z-index lower when modal is open.
1137 1137
 					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1138 1138
 
1139
-					if(is_admin()){
1139
+					if (is_admin()) {
1140 1140
 						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1141 1141
 					}
1142 1142
 
1143
-                    if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' ) ){
1143
+                    if ($aui_bs5 && defined('BLOCKSTRAP_VERSION')) {
1144 1144
                         $css = '';
1145 1145
                         $theme_settings = wp_get_global_styles();
1146 1146
 
1147 1147
                         // font face
1148
-                        if( !empty( $theme_settings['typography']['fontFamily'] ) ){
1149
-                            $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily']  ); //var(--wp--preset--font-family--poppins)
1148
+                        if (!empty($theme_settings['typography']['fontFamily'])) {
1149
+                            $t_fontface = str_replace(array('var:preset|', 'font-family|'), array('--wp--preset--', 'font-family--'), $theme_settings['typography']['fontFamily']); //var(--wp--preset--font-family--poppins)
1150 1150
                             $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';';
1151 1151
                         }
1152 1152
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
                         $css .= '--bs-body-font-size: var(--wp--preset--font-size--small);';
1155 1155
 
1156 1156
 
1157
-                        if($css){
1157
+                        if ($css) {
1158 1158
                             echo 'body{' . $css . '}';
1159 1159
                         }
1160 1160
                     }
@@ -1166,10 +1166,10 @@  discard block
 block discarded – undo
1166 1166
 			/*
1167 1167
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1168 1168
 			 */
1169
-			return str_replace( array(
1169
+			return str_replace(array(
1170 1170
 				'<style>',
1171 1171
 				'</style>'
1172
-			), '', self::minify_css( ob_get_clean() ) );
1172
+			), '', self::minify_css(ob_get_clean()));
1173 1173
 		}
1174 1174
 
1175 1175
 
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 		 *
1180 1180
 		 * @return bool
1181 1181
 		 */
1182
-		public static function is_bs3_compat(){
1182
+		public static function is_bs3_compat() {
1183 1183
 			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1184 1184
 		}
1185 1185
 
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 			$hex = str_replace('#', '', $hex);
1189 1189
 
1190 1190
 			// Convert 3-digit hex to 6-digit hex
1191
-			if(strlen($hex) == 3) {
1191
+			if (strlen($hex) == 3) {
1192 1192
 				$hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1193 1193
 			}
1194 1194
 
@@ -1210,13 +1210,13 @@  discard block
 block discarded – undo
1210 1210
 		 *
1211 1211
 		 * @return string
1212 1212
 		 */
1213
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1213
+		public static function css_overwrite_bs5($type, $color_code, $compatibility, $hex = '') {
1214 1214
 			global $aui_bs5;
1215 1215
 
1216 1216
 			$is_var = false;
1217 1217
 			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1218
-			if(!$color_code){return '';}
1219
-			if(strpos($color_code, 'var') !== false){
1218
+			if (!$color_code) {return ''; }
1219
+			if (strpos($color_code, 'var') !== false) {
1220 1220
 				//if(!sanitize_hex_color($color_code)){
1221 1221
 				$color_code = esc_attr($color_code);
1222 1222
 				$is_var = true;
@@ -1226,15 +1226,15 @@  discard block
 block discarded – undo
1226 1226
 
1227 1227
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1228 1228
 
1229
-			if(!$color_code){return '';}
1229
+			if (!$color_code) {return ''; }
1230 1230
 
1231 1231
 			$rgb = self::hex_to_rgb($hex);
1232 1232
 
1233
-			if($compatibility===true || $compatibility===1){
1233
+			if ($compatibility === true || $compatibility === 1) {
1234 1234
 				$compatibility = '.bsui';
1235
-			}elseif(!$compatibility){
1235
+			}elseif (!$compatibility) {
1236 1236
 				$compatibility = '';
1237
-			}else{
1237
+			} else {
1238 1238
 				$compatibility = esc_attr($compatibility);
1239 1239
 			}
1240 1240
 
@@ -1251,30 +1251,30 @@  discard block
 block discarded – undo
1251 1251
 			 * c = color, b = background color, o = border-color, f = fill
1252 1252
 			 */
1253 1253
 			$selectors = array(
1254
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1255
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1256
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1257
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1258
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1259
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1260
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1261
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1262
-				".badge-{$type}"                                            => array( 'b' ),
1263
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1264
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1265
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1266
-				".text-{$type}"                                     => array( 'c' ),
1254
+				".btn-{$type}"                                              => array('b', 'o'),
1255
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1256
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1257
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1258
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1259
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1260
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1261
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1262
+				".badge-{$type}"                                            => array('b'),
1263
+				".alert-{$type}"                                            => array('b', 'o'),
1264
+				".bg-{$type}"                                               => array('b', 'f'),
1265
+				".btn-link.btn-{$type}"                                     => array('c'),
1266
+				".text-{$type}"                                     => array('c'),
1267 1267
 			);
1268 1268
 
1269
-			if ( $aui_bs5 ) {
1270
-				unset($selectors[".alert-{$type}" ]);
1269
+			if ($aui_bs5) {
1270
+				unset($selectors[".alert-{$type}"]);
1271 1271
 			}
1272 1272
 
1273
-			if ( $type == 'primary' ) {
1273
+			if ($type == 'primary') {
1274 1274
 				$selectors = $selectors + array(
1275
-						'a'                                                                                                    => array( 'c' ),
1276
-						'.btn-link'                                                                                            => array( 'c' ),
1277
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1275
+						'a'                                                                                                    => array('c'),
1276
+						'.btn-link'                                                                                            => array('c'),
1277
+						'.dropdown-item.active'                                                                                => array('b'),
1278 1278
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1279 1279
 							'b',
1280 1280
 							'o'
@@ -1283,56 +1283,56 @@  discard block
 block discarded – undo
1283 1283
 							'b',
1284 1284
 							'o'
1285 1285
 						),
1286
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1287
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1288
-						'.page-link'                                                                                           => array( 'c' ),
1286
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1287
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1288
+						'.page-link'                                                                                           => array('c'),
1289 1289
 						'.page-item.active .page-link'                                                                         => array(
1290 1290
 							'b',
1291 1291
 							'o'
1292 1292
 						),
1293
-						'.progress-bar'                                                                                        => array( 'b' ),
1293
+						'.progress-bar'                                                                                        => array('b'),
1294 1294
 						'.list-group-item.active'                                                                              => array(
1295 1295
 							'b',
1296 1296
 							'o'
1297 1297
 						),
1298
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1298
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1299 1299
 					);
1300 1300
 			}
1301 1301
 
1302 1302
 
1303 1303
 
1304 1304
             // link
1305
-			if ( $type === 'primary' ) {
1306
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1307
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1308
-				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: '.esc_attr($color_code).'; --bs-navbar-hover-color: '.esc_attr($color_code).'; --bs-navbar-active-color: '.esc_attr($color_code).'; }';
1305
+			if ($type === 'primary') {
1306
+				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .75); --bs-link-color: var(--bs-' . esc_attr($type) . '); }';
1307
+				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: ' . esc_attr($color_code) . ';  }';
1308
+				$output .= $prefix . ' .navbar { --bs-nav-link-hover-color: ' . esc_attr($color_code) . '; --bs-navbar-hover-color: ' . esc_attr($color_code) . '; --bs-navbar-active-color: ' . esc_attr($color_code) . '; }';
1309 1309
 
1310
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1311
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1310
+				$output .= $prefix . ' a{color: var(--bs-' . esc_attr($type) . ');}';
1311
+				$output .= $prefix . ' .text-primary{color: var(--bs-' . esc_attr($type) . ') !important;}';
1312 1312
 
1313 1313
                 // dropdown
1314
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1314
+				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-' . esc_attr($type) . '); --bs-dropdown-link-active-color: var(--bs-' . esc_attr($type) . ');}';
1315 1315
 
1316 1316
                 // pagination
1317
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1317
+				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-' . esc_attr($type) . '); --bs-pagination-active-bg: var(--bs-' . esc_attr($type) . ');}';
1318 1318
 
1319 1319
 			}
1320 1320
 
1321
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1321
+			$output .= $prefix . ' .link-' . esc_attr($type) . ':hover {color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .8) !important;}';
1322 1322
 
1323 1323
 			//  buttons
1324
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1324
+			$output .= $prefix . ' .btn-' . esc_attr($type) . '{';
1325 1325
 			$output .= ' 
1326
-            --bs-btn-bg: '.esc_attr($color_code).';
1327
-            --bs-btn-border-color: '.esc_attr($color_code).';
1328
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1329
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1330
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1331
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1332
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1326
+            --bs-btn-bg: '.esc_attr($color_code) . ';
1327
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1328
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1329
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1330
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1331
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1332
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1333 1333
             --bs-btn-active-shadow: unset;
1334
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1335
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1334
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1335
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1336 1336
             ';
1337 1337
 //			$output .= '
1338 1338
 //		    --bs-btn-color: #fff;
@@ -1343,17 +1343,17 @@  discard block
 block discarded – undo
1343 1343
 			$output .= '}';
1344 1344
 
1345 1345
 			//  buttons outline
1346
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1346
+			$output .= $prefix . ' .btn-outline-' . esc_attr($type) . '{';
1347 1347
 			$output .= ' 
1348
-            --bs-btn-border-color: '.esc_attr($color_code).';
1349
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1350
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1351
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1352
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1353
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1348
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1349
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1350
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1351
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1352
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1353
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1354 1354
             --bs-btn-active-shadow: unset;
1355
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1356
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1355
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1356
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1357 1357
             ';
1358 1358
 //			$output .= '
1359 1359
 //		    --bs-btn-color: #fff;
@@ -1365,32 +1365,32 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
 
1367 1367
             // button hover
1368
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1368
+			$output .= $prefix . ' .btn-' . esc_attr($type) . ':hover{';
1369 1369
 			$output .= ' 
1370
-            box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4);
1370
+            box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type) . '-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-' . esc_attr($type) . '-rgb) , .4);
1371 1371
             }
1372 1372
             ';
1373 1373
 
1374 1374
 
1375
-			if ( $aui_bs5 ) {
1375
+			if ($aui_bs5) {
1376 1376
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1377
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1378
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1377
+				$output .= 'html body {--bs-' . esc_attr($type) . ': ' . esc_attr($color_code) . '; }';
1378
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1379 1379
 			}
1380 1380
 
1381 1381
 
1382
-			if ( $is_custom ) {
1382
+			if ($is_custom) {
1383 1383
 
1384 1384
 //				echo '###'.$type;exit;
1385 1385
 
1386 1386
 				// build rules into each type
1387
-				foreach($selectors as $selector => $types){
1388
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1389
-					$types = array_combine($types,$types);
1390
-					if(isset($types['c'])){$color[] = $selector;}
1391
-					if(isset($types['b'])){$background[] = $selector;}
1392
-					if(isset($types['o'])){$border[] = $selector;}
1393
-					if(isset($types['f'])){$fill[] = $selector;}
1387
+				foreach ($selectors as $selector => $types) {
1388
+					$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1389
+					$types = array_combine($types, $types);
1390
+					if (isset($types['c'])) {$color[] = $selector; }
1391
+					if (isset($types['b'])) {$background[] = $selector; }
1392
+					if (isset($types['o'])) {$border[] = $selector; }
1393
+					if (isset($types['f'])) {$fill[] = $selector; }
1394 1394
 				}
1395 1395
 
1396 1396
 //				// build rules into each type
@@ -1404,36 +1404,36 @@  discard block
 block discarded – undo
1404 1404
 //				}
1405 1405
 
1406 1406
 				// add any color rules
1407
-				if(!empty($color)){
1408
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1407
+				if (!empty($color)) {
1408
+					$output .= implode(",", $color) . "{color: $color_code;} ";
1409 1409
 				}
1410
-				if(!empty($color_i)){
1411
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1410
+				if (!empty($color_i)) {
1411
+					$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1412 1412
 				}
1413 1413
 
1414 1414
 				// add any background color rules
1415
-				if(!empty($background)){
1416
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1415
+				if (!empty($background)) {
1416
+					$output .= implode(",", $background) . "{background-color: $color_code;} ";
1417 1417
 				}
1418
-				if(!empty($background_i)){
1419
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1418
+				if (!empty($background_i)) {
1419
+					$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1420 1420
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1421 1421
 				}
1422 1422
 
1423 1423
 				// add any border color rules
1424
-				if(!empty($border)){
1425
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1424
+				if (!empty($border)) {
1425
+					$output .= implode(",", $border) . "{border-color: $color_code;} ";
1426 1426
 				}
1427
-				if(!empty($border_i)){
1428
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1427
+				if (!empty($border_i)) {
1428
+					$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1429 1429
 				}
1430 1430
 
1431 1431
 				// add any fill color rules
1432
-				if(!empty($fill)){
1433
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1432
+				if (!empty($fill)) {
1433
+					$output .= implode(",", $fill) . "{fill: $color_code;} ";
1434 1434
 				}
1435
-				if(!empty($fill_i)){
1436
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1435
+				if (!empty($fill_i)) {
1436
+					$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1437 1437
 				}
1438 1438
 
1439 1439
 			}
@@ -1443,25 +1443,25 @@  discard block
 block discarded – undo
1443 1443
 
1444 1444
 			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1445 1445
 			// darken
1446
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1447
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1448
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1449
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1446
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1447
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1448
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1449
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1450 1450
 
1451 1451
 			// lighten
1452
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1452
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1453 1453
 
1454 1454
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1455
-			$op_25 = $color_code."40"; // 25% opacity
1455
+			$op_25 = $color_code . "40"; // 25% opacity
1456 1456
 
1457 1457
 
1458 1458
 			// button states
1459
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1460
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1459
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1460
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1461 1461
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1462
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1463
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1464
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1462
+			$output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1463
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1464
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1465 1465
 
1466 1466
 			// text
1467 1467
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
@@ -1479,9 +1479,9 @@  discard block
 block discarded – undo
1479 1479
 //			}
1480 1480
 
1481 1481
 			// alerts
1482
-			if ( $aui_bs5 ) {
1482
+			if ($aui_bs5) {
1483 1483
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1484
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1484
+				$output .= $prefix . " .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1485 1485
 			}
1486 1486
 
1487 1487
 			return $output;
@@ -1496,12 +1496,12 @@  discard block
 block discarded – undo
1496 1496
 		 *
1497 1497
 		 * @return string
1498 1498
 		 */
1499
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1499
+		public static function css_overwrite($type, $color_code, $compatibility, $hex = '') {
1500 1500
             global $aui_bs5;
1501 1501
 
1502 1502
 			$is_var = false;
1503
-			if(!$color_code){return '';}
1504
-			if(strpos($color_code, 'var') !== false){
1503
+			if (!$color_code) {return ''; }
1504
+			if (strpos($color_code, 'var') !== false) {
1505 1505
 				//if(!sanitize_hex_color($color_code)){
1506 1506
 				$color_code = esc_attr($color_code);
1507 1507
 				$is_var = true;
@@ -1511,15 +1511,15 @@  discard block
 block discarded – undo
1511 1511
 
1512 1512
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1513 1513
 
1514
-			if(!$color_code){return '';}
1514
+			if (!$color_code) {return ''; }
1515 1515
 
1516 1516
             $rgb = self::hex_to_rgb($hex);
1517 1517
 
1518
-			if($compatibility===true || $compatibility===1){
1518
+			if ($compatibility === true || $compatibility === 1) {
1519 1519
 				$compatibility = '.bsui';
1520
-			}elseif(!$compatibility){
1520
+			}elseif (!$compatibility) {
1521 1521
 				$compatibility = '';
1522
-			}else{
1522
+			} else {
1523 1523
 				$compatibility = esc_attr($compatibility);
1524 1524
 			}
1525 1525
 
@@ -1533,29 +1533,29 @@  discard block
 block discarded – undo
1533 1533
 			 * c = color, b = background color, o = border-color, f = fill
1534 1534
 			 */
1535 1535
 			$selectors = array(
1536
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1537
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1538
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1539
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1540
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1541
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1542
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1543
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1544
-				".badge-{$type}"                                            => array( 'b' ),
1545
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1546
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1547
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1536
+				".btn-{$type}"                                              => array('b', 'o'),
1537
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1538
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1539
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1540
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1541
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1542
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1543
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1544
+				".badge-{$type}"                                            => array('b'),
1545
+				".alert-{$type}"                                            => array('b', 'o'),
1546
+				".bg-{$type}"                                               => array('b', 'f'),
1547
+				".btn-link.btn-{$type}"                                     => array('c'),
1548 1548
 			);
1549 1549
 
1550
-			if ( $aui_bs5 ) {
1551
-                unset($selectors[".alert-{$type}" ]);
1550
+			if ($aui_bs5) {
1551
+                unset($selectors[".alert-{$type}"]);
1552 1552
 			}
1553 1553
 
1554
-			if ( $type == 'primary' ) {
1554
+			if ($type == 'primary') {
1555 1555
 				$selectors = $selectors + array(
1556
-						'a'                                                                                                    => array( 'c' ),
1557
-						'.btn-link'                                                                                            => array( 'c' ),
1558
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1556
+						'a'                                                                                                    => array('c'),
1557
+						'.btn-link'                                                                                            => array('c'),
1558
+						'.dropdown-item.active'                                                                                => array('b'),
1559 1559
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1560 1560
 							'b',
1561 1561
 							'o'
@@ -1564,19 +1564,19 @@  discard block
 block discarded – undo
1564 1564
 							'b',
1565 1565
 							'o'
1566 1566
 						),
1567
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1568
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1569
-						'.page-link'                                                                                           => array( 'c' ),
1567
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1568
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1569
+						'.page-link'                                                                                           => array('c'),
1570 1570
 						'.page-item.active .page-link'                                                                         => array(
1571 1571
 							'b',
1572 1572
 							'o'
1573 1573
 						),
1574
-						'.progress-bar'                                                                                        => array( 'b' ),
1574
+						'.progress-bar'                                                                                        => array('b'),
1575 1575
 						'.list-group-item.active'                                                                              => array(
1576 1576
 							'b',
1577 1577
 							'o'
1578 1578
 						),
1579
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1579
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1580 1580
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1581 1581
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1582 1582
 //				    '.custom-range::-ms-thumb' => array('b'),
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 			}
1585 1585
 
1586 1586
 			$important_selectors = array(
1587
-				".bg-{$type}" => array('b','f'),
1587
+				".bg-{$type}" => array('b', 'f'),
1588 1588
 				".border-{$type}" => array('o'),
1589 1589
 				".text-{$type}" => array('c'),
1590 1590
 			);
@@ -1600,62 +1600,62 @@  discard block
 block discarded – undo
1600 1600
 
1601 1601
 			$output = '';
1602 1602
 
1603
-			if ( $aui_bs5 ) {
1603
+			if ($aui_bs5) {
1604 1604
 //				$output .= $is_var ? 'html body {--bs-'.esc_attr($type).'-rgb: '.$color_code.'; }' : 'html body {--bs-'.esc_attr($type).'-rgb: '.self::hex_to_rgb($color_code).'; }';
1605
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1605
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1606 1606
 			}
1607 1607
 
1608 1608
 			// build rules into each type
1609
-			foreach($selectors as $selector => $types){
1610
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1611
-				$types = array_combine($types,$types);
1612
-				if(isset($types['c'])){$color[] = $selector;}
1613
-				if(isset($types['b'])){$background[] = $selector;}
1614
-				if(isset($types['o'])){$border[] = $selector;}
1615
-				if(isset($types['f'])){$fill[] = $selector;}
1609
+			foreach ($selectors as $selector => $types) {
1610
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1611
+				$types = array_combine($types, $types);
1612
+				if (isset($types['c'])) {$color[] = $selector; }
1613
+				if (isset($types['b'])) {$background[] = $selector; }
1614
+				if (isset($types['o'])) {$border[] = $selector; }
1615
+				if (isset($types['f'])) {$fill[] = $selector; }
1616 1616
 			}
1617 1617
 
1618 1618
 			// build rules into each type
1619
-			foreach($important_selectors as $selector => $types){
1620
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1621
-				$types = array_combine($types,$types);
1622
-				if(isset($types['c'])){$color_i[] = $selector;}
1623
-				if(isset($types['b'])){$background_i[] = $selector;}
1624
-				if(isset($types['o'])){$border_i[] = $selector;}
1625
-				if(isset($types['f'])){$fill_i[] = $selector;}
1619
+			foreach ($important_selectors as $selector => $types) {
1620
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1621
+				$types = array_combine($types, $types);
1622
+				if (isset($types['c'])) {$color_i[] = $selector; }
1623
+				if (isset($types['b'])) {$background_i[] = $selector; }
1624
+				if (isset($types['o'])) {$border_i[] = $selector; }
1625
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1626 1626
 			}
1627 1627
 
1628 1628
 			// add any color rules
1629
-			if(!empty($color)){
1630
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1629
+			if (!empty($color)) {
1630
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1631 1631
 			}
1632
-			if(!empty($color_i)){
1633
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1632
+			if (!empty($color_i)) {
1633
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1634 1634
 			}
1635 1635
 
1636 1636
 			// add any background color rules
1637
-			if(!empty($background)){
1638
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1637
+			if (!empty($background)) {
1638
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1639 1639
 			}
1640
-			if(!empty($background_i)){
1641
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1640
+			if (!empty($background_i)) {
1641
+				$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1642 1642
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1643 1643
 			}
1644 1644
 
1645 1645
 			// add any border color rules
1646
-			if(!empty($border)){
1647
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1646
+			if (!empty($border)) {
1647
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1648 1648
 			}
1649
-			if(!empty($border_i)){
1650
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1649
+			if (!empty($border_i)) {
1650
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1651 1651
 			}
1652 1652
 
1653 1653
 			// add any fill color rules
1654
-			if(!empty($fill)){
1655
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1654
+			if (!empty($fill)) {
1655
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1656 1656
 			}
1657
-			if(!empty($fill_i)){
1658
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1657
+			if (!empty($fill_i)) {
1658
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1659 1659
 			}
1660 1660
 
1661 1661
 
@@ -1663,27 +1663,27 @@  discard block
 block discarded – undo
1663 1663
 
1664 1664
 			$transition = $is_var ? 'transition: color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,filter 0.15s ease-in-out;' : '';
1665 1665
 			// darken
1666
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1667
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1668
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1669
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1666
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1667
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1668
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1669
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1670 1670
 
1671 1671
 			// lighten
1672
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1672
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1673 1673
 
1674 1674
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1675
-			$op_25 = $color_code."40"; // 25% opacity
1675
+			$op_25 = $color_code . "40"; // 25% opacity
1676 1676
 
1677 1677
 
1678 1678
 			// button states
1679
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1680
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1679
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1680
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1681 1681
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1682
-			$output .= $prefix ." .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1683
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1684
-			$output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1682
+			$output .= $prefix . " .btn-outline-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-{$type}.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1683
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active, $prefix .btn-{$type}:not(:disabled):not(.disabled).active, .show>$prefix .btn-{$type}.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1684
+			$output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-{$type}.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1685 1685
 
1686
-			if ( $type == 'primary' ) {
1686
+			if ($type == 'primary') {
1687 1687
 				// dropdown's
1688 1688
 				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1689 1689
 
@@ -1695,9 +1695,9 @@  discard block
 block discarded – undo
1695 1695
 			}
1696 1696
 
1697 1697
             // alerts
1698
-			if ( $aui_bs5 ) {
1698
+			if ($aui_bs5) {
1699 1699
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1700
-				$output .= $prefix ." .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1700
+				$output .= $prefix . " .alert-{$type} {--bs-alert-bg: rgba(var(--bs-{$type}-rgb), .1 ) !important;--bs-alert-border-color: rgba(var(--bs-{$type}-rgb), .25 ) !important;--bs-alert-color: rgba(var(--bs-{$type}-rgb), 1 ) !important;} ";
1701 1701
 			}
1702 1702
 
1703 1703
 			return $output;
@@ -1713,11 +1713,11 @@  discard block
 block discarded – undo
1713 1713
 		 *
1714 1714
 		 * @return string
1715 1715
 		 */
1716
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1716
+		public static function css_primary($color_code, $compatibility, $use_variable = false) {
1717 1717
 
1718
-			if(!$use_variable){
1718
+			if (!$use_variable) {
1719 1719
 				$color_code = sanitize_hex_color($color_code);
1720
-				if(!$color_code){return '';}
1720
+				if (!$color_code) {return ''; }
1721 1721
 			}
1722 1722
 
1723 1723
 			/**
@@ -1725,36 +1725,36 @@  discard block
 block discarded – undo
1725 1725
 			 */
1726 1726
 			$selectors = array(
1727 1727
 				'a' => array('c'),
1728
-				'.btn-primary' => array('b','o'),
1729
-				'.btn-primary.disabled' => array('b','o'),
1730
-				'.btn-primary:disabled' => array('b','o'),
1731
-				'.btn-outline-primary' => array('c','o'),
1732
-				'.btn-outline-primary:hover' => array('b','o'),
1733
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1734
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1735
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1728
+				'.btn-primary' => array('b', 'o'),
1729
+				'.btn-primary.disabled' => array('b', 'o'),
1730
+				'.btn-primary:disabled' => array('b', 'o'),
1731
+				'.btn-outline-primary' => array('c', 'o'),
1732
+				'.btn-outline-primary:hover' => array('b', 'o'),
1733
+				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'),
1734
+				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'),
1735
+				'.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'),
1736 1736
 				'.btn-link' => array('c'),
1737 1737
 				'.dropdown-item.active' => array('b'),
1738
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1739
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1738
+				'.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'),
1739
+				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'),
1740 1740
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1741 1741
 //				'.custom-range::-moz-range-thumb' => array('b'),
1742 1742
 //				'.custom-range::-ms-thumb' => array('b'),
1743 1743
 				'.nav-pills .nav-link.active' => array('b'),
1744 1744
 				'.nav-pills .show>.nav-link' => array('b'),
1745 1745
 				'.page-link' => array('c'),
1746
-				'.page-item.active .page-link' => array('b','o'),
1746
+				'.page-item.active .page-link' => array('b', 'o'),
1747 1747
 				'.badge-primary' => array('b'),
1748
-				'.alert-primary' => array('b','o'),
1748
+				'.alert-primary' => array('b', 'o'),
1749 1749
 				'.progress-bar' => array('b'),
1750
-				'.list-group-item.active' => array('b','o'),
1751
-				'.bg-primary' => array('b','f'),
1750
+				'.list-group-item.active' => array('b', 'o'),
1751
+				'.bg-primary' => array('b', 'f'),
1752 1752
 				'.btn-link.btn-primary' => array('c'),
1753 1753
 				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1754 1754
 			);
1755 1755
 
1756 1756
 			$important_selectors = array(
1757
-				'.bg-primary' => array('b','f'),
1757
+				'.bg-primary' => array('b', 'f'),
1758 1758
 				'.border-primary' => array('o'),
1759 1759
 				'.text-primary' => array('c'),
1760 1760
 			);
@@ -1771,88 +1771,88 @@  discard block
 block discarded – undo
1771 1771
 			$output = '';
1772 1772
 
1773 1773
 			// build rules into each type
1774
-			foreach($selectors as $selector => $types){
1775
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1776
-				$types = array_combine($types,$types);
1777
-				if(isset($types['c'])){$color[] = $selector;}
1778
-				if(isset($types['b'])){$background[] = $selector;}
1779
-				if(isset($types['o'])){$border[] = $selector;}
1780
-				if(isset($types['f'])){$fill[] = $selector;}
1774
+			foreach ($selectors as $selector => $types) {
1775
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1776
+				$types = array_combine($types, $types);
1777
+				if (isset($types['c'])) {$color[] = $selector; }
1778
+				if (isset($types['b'])) {$background[] = $selector; }
1779
+				if (isset($types['o'])) {$border[] = $selector; }
1780
+				if (isset($types['f'])) {$fill[] = $selector; }
1781 1781
 			}
1782 1782
 
1783 1783
 			// build rules into each type
1784
-			foreach($important_selectors as $selector => $types){
1785
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1786
-				$types = array_combine($types,$types);
1787
-				if(isset($types['c'])){$color_i[] = $selector;}
1788
-				if(isset($types['b'])){$background_i[] = $selector;}
1789
-				if(isset($types['o'])){$border_i[] = $selector;}
1790
-				if(isset($types['f'])){$fill_i[] = $selector;}
1784
+			foreach ($important_selectors as $selector => $types) {
1785
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1786
+				$types = array_combine($types, $types);
1787
+				if (isset($types['c'])) {$color_i[] = $selector; }
1788
+				if (isset($types['b'])) {$background_i[] = $selector; }
1789
+				if (isset($types['o'])) {$border_i[] = $selector; }
1790
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1791 1791
 			}
1792 1792
 
1793 1793
 			// add any color rules
1794
-			if(!empty($color)){
1795
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1794
+			if (!empty($color)) {
1795
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1796 1796
 			}
1797
-			if(!empty($color_i)){
1798
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1797
+			if (!empty($color_i)) {
1798
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1799 1799
 			}
1800 1800
 
1801 1801
 			// add any background color rules
1802
-			if(!empty($background)){
1803
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1802
+			if (!empty($background)) {
1803
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1804 1804
 			}
1805
-			if(!empty($background_i)){
1806
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1805
+			if (!empty($background_i)) {
1806
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
1807 1807
 			}
1808 1808
 
1809 1809
 			// add any border color rules
1810
-			if(!empty($border)){
1811
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1810
+			if (!empty($border)) {
1811
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1812 1812
 			}
1813
-			if(!empty($border_i)){
1814
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1813
+			if (!empty($border_i)) {
1814
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1815 1815
 			}
1816 1816
 
1817 1817
 			// add any fill color rules
1818
-			if(!empty($fill)){
1819
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1818
+			if (!empty($fill)) {
1819
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1820 1820
 			}
1821
-			if(!empty($fill_i)){
1822
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1821
+			if (!empty($fill_i)) {
1822
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1823 1823
 			}
1824 1824
 
1825 1825
 
1826 1826
 			$prefix = $compatibility ? ".bsui " : "";
1827 1827
 
1828 1828
 			// darken
1829
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1830
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1831
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1829
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
1830
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
1831
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
1832 1832
 
1833 1833
 			// lighten
1834
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1834
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
1835 1835
 
1836 1836
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1837
-			$op_25 = $color_code."40"; // 25% opacity
1837
+			$op_25 = $color_code . "40"; // 25% opacity
1838 1838
 
1839 1839
 
1840 1840
 			// button states
1841
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1842
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1843
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1844
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1841
+			$output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1842
+			$output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1843
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1844
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1845 1845
 
1846 1846
 
1847 1847
 			// dropdown's
1848
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1848
+			$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1849 1849
 
1850 1850
 
1851 1851
 			// input states
1852
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1852
+			$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1853 1853
 
1854 1854
 			// page link
1855
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1855
+			$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1856 1856
 
1857 1857
 			return $output;
1858 1858
 		}
@@ -1866,30 +1866,30 @@  discard block
 block discarded – undo
1866 1866
 		 *
1867 1867
 		 * @return string
1868 1868
 		 */
1869
-		public static function css_secondary($color_code,$compatibility){;
1869
+		public static function css_secondary($color_code, $compatibility) {;
1870 1870
 			$color_code = sanitize_hex_color($color_code);
1871
-			if(!$color_code){return '';}
1871
+			if (!$color_code) {return ''; }
1872 1872
 			/**
1873 1873
 			 * c = color, b = background color, o = border-color, f = fill
1874 1874
 			 */
1875 1875
 			$selectors = array(
1876
-				'.btn-secondary' => array('b','o'),
1877
-				'.btn-secondary.disabled' => array('b','o'),
1878
-				'.btn-secondary:disabled' => array('b','o'),
1879
-				'.btn-outline-secondary' => array('c','o'),
1880
-				'.btn-outline-secondary:hover' => array('b','o'),
1876
+				'.btn-secondary' => array('b', 'o'),
1877
+				'.btn-secondary.disabled' => array('b', 'o'),
1878
+				'.btn-secondary:disabled' => array('b', 'o'),
1879
+				'.btn-outline-secondary' => array('c', 'o'),
1880
+				'.btn-outline-secondary:hover' => array('b', 'o'),
1881 1881
 				'.btn-outline-secondary.disabled' => array('c'),
1882 1882
 				'.btn-outline-secondary:disabled' => array('c'),
1883
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1884
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
1885
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1883
+				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'),
1884
+				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'),
1885
+				'.btn-outline-secondary.dropdown-toggle' => array('b', 'o'),
1886 1886
 				'.badge-secondary' => array('b'),
1887
-				'.alert-secondary' => array('b','o'),
1887
+				'.alert-secondary' => array('b', 'o'),
1888 1888
 				'.btn-link.btn-secondary' => array('c'),
1889 1889
 			);
1890 1890
 
1891 1891
 			$important_selectors = array(
1892
-				'.bg-secondary' => array('b','f'),
1892
+				'.bg-secondary' => array('b', 'f'),
1893 1893
 				'.border-secondary' => array('o'),
1894 1894
 				'.text-secondary' => array('c'),
1895 1895
 			);
@@ -1906,77 +1906,77 @@  discard block
 block discarded – undo
1906 1906
 			$output = '';
1907 1907
 
1908 1908
 			// build rules into each type
1909
-			foreach($selectors as $selector => $types){
1910
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1911
-				$types = array_combine($types,$types);
1912
-				if(isset($types['c'])){$color[] = $selector;}
1913
-				if(isset($types['b'])){$background[] = $selector;}
1914
-				if(isset($types['o'])){$border[] = $selector;}
1915
-				if(isset($types['f'])){$fill[] = $selector;}
1909
+			foreach ($selectors as $selector => $types) {
1910
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1911
+				$types = array_combine($types, $types);
1912
+				if (isset($types['c'])) {$color[] = $selector; }
1913
+				if (isset($types['b'])) {$background[] = $selector; }
1914
+				if (isset($types['o'])) {$border[] = $selector; }
1915
+				if (isset($types['f'])) {$fill[] = $selector; }
1916 1916
 			}
1917 1917
 
1918 1918
 			// build rules into each type
1919
-			foreach($important_selectors as $selector => $types){
1920
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1921
-				$types = array_combine($types,$types);
1922
-				if(isset($types['c'])){$color_i[] = $selector;}
1923
-				if(isset($types['b'])){$background_i[] = $selector;}
1924
-				if(isset($types['o'])){$border_i[] = $selector;}
1925
-				if(isset($types['f'])){$fill_i[] = $selector;}
1919
+			foreach ($important_selectors as $selector => $types) {
1920
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1921
+				$types = array_combine($types, $types);
1922
+				if (isset($types['c'])) {$color_i[] = $selector; }
1923
+				if (isset($types['b'])) {$background_i[] = $selector; }
1924
+				if (isset($types['o'])) {$border_i[] = $selector; }
1925
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1926 1926
 			}
1927 1927
 
1928 1928
 			// add any color rules
1929
-			if(!empty($color)){
1930
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1929
+			if (!empty($color)) {
1930
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1931 1931
 			}
1932
-			if(!empty($color_i)){
1933
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1932
+			if (!empty($color_i)) {
1933
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1934 1934
 			}
1935 1935
 
1936 1936
 			// add any background color rules
1937
-			if(!empty($background)){
1938
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1937
+			if (!empty($background)) {
1938
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1939 1939
 			}
1940
-			if(!empty($background_i)){
1941
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1940
+			if (!empty($background_i)) {
1941
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
1942 1942
 			}
1943 1943
 
1944 1944
 			// add any border color rules
1945
-			if(!empty($border)){
1946
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1945
+			if (!empty($border)) {
1946
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1947 1947
 			}
1948
-			if(!empty($border_i)){
1949
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1948
+			if (!empty($border_i)) {
1949
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1950 1950
 			}
1951 1951
 
1952 1952
 			// add any fill color rules
1953
-			if(!empty($fill)){
1954
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1953
+			if (!empty($fill)) {
1954
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1955 1955
 			}
1956
-			if(!empty($fill_i)){
1957
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1956
+			if (!empty($fill_i)) {
1957
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1958 1958
 			}
1959 1959
 
1960 1960
 
1961 1961
 			$prefix = $compatibility ? ".bsui " : "";
1962 1962
 
1963 1963
 			// darken
1964
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1965
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1966
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1964
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
1965
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
1966
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
1967 1967
 
1968 1968
 			// lighten
1969
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1969
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
1970 1970
 
1971 1971
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1972
-			$op_25 = $color_code."40"; // 25% opacity
1972
+			$op_25 = $color_code . "40"; // 25% opacity
1973 1973
 
1974 1974
 
1975 1975
 			// button states
1976
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1977
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1978
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1979
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1976
+			$output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1977
+			$output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1978
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1979
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1980 1980
 
1981 1981
 
1982 1982
 			return $output;
@@ -2012,8 +2012,8 @@  discard block
 block discarded – undo
2012 2012
 		/**
2013 2013
 		 * Check if we should display examples.
2014 2014
 		 */
2015
-		public function maybe_show_examples(){
2016
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2015
+		public function maybe_show_examples() {
2016
+			if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
2017 2017
 				echo "<head>";
2018 2018
 				wp_head();
2019 2019
 				echo "</head>";
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 		 *
2030 2030
 		 * @return string
2031 2031
 		 */
2032
-		public function get_examples(){
2032
+		public function get_examples() {
2033 2033
 			$output = '';
2034 2034
 
2035 2035
 
@@ -2135,74 +2135,74 @@  discard block
 block discarded – undo
2135 2135
 		 */
2136 2136
 		public static function calendar_params() {
2137 2137
 			$params = array(
2138
-				'month_long_1' => __( 'January', 'aui' ),
2139
-				'month_long_2' => __( 'February', 'aui' ),
2140
-				'month_long_3' => __( 'March', 'aui' ),
2141
-				'month_long_4' => __( 'April', 'aui' ),
2142
-				'month_long_5' => __( 'May', 'aui' ),
2143
-				'month_long_6' => __( 'June', 'aui' ),
2144
-				'month_long_7' => __( 'July', 'aui' ),
2145
-				'month_long_8' => __( 'August', 'aui' ),
2146
-				'month_long_9' => __( 'September', 'aui' ),
2147
-				'month_long_10' => __( 'October', 'aui' ),
2148
-				'month_long_11' => __( 'November', 'aui' ),
2149
-				'month_long_12' => __( 'December', 'aui' ),
2150
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
2151
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
2152
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
2153
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
2154
-				'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
2155
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
2156
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
2157
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
2158
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
2159
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
2160
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
2161
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
2162
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
2163
-				'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
2164
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
2165
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
2166
-				'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
2167
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
2168
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
2169
-				'day_s2_1' => __( 'Su', 'aui' ),
2170
-				'day_s2_2' => __( 'Mo', 'aui' ),
2171
-				'day_s2_3' => __( 'Tu', 'aui' ),
2172
-				'day_s2_4' => __( 'We', 'aui' ),
2173
-				'day_s2_5' => __( 'Th', 'aui' ),
2174
-				'day_s2_6' => __( 'Fr', 'aui' ),
2175
-				'day_s2_7' => __( 'Sa', 'aui' ),
2176
-				'day_s3_1' => __( 'Sun', 'aui' ),
2177
-				'day_s3_2' => __( 'Mon', 'aui' ),
2178
-				'day_s3_3' => __( 'Tue', 'aui' ),
2179
-				'day_s3_4' => __( 'Wed', 'aui' ),
2180
-				'day_s3_5' => __( 'Thu', 'aui' ),
2181
-				'day_s3_6' => __( 'Fri', 'aui' ),
2182
-				'day_s3_7' => __( 'Sat', 'aui' ),
2183
-				'day_s5_1' => __( 'Sunday', 'aui' ),
2184
-				'day_s5_2' => __( 'Monday', 'aui' ),
2185
-				'day_s5_3' => __( 'Tuesday', 'aui' ),
2186
-				'day_s5_4' => __( 'Wednesday', 'aui' ),
2187
-				'day_s5_5' => __( 'Thursday', 'aui' ),
2188
-				'day_s5_6' => __( 'Friday', 'aui' ),
2189
-				'day_s5_7' => __( 'Saturday', 'aui' ),
2190
-				'am_lower' => __( 'am', 'aui' ),
2191
-				'pm_lower' => __( 'pm', 'aui' ),
2192
-				'am_upper' => __( 'AM', 'aui' ),
2193
-				'pm_upper' => __( 'PM', 'aui' ),
2194
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2138
+				'month_long_1' => __('January', 'aui'),
2139
+				'month_long_2' => __('February', 'aui'),
2140
+				'month_long_3' => __('March', 'aui'),
2141
+				'month_long_4' => __('April', 'aui'),
2142
+				'month_long_5' => __('May', 'aui'),
2143
+				'month_long_6' => __('June', 'aui'),
2144
+				'month_long_7' => __('July', 'aui'),
2145
+				'month_long_8' => __('August', 'aui'),
2146
+				'month_long_9' => __('September', 'aui'),
2147
+				'month_long_10' => __('October', 'aui'),
2148
+				'month_long_11' => __('November', 'aui'),
2149
+				'month_long_12' => __('December', 'aui'),
2150
+				'month_s_1' => _x('Jan', 'January abbreviation', 'aui'),
2151
+				'month_s_2' => _x('Feb', 'February abbreviation', 'aui'),
2152
+				'month_s_3' => _x('Mar', 'March abbreviation', 'aui'),
2153
+				'month_s_4' => _x('Apr', 'April abbreviation', 'aui'),
2154
+				'month_s_5' => _x('May', 'May abbreviation', 'aui'),
2155
+				'month_s_6' => _x('Jun', 'June abbreviation', 'aui'),
2156
+				'month_s_7' => _x('Jul', 'July abbreviation', 'aui'),
2157
+				'month_s_8' => _x('Aug', 'August abbreviation', 'aui'),
2158
+				'month_s_9' => _x('Sep', 'September abbreviation', 'aui'),
2159
+				'month_s_10' => _x('Oct', 'October abbreviation', 'aui'),
2160
+				'month_s_11' => _x('Nov', 'November abbreviation', 'aui'),
2161
+				'month_s_12' => _x('Dec', 'December abbreviation', 'aui'),
2162
+				'day_s1_1' => _x('S', 'Sunday initial', 'aui'),
2163
+				'day_s1_2' => _x('M', 'Monday initial', 'aui'),
2164
+				'day_s1_3' => _x('T', 'Tuesday initial', 'aui'),
2165
+				'day_s1_4' => _x('W', 'Wednesday initial', 'aui'),
2166
+				'day_s1_5' => _x('T', 'Friday initial', 'aui'),
2167
+				'day_s1_6' => _x('F', 'Thursday initial', 'aui'),
2168
+				'day_s1_7' => _x('S', 'Saturday initial', 'aui'),
2169
+				'day_s2_1' => __('Su', 'aui'),
2170
+				'day_s2_2' => __('Mo', 'aui'),
2171
+				'day_s2_3' => __('Tu', 'aui'),
2172
+				'day_s2_4' => __('We', 'aui'),
2173
+				'day_s2_5' => __('Th', 'aui'),
2174
+				'day_s2_6' => __('Fr', 'aui'),
2175
+				'day_s2_7' => __('Sa', 'aui'),
2176
+				'day_s3_1' => __('Sun', 'aui'),
2177
+				'day_s3_2' => __('Mon', 'aui'),
2178
+				'day_s3_3' => __('Tue', 'aui'),
2179
+				'day_s3_4' => __('Wed', 'aui'),
2180
+				'day_s3_5' => __('Thu', 'aui'),
2181
+				'day_s3_6' => __('Fri', 'aui'),
2182
+				'day_s3_7' => __('Sat', 'aui'),
2183
+				'day_s5_1' => __('Sunday', 'aui'),
2184
+				'day_s5_2' => __('Monday', 'aui'),
2185
+				'day_s5_3' => __('Tuesday', 'aui'),
2186
+				'day_s5_4' => __('Wednesday', 'aui'),
2187
+				'day_s5_5' => __('Thursday', 'aui'),
2188
+				'day_s5_6' => __('Friday', 'aui'),
2189
+				'day_s5_7' => __('Saturday', 'aui'),
2190
+				'am_lower' => __('am', 'aui'),
2191
+				'pm_lower' => __('pm', 'aui'),
2192
+				'am_upper' => __('AM', 'aui'),
2193
+				'pm_upper' => __('PM', 'aui'),
2194
+				'firstDayOfWeek' => (int) get_option('start_of_week'),
2195 2195
 				'time_24hr' => false,
2196
-				'year' => __( 'Year', 'aui' ),
2197
-				'hour' => __( 'Hour', 'aui' ),
2198
-				'minute' => __( 'Minute', 'aui' ),
2199
-				'weekAbbreviation' => __( 'Wk', 'aui' ),
2200
-				'rangeSeparator' => __( ' to ', 'aui' ),
2201
-				'scrollTitle' => __( 'Scroll to increment', 'aui' ),
2202
-				'toggleTitle' => __( 'Click to toggle', 'aui' )
2196
+				'year' => __('Year', 'aui'),
2197
+				'hour' => __('Hour', 'aui'),
2198
+				'minute' => __('Minute', 'aui'),
2199
+				'weekAbbreviation' => __('Wk', 'aui'),
2200
+				'rangeSeparator' => __(' to ', 'aui'),
2201
+				'scrollTitle' => __('Scroll to increment', 'aui'),
2202
+				'toggleTitle' => __('Click to toggle', 'aui')
2203 2203
 			);
2204 2204
 
2205
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2205
+			return apply_filters('ayecode_ui_calendar_params', $params);
2206 2206
 		}
2207 2207
 
2208 2208
 		/**
@@ -2215,47 +2215,47 @@  discard block
 block discarded – undo
2215 2215
 		public static function flatpickr_locale() {
2216 2216
 			$params = self::calendar_params();
2217 2217
 
2218
-			if ( is_string( $params ) ) {
2219
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2218
+			if (is_string($params)) {
2219
+				$params = html_entity_decode($params, ENT_QUOTES, 'UTF-8');
2220 2220
 			} else {
2221
-				foreach ( (array) $params as $key => $value ) {
2222
-					if ( ! is_scalar( $value ) ) {
2221
+				foreach ((array) $params as $key => $value) {
2222
+					if (!is_scalar($value)) {
2223 2223
 						continue;
2224 2224
 					}
2225 2225
 
2226
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2226
+					$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2227 2227
 				}
2228 2228
 			}
2229 2229
 
2230 2230
 			$day_s3 = array();
2231 2231
 			$day_s5 = array();
2232 2232
 
2233
-			for ( $i = 1; $i <= 7; $i ++ ) {
2234
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
2235
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
2233
+			for ($i = 1; $i <= 7; $i++) {
2234
+				$day_s3[] = addslashes($params['day_s3_' . $i]);
2235
+				$day_s5[] = addslashes($params['day_s3_' . $i]);
2236 2236
 			}
2237 2237
 
2238 2238
 			$month_s = array();
2239 2239
 			$month_long = array();
2240 2240
 
2241
-			for ( $i = 1; $i <= 12; $i ++ ) {
2242
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
2243
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
2241
+			for ($i = 1; $i <= 12; $i++) {
2242
+				$month_s[] = addslashes($params['month_s_' . $i]);
2243
+				$month_long[] = addslashes($params['month_long_' . $i]);
2244 2244
 			}
2245 2245
 
2246 2246
 			ob_start();
2247
-		if ( 0 ) { ?><script><?php } ?>
2247
+		if (0) { ?><script><?php } ?>
2248 2248
                 {
2249 2249
                     weekdays: {
2250
-                        shorthand: ['<?php echo implode( "','", $day_s3 ); ?>'],
2251
-                            longhand: ['<?php echo implode( "','", $day_s5 ); ?>'],
2250
+                        shorthand: ['<?php echo implode("','", $day_s3); ?>'],
2251
+                            longhand: ['<?php echo implode("','", $day_s5); ?>'],
2252 2252
                     },
2253 2253
                     months: {
2254
-                        shorthand: ['<?php echo implode( "','", $month_s ); ?>'],
2255
-                            longhand: ['<?php echo implode( "','", $month_long ); ?>'],
2254
+                        shorthand: ['<?php echo implode("','", $month_s); ?>'],
2255
+                            longhand: ['<?php echo implode("','", $month_long); ?>'],
2256 2256
                     },
2257 2257
                     daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31],
2258
-                        firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>,
2258
+                        firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>,
2259 2259
                     ordinal: function (nth) {
2260 2260
                         var s = nth % 100;
2261 2261
                         if (s > 3 && s < 21)
@@ -2271,21 +2271,21 @@  discard block
 block discarded – undo
2271 2271
                                 return "th";
2272 2272
                         }
2273 2273
                     },
2274
-                    rangeSeparator: '<?php echo addslashes( $params[ 'rangeSeparator' ] ); ?>',
2275
-                        weekAbbreviation: '<?php echo addslashes( $params[ 'weekAbbreviation' ] ); ?>',
2276
-                    scrollTitle: '<?php echo addslashes( $params[ 'scrollTitle' ] ); ?>',
2277
-                    toggleTitle: '<?php echo addslashes( $params[ 'toggleTitle' ] ); ?>',
2278
-                    amPM: ['<?php echo addslashes( $params[ 'am_upper' ] ); ?>','<?php echo addslashes( $params[ 'pm_upper' ] ); ?>'],
2279
-                    yearAriaLabel: '<?php echo addslashes( $params[ 'year' ] ); ?>',
2280
-                    hourAriaLabel: '<?php echo addslashes( $params[ 'hour' ] ); ?>',
2281
-                    minuteAriaLabel: '<?php echo addslashes( $params[ 'minute' ] ); ?>',
2282
-                    time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?>
2274
+                    rangeSeparator: '<?php echo addslashes($params['rangeSeparator']); ?>',
2275
+                        weekAbbreviation: '<?php echo addslashes($params['weekAbbreviation']); ?>',
2276
+                    scrollTitle: '<?php echo addslashes($params['scrollTitle']); ?>',
2277
+                    toggleTitle: '<?php echo addslashes($params['toggleTitle']); ?>',
2278
+                    amPM: ['<?php echo addslashes($params['am_upper']); ?>','<?php echo addslashes($params['pm_upper']); ?>'],
2279
+                    yearAriaLabel: '<?php echo addslashes($params['year']); ?>',
2280
+                    hourAriaLabel: '<?php echo addslashes($params['hour']); ?>',
2281
+                    minuteAriaLabel: '<?php echo addslashes($params['minute']); ?>',
2282
+                    time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?>
2283 2283
                 }
2284
-				<?php if ( 0 ) { ?></script><?php } ?>
2284
+				<?php if (0) { ?></script><?php } ?>
2285 2285
 			<?php
2286 2286
 			$locale = ob_get_clean();
2287 2287
 
2288
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2288
+			return apply_filters('ayecode_ui_flatpickr_locale', trim($locale));
2289 2289
 		}
2290 2290
 
2291 2291
 		/**
@@ -2297,20 +2297,20 @@  discard block
 block discarded – undo
2297 2297
 		 */
2298 2298
 		public static function select2_params() {
2299 2299
 			$params = array(
2300
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2301
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2302
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2303
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2304
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2305
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2306
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2307
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2308
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2309
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2310
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2300
+				'i18n_select_state_text'    => esc_attr__('Select an option&hellip;', 'aui'),
2301
+				'i18n_no_matches'           => _x('No matches found', 'enhanced select', 'aui'),
2302
+				'i18n_ajax_error'           => _x('Loading failed', 'enhanced select', 'aui'),
2303
+				'i18n_input_too_short_1'    => _x('Please enter 1 or more characters', 'enhanced select', 'aui'),
2304
+				'i18n_input_too_short_n'    => _x('Please enter %item% or more characters', 'enhanced select', 'aui'),
2305
+				'i18n_input_too_long_1'     => _x('Please delete 1 character', 'enhanced select', 'aui'),
2306
+				'i18n_input_too_long_n'     => _x('Please delete %item% characters', 'enhanced select', 'aui'),
2307
+				'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'aui'),
2308
+				'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'aui'),
2309
+				'i18n_load_more'            => _x('Loading more results&hellip;', 'enhanced select', 'aui'),
2310
+				'i18n_searching'            => _x('Searching&hellip;', 'enhanced select', 'aui')
2311 2311
 			);
2312 2312
 
2313
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2313
+			return apply_filters('ayecode_ui_select2_params', $params);
2314 2314
 		}
2315 2315
 
2316 2316
 		/**
@@ -2323,17 +2323,17 @@  discard block
 block discarded – undo
2323 2323
 		public static function select2_locale() {
2324 2324
 			$params = self::select2_params();
2325 2325
 
2326
-			foreach ( (array) $params as $key => $value ) {
2327
-				if ( ! is_scalar( $value ) ) {
2326
+			foreach ((array) $params as $key => $value) {
2327
+				if (!is_scalar($value)) {
2328 2328
 					continue;
2329 2329
 				}
2330 2330
 
2331
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2331
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2332 2332
 			}
2333 2333
 
2334
-			$locale = json_encode( $params );
2334
+			$locale = json_encode($params);
2335 2335
 
2336
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2336
+			return apply_filters('ayecode_ui_select2_locale', trim($locale));
2337 2337
 		}
2338 2338
 
2339 2339
 		/**
@@ -2346,35 +2346,35 @@  discard block
 block discarded – undo
2346 2346
 		public static function timeago_locale() {
2347 2347
 			$params = array(
2348 2348
 				'prefix_ago' => '',
2349
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2350
-				'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2349
+				'suffix_ago' => ' ' . _x('ago', 'time ago', 'aui'),
2350
+				'prefix_after' => _x('after', 'time ago', 'aui') . ' ',
2351 2351
 				'suffix_after' => '',
2352
-				'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2353
-				'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2354
-				'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2355
-				'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2356
-				'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2357
-				'day' => _x( 'a day', 'time ago', 'aui' ),
2358
-				'days' => _x( '%d days', 'time ago', 'aui' ),
2359
-				'month' => _x( 'about a month', 'time ago', 'aui' ),
2360
-				'months' => _x( '%d months', 'time ago', 'aui' ),
2361
-				'year' => _x( 'about a year', 'time ago', 'aui' ),
2362
-				'years' => _x( '%d years', 'time ago', 'aui' ),
2352
+				'seconds' => _x('less than a minute', 'time ago', 'aui'),
2353
+				'minute' => _x('about a minute', 'time ago', 'aui'),
2354
+				'minutes' => _x('%d minutes', 'time ago', 'aui'),
2355
+				'hour' => _x('about an hour', 'time ago', 'aui'),
2356
+				'hours' => _x('about %d hours', 'time ago', 'aui'),
2357
+				'day' => _x('a day', 'time ago', 'aui'),
2358
+				'days' => _x('%d days', 'time ago', 'aui'),
2359
+				'month' => _x('about a month', 'time ago', 'aui'),
2360
+				'months' => _x('%d months', 'time ago', 'aui'),
2361
+				'year' => _x('about a year', 'time ago', 'aui'),
2362
+				'years' => _x('%d years', 'time ago', 'aui'),
2363 2363
 			);
2364 2364
 
2365
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2365
+			$params = apply_filters('ayecode_ui_timeago_params', $params);
2366 2366
 
2367
-			foreach ( (array) $params as $key => $value ) {
2368
-				if ( ! is_scalar( $value ) ) {
2367
+			foreach ((array) $params as $key => $value) {
2368
+				if (!is_scalar($value)) {
2369 2369
 					continue;
2370 2370
 				}
2371 2371
 
2372
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2372
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2373 2373
 			}
2374 2374
 
2375
-			$locale = json_encode( $params );
2375
+			$locale = json_encode($params);
2376 2376
 
2377
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2377
+			return apply_filters('ayecode_ui_timeago_locale', trim($locale));
2378 2378
 		}
2379 2379
 
2380 2380
 		/**
@@ -2385,7 +2385,7 @@  discard block
 block discarded – undo
2385 2385
 		 * @return mixed
2386 2386
 		 */
2387 2387
 		public static function minify_js($input) {
2388
-			if(trim($input) === "") return $input;
2388
+			if (trim($input) === "") return $input;
2389 2389
 			return preg_replace(
2390 2390
 				array(
2391 2391
 					// Remove comment(s)
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
 		 * @return mixed
2418 2418
 		 */
2419 2419
 		public static function minify_css($input) {
2420
-			if(trim($input) === "") return $input;
2420
+			if (trim($input) === "") return $input;
2421 2421
 			return preg_replace(
2422 2422
 				array(
2423 2423
 					// Remove comment(s)
@@ -2967,12 +2967,12 @@  discard block
 block discarded – undo
2967 2967
                         });
2968 2968
                     }
2969 2969
                 }
2970
-				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
2970
+				<?php do_action('aui_conditional_fields_js', $this); ?>
2971 2971
             </script>
2972 2972
 			<?php
2973 2973
 			$output = ob_get_clean();
2974 2974
 
2975
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
2975
+			return str_replace(array('<script>', '</script>'), '', self::minify_js($output));
2976 2976
 		}
2977 2977
 	}
2978 2978
 
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,51 +1,51 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( ! defined( 'WPINC' ) ) {
3
+if (!defined('WPINC')) {
4 4
     exit;
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code':
15
-            echo esc_html( $discount->get_code() );
15
+            echo esc_html($discount->get_code());
16 16
             break;
17 17
         case 'amount':
18
-            echo wp_kses_post( $discount->get_formatted_amount() );
18
+            echo wp_kses_post($discount->get_formatted_amount());
19 19
             break;
20 20
         case 'usage':
21
-            echo wp_kses_post( $discount->get_usage() );
21
+            echo wp_kses_post($discount->get_usage());
22 22
             break;
23 23
         case 'start_date':
24
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_start_date() ) );
24
+            echo wp_kses_post(getpaid_format_date_value($discount->get_start_date()));
25 25
             break;
26 26
         case 'expiry_date':
27
-            echo wp_kses_post( getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) ) );
27
+            echo wp_kses_post(getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing')));
28 28
             break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = ! empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ), array( 'publish' ) ) && wpinv_current_user_can( 'deactivate_discount', array( 'discount' => (int) $discount->ID ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish')) && wpinv_current_user_can('deactivate_discount', array('discount' => (int) $discount->ID))) {
49 49
 
50 50
         $url = wp_nonce_url(
51 51
             add_query_arg(
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+		$anchor = __('Deactivate', 'invoicing');
61
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64
-    } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) && wpinv_current_user_can( 'activate_discount', array( 'discount' => (int) $discount->ID ) ) ) {
64
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft')) && wpinv_current_user_can('activate_discount', array('discount' => (int) $discount->ID))) {
65 65
 
66
-        $url    = wp_nonce_url(
66
+        $url = wp_nonce_url(
67 67
             add_query_arg(
68 68
                 array(
69 69
                     'getpaid-admin-action' => 'activate_discount',
@@ -73,14 +73,14 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+		$anchor = __('Activate', 'invoicing');
77
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
81 81
 
82
-    if ( wpinv_current_user_can( 'delete_discount', array( 'discount' => (int) $discount->ID ) ) ) {
83
-        $url    = esc_url(
82
+    if (wpinv_current_user_can('delete_discount', array('discount' => (int) $discount->ID))) {
83
+        $url = esc_url(
84 84
             wp_nonce_url(
85 85
                 add_query_arg(
86 86
                     array(
@@ -93,12 +93,12 @@  discard block
 block discarded – undo
93 93
             )
94 94
     );
95 95
 
96
-        $anchor = __( 'Delete', 'invoicing' );
97
-        $title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
96
+        $anchor = __('Delete', 'invoicing');
97
+        $title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
98 98
         $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
99 99
     }
100 100
 
101
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
101
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
102 102
 
103 103
     return $row_actions;
104 104
 }
@@ -106,68 +106,68 @@  discard block
 block discarded – undo
106 106
 function wpinv_restrict_manage_posts() {
107 107
     global $typenow;
108 108
 
109
-    if ( 'wpi_discount' == $typenow ) {
109
+    if ('wpi_discount' == $typenow) {
110 110
         wpinv_discount_filters();
111 111
     }
112 112
 }
113
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
113
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
114 114
 
115 115
 function wpinv_discount_filters() {
116 116
 
117 117
     ?>
118 118
     <select name="discount_type" id="dropdown_wpinv_discount_type">
119
-        <option value=""><?php esc_html_e( 'Show all types', 'invoicing' ); ?></option>
119
+        <option value=""><?php esc_html_e('Show all types', 'invoicing'); ?></option>
120 120
         <?php
121 121
             $types = wpinv_get_discount_types();
122 122
 
123
-            foreach ( $types as $name => $type ) {
124
-			echo '<option value="' . esc_attr( $name ) . '"';
123
+            foreach ($types as $name => $type) {
124
+			echo '<option value="' . esc_attr($name) . '"';
125 125
 
126
-			if ( isset( $_GET['discount_type'] ) ) {
127
-				selected( $name, sanitize_text_field( $_GET['discount_type'] ) );
126
+			if (isset($_GET['discount_type'])) {
127
+				selected($name, sanitize_text_field($_GET['discount_type']));
128 128
                 }
129 129
 
130
-			echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
130
+			echo '>' . esc_html__($type, 'invoicing') . '</option>';
131 131
             }
132 132
         ?>
133 133
     </select>
134 134
     <?php
135 135
 }
136 136
 
137
-function wpinv_request( $vars ) {
137
+function wpinv_request($vars) {
138 138
     global $typenow, $wp_post_statuses;
139 139
 
140
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
141
-        if ( ! isset( $vars['post_status'] ) ) {
142
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
140
+    if (getpaid_is_invoice_post_type($typenow)) {
141
+        if (!isset($vars['post_status'])) {
142
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
143 143
 
144
-            foreach ( $post_statuses as $status => $value ) {
145
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
146
-                    unset( $post_statuses[ $status ] );
144
+            foreach ($post_statuses as $status => $value) {
145
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
146
+                    unset($post_statuses[$status]);
147 147
                 }
148 148
             }
149 149
 
150
-            $vars['post_status'] = array_keys( $post_statuses );
150
+            $vars['post_status'] = array_keys($post_statuses);
151 151
         }
152
-} elseif ( 'wpi_discount' == $typenow ) {
153
-        $meta_query = ! empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
152
+} elseif ('wpi_discount' == $typenow) {
153
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
154 154
         // Filter vat rule type
155
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
155
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
156 156
             $meta_query[] = array(
157 157
 				'key'     => '_wpi_discount_type',
158
-				'value'   => sanitize_key( urldecode( $_GET['discount_type'] ) ),
158
+				'value'   => sanitize_key(urldecode($_GET['discount_type'])),
159 159
 				'compare' => '=',
160 160
 			);
161 161
 			}
162 162
 
163
-        if ( ! empty( $meta_query ) ) {
163
+        if (!empty($meta_query)) {
164 164
             $vars['meta_query'] = $meta_query;
165 165
 			}
166 166
     }
167 167
 
168 168
     return $vars;
169 169
 }
170
-add_filter( 'request', 'wpinv_request' );
170
+add_filter('request', 'wpinv_request');
171 171
 
172 172
 /**
173 173
  * Create a page and store the ID in an option.
@@ -179,61 +179,61 @@  discard block
 block discarded – undo
179 179
  * @param int $post_parent (default: 0) Parent for the new page
180 180
  * @return int page ID
181 181
  */
182
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
182
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
183 183
     global $wpdb;
184 184
 
185
-    $option_value = wpinv_get_option( $option );
185
+    $option_value = wpinv_get_option($option);
186 186
 
187
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
188
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
187
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
188
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
189 189
             // Valid page is already in place
190 190
             return $page_object->ID;
191 191
         }
192 192
     }
193 193
 
194
-    if ( ! empty( $post_parent ) ) {
195
-        $page = get_page_by_path( $post_parent );
196
-        if ( $page ) {
194
+    if (!empty($post_parent)) {
195
+        $page = get_page_by_path($post_parent);
196
+        if ($page) {
197 197
             $post_parent = $page->ID;
198 198
         } else {
199 199
             $post_parent = '';
200 200
         }
201 201
     }
202 202
 
203
-    if ( strlen( $page_content ) > 0 ) {
203
+    if (strlen($page_content) > 0) {
204 204
         // Search for an existing page with the specified page content (typically a shortcode)
205
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
205
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
206 206
     } else {
207 207
         // Search for an existing page with the specified page slug
208
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
208
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
209 209
     }
210 210
 
211
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
211
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
212 212
 
213
-    if ( $valid_page_found ) {
214
-        if ( $option ) {
215
-            wpinv_update_option( $option, $valid_page_found );
213
+    if ($valid_page_found) {
214
+        if ($option) {
215
+            wpinv_update_option($option, $valid_page_found);
216 216
         }
217 217
         return $valid_page_found;
218 218
     }
219 219
 
220 220
     // Search for a matching valid trashed page
221
-    if ( strlen( $page_content ) > 0 ) {
221
+    if (strlen($page_content) > 0) {
222 222
         // Search for an existing page with the specified page content (typically a shortcode)
223
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
223
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
224 224
     } else {
225 225
         // Search for an existing page with the specified page slug
226
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
226
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
227 227
     }
228 228
 
229
-    if ( $trashed_page_found ) {
229
+    if ($trashed_page_found) {
230 230
         $page_id   = $trashed_page_found;
231 231
         $page_data = array(
232 232
             'ID'          => $page_id,
233 233
             'post_status' => 'publish',
234 234
             'post_parent' => $post_parent,
235 235
         );
236
-        wp_update_post( $page_data );
236
+        wp_update_post($page_data);
237 237
     } else {
238 238
         $page_data = array(
239 239
             'post_status'    => 'publish',
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
             'post_parent'    => $post_parent,
246 246
             'comment_status' => 'closed',
247 247
         );
248
-        $page_id = wp_insert_post( $page_data );
248
+        $page_id = wp_insert_post($page_data);
249 249
     }
250 250
 
251
-    if ( $option ) {
252
-        wpinv_update_option( $option, (int) $page_id );
251
+    if ($option) {
252
+        wpinv_update_option($option, (int) $page_id);
253 253
     }
254 254
 
255 255
     return $page_id;
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
  *
263 263
  * @return array
264 264
  */
265
-function wpinv_add_aui_screens( $screen_ids ) {
265
+function wpinv_add_aui_screens($screen_ids) {
266 266
 
267 267
     // load on these pages if set
268
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
268
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
269 269
 
270 270
     return $screen_ids;
271 271
 }
272
-add_filter( 'aui_screen_ids', 'wpinv_add_aui_screens' );
272
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +131 added lines, -131 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 an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' === strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $value );
29
+    if ('id' === strtolower($field)) {
30
+        return wpinv_get_item_by_id($value);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
60
+			'status'     => array('publish'),
61
+			'limit'      => get_option('posts_per_page'),
62 62
 			'page'       => 1,
63 63
 			'exclude'    => array(),
64 64
 			'orderby'    => 'date',
@@ -83,44 +83,44 @@  discard block
 block discarded – undo
83 83
         'fields'         => 'ids',
84 84
         'orderby'        => $args['orderby'],
85 85
         'order'          => $args['order'],
86
-        'paged'          => absint( $args['page'] ),
86
+        'paged'          => absint($args['page']),
87 87
     );
88 88
 
89
-    if ( ! empty( $args['exclude'] ) ) {
90
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
89
+    if (!empty($args['exclude'])) {
90
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
91 91
     }
92 92
 
93
-    if ( ! $args['paginate'] ) {
93
+    if (!$args['paginate']) {
94 94
         $wp_query_args['no_found_rows'] = true;
95 95
     }
96 96
 
97
-    if ( ! empty( $args['search'] ) ) {
97
+    if (!empty($args['search'])) {
98 98
         $wp_query_args['s'] = $args['search'];
99 99
     }
100 100
 
101
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
102
-        $types = wpinv_parse_list( $args['type'] );
101
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
102
+        $types = wpinv_parse_list($args['type']);
103 103
         $wp_query_args['meta_query'][] = array(
104 104
             'key'     => '_wpinv_type',
105
-            'value'   => implode( ',', $types ),
105
+            'value'   => implode(',', $types),
106 106
             'compare' => 'IN',
107 107
         );
108 108
     }
109 109
 
110
-    $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args );
110
+    $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
111 111
 
112 112
     // Get results.
113
-    $items = new WP_Query( $wp_query_args );
113
+    $items = new WP_Query($wp_query_args);
114 114
 
115
-    if ( 'objects' === $args['return'] ) {
116
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
117
-    } elseif ( 'self' === $args['return'] ) {
115
+    if ('objects' === $args['return']) {
116
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
117
+    } elseif ('self' === $args['return']) {
118 118
         return $items;
119 119
     } else {
120 120
         $return = $items->posts;
121 121
     }
122 122
 
123
-    if ( $args['paginate'] ) {
123
+    if ($args['paginate']) {
124 124
         return (object) array(
125 125
             'items'         => $return,
126 126
             'total'         => $items->found_posts,
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 
133 133
 }
134 134
 
135
-function wpinv_is_free_item( $item_id = 0 ) {
136
-    if ( empty( $item_id ) ) {
135
+function wpinv_is_free_item($item_id = 0) {
136
+    if (empty($item_id)) {
137 137
         return false;
138 138
     }
139 139
 
140
-    $item = new WPInv_Item( $item_id );
140
+    $item = new WPInv_Item($item_id);
141 141
 
142 142
     return $item->is_free();
143 143
 }
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
  *
148 148
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
149 149
  */
150
-function wpinv_item_is_editable( $item = 0 ) {
150
+function wpinv_item_is_editable($item = 0) {
151 151
 
152 152
     // Fetch the item.
153
-    $item = new WPInv_Item( $item );
153
+    $item = new WPInv_Item($item);
154 154
 
155 155
     // Check if it is editable.
156 156
     return $item->is_editable();
157 157
 }
158 158
 
159
-function wpinv_get_item_price( $item_id = 0 ) {
160
-    if ( empty( $item_id ) ) {
159
+function wpinv_get_item_price($item_id = 0) {
160
+    if (empty($item_id)) {
161 161
         return false;
162 162
     }
163 163
 
164
-    $item = new WPInv_Item( $item_id );
164
+    $item = new WPInv_Item($item_id);
165 165
 
166 166
     return $item->get_price();
167 167
 }
@@ -171,89 +171,89 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @param WPInv_Item|int $item
173 173
  */
174
-function wpinv_is_recurring_item( $item = 0 ) {
175
-    $item = new WPInv_Item( $item );
174
+function wpinv_is_recurring_item($item = 0) {
175
+    $item = new WPInv_Item($item);
176 176
     return $item->is_recurring();
177 177
 }
178 178
 
179
-function wpinv_item_price( $item_id = 0 ) {
180
-    if ( empty( $item_id ) ) {
179
+function wpinv_item_price($item_id = 0) {
180
+    if (empty($item_id)) {
181 181
         return false;
182 182
     }
183 183
 
184
-    $price = wpinv_get_item_price( $item_id );
185
-    $price = wpinv_price( $price );
184
+    $price = wpinv_get_item_price($item_id);
185
+    $price = wpinv_price($price);
186 186
 
187
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
187
+    return apply_filters('wpinv_item_price', $price, $item_id);
188 188
 }
189 189
 
190
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
191
-    if ( is_null( $amount_override ) ) {
192
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
190
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
191
+    if (is_null($amount_override)) {
192
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
193 193
     } else {
194 194
         $original_price = $amount_override;
195 195
     }
196 196
 
197 197
     $price = $original_price;
198 198
 
199
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
199
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
200 200
 }
201 201
 
202
-function wpinv_item_custom_singular_name( $item_id ) {
203
-    if ( empty( $item_id ) ) {
202
+function wpinv_item_custom_singular_name($item_id) {
203
+    if (empty($item_id)) {
204 204
         return false;
205 205
     }
206 206
 
207
-    $item = new WPInv_Item( $item_id );
207
+    $item = new WPInv_Item($item_id);
208 208
 
209 209
     return $item->get_custom_singular_name();
210 210
 }
211 211
 
212 212
 function wpinv_get_item_types() {
213 213
     $item_types = array(
214
-		'custom' => __( 'Standard', 'invoicing' ),
215
-		'fee'    => __( 'Fee', 'invoicing' ),
214
+		'custom' => __('Standard', 'invoicing'),
215
+		'fee'    => __('Fee', 'invoicing'),
216 216
 	);
217
-    return apply_filters( 'wpinv_get_item_types', $item_types );
217
+    return apply_filters('wpinv_get_item_types', $item_types);
218 218
 }
219 219
 
220 220
 function wpinv_item_types() {
221 221
     $item_types = wpinv_get_item_types();
222 222
 
223
-    return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() );
223
+    return (!empty($item_types) ? array_keys($item_types) : array());
224 224
 }
225 225
 
226
-function wpinv_get_item_type( $item_id ) {
227
-    if ( empty( $item_id ) ) {
226
+function wpinv_get_item_type($item_id) {
227
+    if (empty($item_id)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    $item = new WPInv_Item( $item_id );
231
+    $item = new WPInv_Item($item_id);
232 232
 
233 233
     return $item->get_type();
234 234
 }
235 235
 
236
-function wpinv_item_type( $item_id ) {
236
+function wpinv_item_type($item_id) {
237 237
     $item_types = wpinv_get_item_types();
238 238
 
239
-    $item_type = wpinv_get_item_type( $item_id );
239
+    $item_type = wpinv_get_item_type($item_id);
240 240
 
241
-    if ( empty( $item_type ) ) {
241
+    if (empty($item_type)) {
242 242
         $item_type = '-';
243 243
     }
244 244
 
245
-    $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' );
245
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
246 246
 
247
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
247
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
248 248
 }
249 249
 
250
-function wpinv_get_random_item( $post_ids = true ) {
251
-    wpinv_get_random_items( 1, $post_ids );
250
+function wpinv_get_random_item($post_ids = true) {
251
+    wpinv_get_random_items(1, $post_ids);
252 252
 }
253 253
 
254
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
254
+function wpinv_get_random_items($num = 3, $post_ids = true) {
255 255
     $args = array();
256
-    if ( $post_ids ) {
256
+    if ($post_ids) {
257 257
         $args = array(
258 258
 			'fields' => 'ids',
259 259
 		);
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
         )
275 275
     );
276 276
 
277
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
277
+    $args = apply_filters('wpinv_get_random_items', $args);
278 278
 
279
-    return get_posts( $args );
279
+    return get_posts($args);
280 280
 }
281 281
 
282 282
 /**
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
  * @param WPInv_Item|int $item
286 286
  * @param bool $html
287 287
  */
288
-function wpinv_get_item_suffix( $item, $html = true ) {
288
+function wpinv_get_item_suffix($item, $html = true) {
289 289
 
290
-    $item   = new WPInv_Item( $item );
291
-    $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '';
292
-    $suffix = $html ? $suffix : wp_strip_all_tags( $suffix );
290
+    $item   = new WPInv_Item($item);
291
+    $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : '';
292
+    $suffix = $html ? $suffix : wp_strip_all_tags($suffix);
293 293
 
294
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
294
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
295 295
 }
296 296
 
297 297
 /**
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
  * @param WPInv_Item|int $item
301 301
  * @param bool $force_delete
302 302
  */
303
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
304
-    $item = new WPInv_Item( $item );
305
-    $item->delete( $force_delete );
303
+function wpinv_remove_item($item = 0, $force_delete = false) {
304
+    $item = new WPInv_Item($item);
305
+    $item->delete($force_delete);
306 306
 }
307 307
 
308 308
 /**
@@ -341,44 +341,44 @@  discard block
 block discarded – undo
341 341
  * @param bool $wp_error whether or not to return a WP_Error on failure.
342 342
  * @return bool|WP_Error|WPInv_Item
343 343
  */
344
-function wpinv_create_item( $args = array(), $wp_error = false ) {
344
+function wpinv_create_item($args = array(), $wp_error = false) {
345 345
 
346 346
     // Prepare the item.
347
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
348
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
349
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
347
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
348
+        $type = empty($args['type']) ? 'custom' : $args['type'];
349
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
350 350
 
351
-        if ( ! empty( $item ) ) {
351
+        if (!empty($item)) {
352 352
             $args['ID'] = $item->get_id();
353 353
         }
354 354
     }
355 355
 
356 356
     // Do we have an item?
357
-    if ( ! empty( $args['ID'] ) ) {
358
-        $item = new WPInv_Item( $args['ID'] );
357
+    if (!empty($args['ID'])) {
358
+        $item = new WPInv_Item($args['ID']);
359 359
     } else {
360 360
         $item = new WPInv_Item();
361 361
     }
362 362
 
363 363
     // Do we have an error?
364
-    if ( ! empty( $item->last_error ) ) {
365
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
364
+    if (!empty($item->last_error)) {
365
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
366 366
     }
367 367
 
368 368
     // Update item props.
369
-    $item->set_props( $args );
369
+    $item->set_props($args);
370 370
 
371 371
     // Save the item.
372 372
     $item->save();
373 373
 
374 374
     // Do we have an error?
375
-    if ( ! empty( $item->last_error ) ) {
376
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
375
+    if (!empty($item->last_error)) {
376
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
377 377
     }
378 378
 
379 379
     // Was the item saved?
380
-    if ( ! $item->get_id() ) {
381
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
380
+    if (!$item->get_id()) {
381
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
382 382
     }
383 383
 
384 384
     return $item;
@@ -390,14 +390,14 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @see wpinv_create_item()
392 392
  */
393
-function wpinv_update_item( $args = array(), $wp_error = false ) {
394
-    return wpinv_create_item( $args, $wp_error );
393
+function wpinv_update_item($args = array(), $wp_error = false) {
394
+    return wpinv_create_item($args, $wp_error);
395 395
 }
396 396
 
397 397
 /**
398 398
  * Sanitizes a recurring period
399 399
  */
400
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
400
+function getpaid_sanitize_recurring_period($period, $full = false) {
401 401
 
402 402
     $periods = array(
403 403
         'D' => 'day',
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
         'Y' => 'year',
407 407
     );
408 408
 
409
-    if ( ! isset( $periods[ $period ] ) ) {
409
+    if (!isset($periods[$period])) {
410 410
         $period = 'D';
411 411
     }
412 412
 
413
-    return $full ? $periods[ $period ] : $period;
413
+    return $full ? $periods[$period] : $period;
414 414
 
415 415
 }
416 416
 
417
-function wpinv_item_max_buyable_quantity( $item_id ) {
418
-    return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id );
417
+function wpinv_item_max_buyable_quantity($item_id) {
418
+    return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id);
419 419
 }
420 420
 
421 421
 /**
@@ -423,47 +423,47 @@  discard block
 block discarded – undo
423 423
  *
424 424
  * @param WPInv_Item|GetPaid_Form_Item $item
425 425
  */
426
-function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) {
426
+function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) {
427 427
 
428 428
     // Abort if it is not recurring.
429
-    if ( ! $item->is_recurring() ) {
429
+    if (!$item->is_recurring()) {
430 430
         return '';
431 431
     }
432 432
 
433
-    $initial_price   = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price;
434
-    $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price;
435
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
433
+    $initial_price   = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price;
434
+    $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price;
435
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
436 436
     $initial_class   = 'getpaid-item-initial-price';
437 437
     $recurring_class = 'getpaid-item-recurring-price';
438 438
     $bill_times      = $item->get_recurring_limit();
439 439
     $bill_times_less = $bill_times - 1;
440 440
 
441
-    if ( ! empty( $bill_times ) ) {
441
+    if (!empty($bill_times)) {
442 442
 		$bill_times = $item->get_recurring_interval() * $bill_times;
443
-        $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
444
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
443
+        $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval());
444
+		$bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times);
445 445
 	}
446 446
 
447
-    if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
448
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
449
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
447
+    if ($item instanceof GetPaid_Form_Item && false === $_initial_price) {
448
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
449
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
450 450
     }
451 451
 
452
-    if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) {
453
-        return __( 'Free forever', 'invoicing' );
452
+    if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) {
453
+        return __('Free forever', 'invoicing');
454 454
     }
455 455
 
456 456
     // For free trial items.
457
-    if ( $item->has_free_trial() ) {
458
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
457
+    if ($item->has_free_trial()) {
458
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
459 459
 
460
-        if ( wpinv_price( 0, $currency ) == $initial_price ) {
460
+        if (wpinv_price(0, $currency) == $initial_price) {
461 461
 
462
-            if ( empty( $bill_times ) ) {
462
+            if (empty($bill_times)) {
463 463
 
464 464
                 return sprintf(
465 465
                     // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
466
-                    _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
466
+                    _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
467 467
                     "<span class='getpaid-item-trial-period'>$trial_period</span>",
468 468
                     "<span class='$recurring_class'>$recurring_price</span>",
469 469
                     "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
             return sprintf(
475 475
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times
476
-                _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ),
476
+                _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'),
477 477
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
478 478
                 "<span class='$recurring_class'>$recurring_price</span>",
479 479
                 "<span class='getpaid-item-recurring-period'>$period</span>",
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 
483 483
         }
484 484
 
485
-        if ( empty( $bill_times ) ) {
485
+        if (empty($bill_times)) {
486 486
 
487 487
             return sprintf(
488 488
                 // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
489
-                _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
489
+                _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
490 490
                 "<span class='$initial_class'>$initial_price</span>",
491 491
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
492 492
                 "<span class='$recurring_class'>$recurring_price</span>",
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
         return sprintf(
499 499
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times
500
-            _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ),
500
+            _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'),
501 501
             "<span class='$initial_class'>$initial_price</span>",
502 502
             "<span class='getpaid-item-trial-period'>$trial_period</span>",
503 503
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 
508 508
     }
509 509
 
510
-    if ( $initial_price == $recurring_price ) {
510
+    if ($initial_price == $recurring_price) {
511 511
 
512
-        if ( empty( $bill_times ) ) {
512
+        if (empty($bill_times)) {
513 513
 
514 514
             return sprintf(
515 515
                 // translators: $1: is the recurring price, $2: is the susbcription period
516
-                _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
516
+                _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
517 517
                 "<span class='$recurring_class'>$recurring_price</span>",
518 518
                 "<span class='getpaid-item-recurring-period'>$period</span>"
519 519
             );
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
         return sprintf(
524 524
             // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times
525
-            _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
525
+            _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
526 526
             "<span class='$recurring_class'>$recurring_price</span>",
527 527
             "<span class='getpaid-item-recurring-period'>$period</span>",
528 528
             "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>"
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
 
531 531
     }
532 532
 
533
-    if ( $initial_price == wpinv_price( 0, $currency ) ) {
533
+    if ($initial_price == wpinv_price(0, $currency)) {
534 534
 
535
-        if ( empty( $bill_times ) ) {
535
+        if (empty($bill_times)) {
536 536
 
537 537
             return sprintf(
538 538
                 // translators: $1: is the recurring period, $2: is the recurring price
539
-                _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ),
539
+                _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'),
540 540
                 "<span class='getpaid-item-recurring-period'>$period</span>",
541 541
                 "<span class='$recurring_class'>$recurring_price</span>"
542 542
             );
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
         return sprintf(
547 547
             // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times
548
-            _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ),
548
+            _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'),
549 549
             "<span class='getpaid-item-recurring-period'>$period</span>",
550 550
             "<span class='$recurring_class'>$recurring_price</span>",
551 551
             "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>"
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 
554 554
     }
555 555
 
556
-    if ( empty( $bill_times ) ) {
556
+    if (empty($bill_times)) {
557 557
 
558 558
         return sprintf(
559 559
             // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
560
-            _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
560
+            _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
561 561
             "<span class='$initial_class'>$initial_price</span>",
562 562
             "<span class='$recurring_class'>$recurring_price</span>",
563 563
             "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
     return sprintf(
569 569
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times
570
-        _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ),
570
+        _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'),
571 571
         "<span class='$initial_class'>$initial_price</span>",
572 572
         "<span class='$recurring_class'>$recurring_price</span>",
573 573
         "<span class='getpaid-item-recurring-period'>$period</span>",
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +339 added lines, -339 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
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
 
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -106,36 +106,36 @@  discard block
 block discarded – undo
106 106
             'file_upload'                   => true,
107 107
         );
108 108
 
109
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
110
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
111
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
109
+        foreach ($ajax_events as $ajax_event => $nopriv) {
110
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
111
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
112 112
 
113
-            if ( $nopriv ) {
114
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
116
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
113
+            if ($nopriv) {
114
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
116
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
117 117
             }
118 118
         }
119 119
     }
120 120
 
121 121
     public static function add_note() {
122
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
122
+        check_ajax_referer('add-invoice-note', '_nonce');
123 123
 
124
-        $post_id   = absint( $_POST['post_id'] );
125
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
126
-        $note_type = sanitize_text_field( $_POST['note_type'] );
124
+        $post_id   = absint($_POST['post_id']);
125
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
126
+        $note_type = sanitize_text_field($_POST['note_type']);
127 127
 
128
-        if ( ! wpinv_current_user_can( 'invoice_add_note', array( 'invoice_id' => $post_id, 'note_type' => $note_type ) ) ) {
128
+        if (!wpinv_current_user_can('invoice_add_note', array('invoice_id' => $post_id, 'note_type' => $note_type))) {
129 129
             die( -1 );
130 130
         }
131 131
 
132 132
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
133 133
 
134
-        if ( $post_id > 0 ) {
135
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
134
+        if ($post_id > 0) {
135
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
136 136
 
137
-            if ( $note_id > 0 && ! is_wp_error( $note_id ) ) {
138
-                wpinv_get_invoice_note_line_item( $note_id );
137
+            if ($note_id > 0 && !is_wp_error($note_id)) {
138
+                wpinv_get_invoice_note_line_item($note_id);
139 139
             }
140 140
         }
141 141
 
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
     }
144 144
 
145 145
     public static function delete_note() {
146
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
146
+        check_ajax_referer('delete-invoice-note', '_nonce');
147 147
 
148
-        $note_id = (int)$_POST['note_id'];
148
+        $note_id = (int) $_POST['note_id'];
149 149
 
150
-        if ( ! wpinv_current_user_can( 'invoice_delete_note', array( 'note_id' => $note_id ) ) ) {
150
+        if (!wpinv_current_user_can('invoice_delete_note', array('note_id' => $note_id))) {
151 151
             die( -1 );
152 152
         }
153 153
 
154
-        if ( $note_id > 0 ) {
155
-            wp_delete_comment( $note_id, true );
154
+        if ($note_id > 0) {
155
+            wp_delete_comment($note_id, true);
156 156
         }
157 157
 
158 158
         die();
@@ -169,35 +169,35 @@  discard block
 block discarded – undo
169 169
      */
170 170
     public static function get_billing_details() {
171 171
         // Verify nonce.
172
-        check_ajax_referer( 'wpinv-nonce' );
172
+        check_ajax_referer('wpinv-nonce');
173 173
 
174 174
         // Do we have a user id?
175 175
         $user_id = (int) $_GET['user_id'];
176
-        $invoice_id = ! empty( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
176
+        $invoice_id = !empty($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;
177 177
 
178
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
178
+        if (empty($user_id) || !is_numeric($user_id)) {
179 179
             die( -1 );
180 180
         }
181 181
 
182 182
         // Can the user manage the plugin?
183
-        if ( ! wpinv_current_user_can( 'invoice_get_billing_details', array( 'user_id' => $user_id, 'invoice_id' => $invoice_id ) ) ) {
183
+        if (!wpinv_current_user_can('invoice_get_billing_details', array('user_id' => $user_id, 'invoice_id' => $invoice_id))) {
184 184
             die( -1 );
185 185
         }
186 186
 
187 187
         // Fetch the billing details.
188
-        $billing_details    = wpinv_get_user_address( $user_id );
189
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
188
+        $billing_details    = wpinv_get_user_address($user_id);
189
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
190 190
 
191 191
         // unset the user id and email.
192
-        $to_ignore = array( 'user_id', 'email' );
192
+        $to_ignore = array('user_id', 'email');
193 193
 
194
-        foreach ( $to_ignore as $key ) {
195
-            if ( isset( $billing_details[ $key ] ) ) {
196
-                unset( $billing_details[ $key ] );
194
+        foreach ($to_ignore as $key) {
195
+            if (isset($billing_details[$key])) {
196
+                unset($billing_details[$key]);
197 197
             }
198 198
         }
199 199
 
200
-        wp_send_json_success( $billing_details );
200
+        wp_send_json_success($billing_details);
201 201
 
202 202
     }
203 203
 
@@ -206,54 +206,54 @@  discard block
 block discarded – undo
206 206
      */
207 207
     public static function check_new_user_email() {
208 208
         // Verify nonce.
209
-        check_ajax_referer( 'wpinv-nonce' );
209
+        check_ajax_referer('wpinv-nonce');
210 210
 
211
-        $invoice_id = ! empty( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0;
211
+        $invoice_id = !empty($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : 0;
212 212
 
213
-        if ( empty( $invoice_id ) ) {
213
+        if (empty($invoice_id)) {
214 214
             die( -1 );
215 215
         }
216 216
 
217 217
         // Can the user manage the plugin?
218
-        if ( ! wpinv_current_user_can( 'invoice_check_new_user_email', array( 'invoice_id' => $invoice_id ) ) ) {
218
+        if (!wpinv_current_user_can('invoice_check_new_user_email', array('invoice_id' => $invoice_id))) {
219 219
             die( -1 );
220 220
         }
221 221
 
222 222
         // We need an email address.
223
-        if ( empty( $_GET['email'] ) ) {
224
-            esc_html_e( "Provide the new user's email address", 'invoicing' );
223
+        if (empty($_GET['email'])) {
224
+            esc_html_e("Provide the new user's email address", 'invoicing');
225 225
             exit;
226 226
         }
227 227
 
228 228
         // Ensure the email is valid.
229
-        $email = sanitize_email( $_GET['email'] );
230
-        if ( ! is_email( $email ) ) {
231
-            esc_html_e( 'Invalid email address', 'invoicing' );
229
+        $email = sanitize_email($_GET['email']);
230
+        if (!is_email($email)) {
231
+            esc_html_e('Invalid email address', 'invoicing');
232 232
             exit;
233 233
         }
234 234
 
235 235
         // And it does not exist.
236
-        $id = email_exists( $email );
237
-        if ( $id ) {
238
-            wp_send_json_success( compact( 'id' ) );
236
+        $id = email_exists($email);
237
+        if ($id) {
238
+            wp_send_json_success(compact('id'));
239 239
         }
240 240
 
241
-        wp_send_json_success( true );
241
+        wp_send_json_success(true);
242 242
     }
243 243
 
244 244
     public static function run_tool() {
245
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
245
+        check_ajax_referer('wpinv-nonce', '_nonce');
246 246
 
247
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
247
+        if (!wpinv_current_user_can_manage_invoicing()) {
248 248
             die( -1 );
249 249
         }
250 250
 
251
-        $tool = sanitize_text_field( $_POST['tool'] );
251
+        $tool = sanitize_text_field($_POST['tool']);
252 252
 
253
-        do_action( 'wpinv_run_tool' );
253
+        do_action('wpinv_run_tool');
254 254
 
255
-        if ( ! empty( $tool ) ) {
256
-            do_action( 'wpinv_tool_' . $tool );
255
+        if (!empty($tool)) {
256
+            do_action('wpinv_tool_' . $tool);
257 257
         }
258 258
     }
259 259
 
@@ -264,11 +264,11 @@  discard block
 block discarded – undo
264 264
         global $getpaid_force_checkbox;
265 265
 
266 266
         // Is the request set up correctly?
267
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
267
+		if (empty($_GET['form']) && empty($_GET['item']) && empty($_GET['invoice'])) {
268 268
 			aui()->alert(
269 269
 				array(
270 270
 					'type'    => 'warning',
271
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
271
+					'content' => __('No payment form or item provided', 'invoicing'),
272 272
                 ),
273 273
                 true
274 274
             );
@@ -276,29 +276,29 @@  discard block
 block discarded – undo
276 276
         }
277 277
 
278 278
         // Payment form or button?
279
-		if ( ! empty( $_GET['form'] ) ) {
280
-            $form = sanitize_text_field( urldecode( $_GET['form'] ) );
279
+		if (!empty($_GET['form'])) {
280
+            $form = sanitize_text_field(urldecode($_GET['form']));
281 281
 
282
-            if ( false !== strpos( $form, '|' ) ) {
283
-                $form_pos = strpos( $form, '|' );
284
-                $_items   = getpaid_convert_items_to_array( substr( $form, $form_pos + 1 ) );
285
-                $form     = substr( $form, 0, $form_pos );
282
+            if (false !== strpos($form, '|')) {
283
+                $form_pos = strpos($form, '|');
284
+                $_items   = getpaid_convert_items_to_array(substr($form, $form_pos + 1));
285
+                $form     = substr($form, 0, $form_pos);
286 286
 
287 287
                 // Retrieve appropriate payment form.
288
-                $payment_form = new GetPaid_Payment_Form( $form );
289
-                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
288
+                $payment_form = new GetPaid_Payment_Form($form);
289
+                $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
290 290
 
291 291
                 $items    = array();
292 292
                 $item_ids = array();
293 293
 
294
-                foreach ( $_items as $item_id => $qty ) {
295
-                    if ( ! in_array( $item_id, $item_ids ) ) {
296
-                        $item = new GetPaid_Form_Item( $item_id );
297
-                        $item->set_quantity( $qty );
294
+                foreach ($_items as $item_id => $qty) {
295
+                    if (!in_array($item_id, $item_ids)) {
296
+                        $item = new GetPaid_Form_Item($item_id);
297
+                        $item->set_quantity($qty);
298 298
 
299
-                        if ( 0 == $qty ) {
300
-                            $item->set_allow_quantities( true );
301
-                            $item->set_is_required( false );
299
+                        if (0 == $qty) {
300
+                            $item->set_allow_quantities(true);
301
+                            $item->set_is_required(false);
302 302
                             $getpaid_force_checkbox = true;
303 303
                         }
304 304
 
@@ -307,32 +307,32 @@  discard block
 block discarded – undo
307 307
                     }
308 308
                 }
309 309
 
310
-                if ( ! $payment_form->is_default() ) {
310
+                if (!$payment_form->is_default()) {
311 311
 
312
-                    foreach ( $payment_form->get_items() as $item ) {
313
-                        if ( ! in_array( $item->get_id(), $item_ids ) ) {
312
+                    foreach ($payment_form->get_items() as $item) {
313
+                        if (!in_array($item->get_id(), $item_ids)) {
314 314
                             $item_ids[] = $item->get_id();
315 315
                             $items[]    = $item;
316 316
                         }
317 317
                     }
318 318
                 }
319 319
 
320
-                $payment_form->set_items( $items );
321
-                $extra_items     = esc_attr( getpaid_convert_items_to_string( $_items ) );
322
-                $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
320
+                $payment_form->set_items($items);
321
+                $extra_items     = esc_attr(getpaid_convert_items_to_string($_items));
322
+                $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
323 323
                 $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
324 324
                 $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
325
-                $payment_form->display( $extra_items );
325
+                $payment_form->display($extra_items);
326 326
                 $getpaid_force_checkbox = false;
327 327
 
328 328
             } else {
329
-                getpaid_display_payment_form( $form );
329
+                getpaid_display_payment_form($form);
330 330
             }
331
-} elseif ( ! empty( $_GET['invoice'] ) ) {
332
-		    getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
331
+} elseif (!empty($_GET['invoice'])) {
332
+		    getpaid_display_invoice_payment_form((int) urldecode($_GET['invoice']));
333 333
         } else {
334
-			$items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
335
-		    getpaid_display_item_payment_form( $items );
334
+			$items = getpaid_convert_items_to_array(sanitize_text_field(urldecode($_GET['item'])));
335
+		    getpaid_display_item_payment_form($items);
336 336
         }
337 337
 
338 338
         exit;
@@ -347,14 +347,14 @@  discard block
 block discarded – undo
347 347
     public static function payment_form() {
348 348
 
349 349
         // ... form fields...
350
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
351
-            esc_html_e( 'Error: Reload the page and try again.', 'invoicing' );
350
+        if (empty($_POST['getpaid_payment_form_submission'])) {
351
+            esc_html_e('Error: Reload the page and try again.', 'invoicing');
352 352
             exit;
353 353
         }
354 354
 
355 355
         // Process the payment form.
356
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
357
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
356
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
357
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
358 358
         $checkout->process_checkout();
359 359
 
360 360
         exit;
@@ -367,55 +367,55 @@  discard block
 block discarded – undo
367 367
      */
368 368
     public static function get_payment_form_states_field() {
369 369
 
370
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
370
+        if (empty($_GET['country']) || empty($_GET['form'])) {
371 371
             exit;
372 372
         }
373 373
 
374
-        $elements = getpaid_get_payment_form_elements( (int) $_GET['form'] );
374
+        $elements = getpaid_get_payment_form_elements((int) $_GET['form']);
375 375
 
376
-        if ( empty( $elements ) ) {
376
+        if (empty($elements)) {
377 377
             exit;
378 378
         }
379 379
 
380 380
         $address_fields = array();
381
-        foreach ( $elements as $element ) {
382
-            if ( 'address' === $element['type'] ) {
381
+        foreach ($elements as $element) {
382
+            if ('address' === $element['type']) {
383 383
                 $address_fields = $element;
384 384
                 break;
385 385
             }
386 386
         }
387 387
 
388
-        if ( empty( $address_fields ) ) {
388
+        if (empty($address_fields)) {
389 389
             exit;
390 390
         }
391 391
 
392
-        foreach ( $address_fields['fields'] as $address_field ) {
392
+        foreach ($address_fields['fields'] as $address_field) {
393 393
 
394
-            if ( 'wpinv_state' == $address_field['name'] ) {
394
+            if ('wpinv_state' == $address_field['name']) {
395 395
 
396
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
397
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
398
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
399
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
400
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
401
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
396
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
397
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
398
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
399
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
400
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
401
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
402 402
 
403
-                if ( ! empty( $address_field['required'] ) ) {
403
+                if (!empty($address_field['required'])) {
404 404
                     $label .= "<span class='text-danger'> *</span>";
405 405
                 }
406 406
 
407 407
                 $html = getpaid_get_states_select_markup(
408
-                    sanitize_text_field( $_GET['country'] ),
408
+                    sanitize_text_field($_GET['country']),
409 409
                     $value,
410 410
                     $placeholder,
411 411
                     $label,
412 412
                     $description,
413
-                    ! empty( $address_field['required'] ),
413
+                    !empty($address_field['required']),
414 414
                     $wrap_class,
415
-                    sanitize_text_field( $_GET['name'] )
415
+                    sanitize_text_field($_GET['name'])
416 416
                 );
417 417
 
418
-                wp_send_json_success( $html );
418
+                wp_send_json_success($html);
419 419
                 exit;
420 420
 
421 421
             }
@@ -429,68 +429,68 @@  discard block
 block discarded – undo
429 429
      */
430 430
     public static function recalculate_invoice_totals() {
431 431
         // Verify nonce.
432
-        check_ajax_referer( 'wpinv-nonce' );
432
+        check_ajax_referer('wpinv-nonce');
433 433
 
434
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
434
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
435 435
 
436
-        if ( empty( $invoice_id ) ) {
436
+        if (empty($invoice_id)) {
437 437
             die( -1 );
438 438
         }
439 439
 
440 440
         // Can the user manage the plugin?
441
-        if ( ! wpinv_current_user_can( 'invoice_recalculate_totals', array( 'invoice_id' => $invoice_id ) ) ) {
441
+        if (!wpinv_current_user_can('invoice_recalculate_totals', array('invoice_id' => $invoice_id))) {
442 442
             die( -1 );
443 443
         }
444 444
 
445 445
         // Fetch the invoice.
446
-        $invoice = new WPInv_Invoice( $invoice_id );
446
+        $invoice = new WPInv_Invoice($invoice_id);
447 447
 
448 448
         // Ensure it exists.
449
-        if ( ! $invoice->get_id() ) {
449
+        if (!$invoice->get_id()) {
450 450
             exit;
451 451
         }
452 452
 
453 453
         // Maybe set the country, state, currency.
454
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
455
-            if ( isset( $_POST[ $key ] ) ) {
454
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
455
+            if (isset($_POST[$key])) {
456 456
                 $method = "set_$key";
457
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
457
+                $invoice->$method(sanitize_text_field($_POST[$key]));
458 458
             }
459 459
         }
460 460
 
461 461
         // Maybe disable taxes.
462
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
462
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
463 463
 
464 464
         // Discount code.
465
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
466
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
467
-            if ( $discount->exists() ) {
468
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
465
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
466
+            $discount = new WPInv_Discount($invoice->get_discount_code());
467
+            if ($discount->exists()) {
468
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
469 469
             } else {
470
-                $invoice->remove_discount( 'discount_code' );
470
+                $invoice->remove_discount('discount_code');
471 471
             }
472 472
         }
473 473
 
474 474
         // Recalculate totals.
475 475
         $invoice->recalculate_total();
476 476
 
477
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
478
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
479
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
480
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
481
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
477
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
478
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
479
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
480
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
481
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
482 482
         }
483 483
 
484 484
         $totals = array(
485
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
486
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
487
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
485
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
486
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
487
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
488 488
             'total'    => $total,
489 489
         );
490 490
 
491
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
491
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
492 492
 
493
-        wp_send_json_success( compact( 'totals' ) );
493
+        wp_send_json_success(compact('totals'));
494 494
     }
495 495
 
496 496
     /**
@@ -498,35 +498,35 @@  discard block
 block discarded – undo
498 498
      */
499 499
     public static function get_invoice_items() {
500 500
         // Verify nonce.
501
-        check_ajax_referer( 'wpinv-nonce' );
501
+        check_ajax_referer('wpinv-nonce');
502 502
 
503
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
503
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
504 504
 
505
-        if ( empty( $invoice_id ) ) {
505
+        if (empty($invoice_id)) {
506 506
             exit;
507 507
         }
508 508
 
509 509
         // Can the user manage the plugin?
510
-        if ( ! wpinv_current_user_can( 'invoice_get_items', array( 'invoice_id' => $invoice_id ) ) ) {
510
+        if (!wpinv_current_user_can('invoice_get_items', array('invoice_id' => $invoice_id))) {
511 511
             exit;
512 512
         }
513 513
 
514 514
         // Fetch the invoice.
515
-        $invoice = new WPInv_Invoice( $invoice_id );
515
+        $invoice = new WPInv_Invoice($invoice_id);
516 516
 
517 517
         // Ensure it exists.
518
-        if ( ! $invoice->get_id() ) {
518
+        if (!$invoice->get_id()) {
519 519
             exit;
520 520
         }
521 521
 
522 522
         // Return an array of invoice items.
523 523
         $items = array();
524 524
 
525
-        foreach ( $invoice->get_items() as $item ) {
526
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency(), $invoice->is_renewal() );
525
+        foreach ($invoice->get_items() as $item) {
526
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
527 527
         }
528 528
 
529
-        wp_send_json_success( compact( 'items' ) );
529
+        wp_send_json_success(compact('items'));
530 530
     }
531 531
 
532 532
     /**
@@ -534,57 +534,57 @@  discard block
 block discarded – undo
534 534
      */
535 535
     public static function edit_invoice_item() {
536 536
         // Verify nonce.
537
-        check_ajax_referer( 'wpinv-nonce' );
537
+        check_ajax_referer('wpinv-nonce');
538 538
 
539 539
         // We need an invoice and item details.
540
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
540
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
541 541
             exit;
542 542
         }
543 543
 
544
-        $invoice_id = absint( $_POST['post_id'] );
544
+        $invoice_id = absint($_POST['post_id']);
545 545
 
546
-        if ( empty( $invoice_id ) ) {
546
+        if (empty($invoice_id)) {
547 547
             exit;
548 548
         }
549 549
 
550 550
         // Can the user manage the plugin?
551
-        if ( ! wpinv_current_user_can( 'invoice_edit_item', array( 'invoice_id' => $invoice_id ) ) ) {
551
+        if (!wpinv_current_user_can('invoice_edit_item', array('invoice_id' => $invoice_id))) {
552 552
             exit;
553 553
         }
554 554
 
555 555
         // Fetch the invoice.
556
-        $invoice = new WPInv_Invoice( $invoice_id );
556
+        $invoice = new WPInv_Invoice($invoice_id);
557 557
 
558 558
         // Ensure it exists and its not been paid for.
559
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
559
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
560 560
             exit;
561 561
         }
562 562
 
563 563
         // Format the data.
564
-        $data = wp_kses_post_deep( wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) ) );
564
+        $data = wp_kses_post_deep(wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field')));
565 565
 
566 566
         // Ensure that we have an item id.
567
-        if ( empty( $data['id'] ) ) {
567
+        if (empty($data['id'])) {
568 568
             exit;
569 569
         }
570 570
 
571 571
         // Abort if the invoice does not have the specified item.
572
-        $item = $invoice->get_item( (int) $data['id'] );
572
+        $item = $invoice->get_item((int) $data['id']);
573 573
 
574
-        if ( empty( $item ) ) {
574
+        if (empty($item)) {
575 575
             exit;
576 576
         }
577 577
 
578 578
         // Update the item.
579
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
580
-        $item->set_name( sanitize_text_field( $data['name'] ) );
581
-        $item->set_description( wp_kses_post( $data['description'] ) );
582
-        $item->set_quantity( floatval( $data['quantity'] ) );
579
+        $item->set_price(getpaid_standardize_amount($data['price']));
580
+        $item->set_name(sanitize_text_field($data['name']));
581
+        $item->set_description(wp_kses_post($data['description']));
582
+        $item->set_quantity(floatval($data['quantity']));
583 583
 
584 584
         // Add it to the invoice.
585
-        $error = $invoice->add_item( $item );
585
+        $error = $invoice->add_item($item);
586 586
         $alert = false;
587
-        if ( is_wp_error( $error ) ) {
587
+        if (is_wp_error($error)) {
588 588
             $alert = $error->get_error_message();
589 589
         }
590 590
 
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
         // Return an array of invoice items.
598 598
         $items = array();
599 599
 
600
-        foreach ( $invoice->get_items() as $item ) {
601
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
600
+        foreach ($invoice->get_items() as $item) {
601
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
602 602
         }
603 603
 
604
-        wp_send_json_success( compact( 'items', 'alert' ) );
604
+        wp_send_json_success(compact('items', 'alert'));
605 605
     }
606 606
 
607 607
     /**
@@ -609,63 +609,63 @@  discard block
 block discarded – undo
609 609
      */
610 610
     public static function create_invoice_item() {
611 611
         // Verify nonce.
612
-        check_ajax_referer( 'wpinv-nonce' );
612
+        check_ajax_referer('wpinv-nonce');
613 613
 
614 614
         // We need an invoice and item details.
615
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
615
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
616 616
             exit;
617 617
         }
618 618
 
619
-        $invoice_id = absint( $_POST['invoice_id'] );
619
+        $invoice_id = absint($_POST['invoice_id']);
620 620
 
621
-        if ( empty( $invoice_id ) ) {
621
+        if (empty($invoice_id)) {
622 622
             exit;
623 623
         }
624 624
 
625
-        if ( ! wpinv_current_user_can( 'invoice_create_item', array( 'invoice_id' => $invoice_id ) ) ) {
625
+        if (!wpinv_current_user_can('invoice_create_item', array('invoice_id' => $invoice_id))) {
626 626
             exit;
627 627
         }
628 628
 
629 629
         // Fetch the invoice.
630
-        $invoice = new WPInv_Invoice( $invoice_id );
630
+        $invoice = new WPInv_Invoice($invoice_id);
631 631
 
632 632
         // Ensure it exists and its not been paid for.
633
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
633
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
634 634
             exit;
635 635
         }
636 636
 
637 637
         // Format the data.
638
-        $data = wp_kses_post_deep( wp_unslash( $_POST['_wpinv_quick'] ) );
638
+        $data = wp_kses_post_deep(wp_unslash($_POST['_wpinv_quick']));
639 639
 
640 640
         $item = new WPInv_Item();
641
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
642
-        $item->set_name( sanitize_text_field( $data['name'] ) );
643
-        $item->set_description( wp_kses_post( $data['description'] ) );
644
-        $item->set_type( sanitize_text_field( $data['type'] ) );
645
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
646
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
647
-        $item->set_status( 'publish' );
641
+        $item->set_price(getpaid_standardize_amount($data['price']));
642
+        $item->set_name(sanitize_text_field($data['name']));
643
+        $item->set_description(wp_kses_post($data['description']));
644
+        $item->set_type(sanitize_text_field($data['type']));
645
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
646
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
647
+        $item->set_status('publish');
648 648
         $item->save();
649 649
 
650
-        if ( ! $item->exists() ) {
651
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
652
-            wp_send_json_success( compact( 'alert' ) );
650
+        if (!$item->exists()) {
651
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
652
+            wp_send_json_success(compact('alert'));
653 653
         }
654 654
 
655
-        if ( ! empty( $data['one-time'] ) ) {
656
-            update_post_meta( $item->get_id(), '_wpinv_one_time', 'yes' );
655
+        if (!empty($data['one-time'])) {
656
+            update_post_meta($item->get_id(), '_wpinv_one_time', 'yes');
657 657
         }
658 658
 
659
-        $item = new GetPaid_Form_Item( $item->get_id() );
660
-        $item->set_quantity( floatval( $data['qty'] ) );
659
+        $item = new GetPaid_Form_Item($item->get_id());
660
+        $item->set_quantity(floatval($data['qty']));
661 661
 
662 662
         // Add it to the invoice.
663
-        $error = $invoice->add_item( $item );
663
+        $error = $invoice->add_item($item);
664 664
         $alert = false;
665 665
 
666
-        if ( is_wp_error( $error ) ) {
666
+        if (is_wp_error($error)) {
667 667
             $alert = $error->get_error_message();
668
-            wp_send_json_success( compact( 'alert' ) );
668
+            wp_send_json_success(compact('alert'));
669 669
          }
670 670
 
671 671
         // Update totals.
@@ -678,9 +678,9 @@  discard block
 block discarded – undo
678 678
         $invoice->recalculate_total();
679 679
         $invoice->save();
680 680
         ob_start();
681
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
681
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
682 682
         $row = ob_get_clean();
683
-        wp_send_json_success( compact( 'row' ) );
683
+        wp_send_json_success(compact('row'));
684 684
     }
685 685
 
686 686
     /**
@@ -688,37 +688,37 @@  discard block
 block discarded – undo
688 688
      */
689 689
     public static function remove_invoice_item() {
690 690
         // Verify nonce.
691
-        check_ajax_referer( 'wpinv-nonce' );
691
+        check_ajax_referer('wpinv-nonce');
692 692
 
693 693
         // We need an invoice and item.
694
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
695
-        $item_id = ! empty( $_POST['item_id'] ) ? absint( $_POST['item_id'] ) : 0;
694
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
695
+        $item_id = !empty($_POST['item_id']) ? absint($_POST['item_id']) : 0;
696 696
 
697
-        if ( empty( $invoice_id ) || empty( $item_id ) ) {
697
+        if (empty($invoice_id) || empty($item_id)) {
698 698
             exit;
699 699
         }
700 700
 
701 701
         // Can the user manage the plugin?
702
-        if ( ! wpinv_current_user_can( 'invoice_remove_item', array( 'invoice_id' => $invoice_id, 'item_id' => $item_id ) ) ) {
702
+        if (!wpinv_current_user_can('invoice_remove_item', array('invoice_id' => $invoice_id, 'item_id' => $item_id))) {
703 703
             exit;
704 704
         }
705 705
 
706 706
         // Fetch the invoice.
707
-        $invoice = new WPInv_Invoice( $invoice_id );
707
+        $invoice = new WPInv_Invoice($invoice_id);
708 708
 
709 709
         // Ensure it exists and its not been paid for.
710
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
710
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
711 711
             exit;
712 712
         }
713 713
 
714 714
         // Abort if the invoice does not have the specified item.
715
-        $item = $invoice->get_item( $item_id );
715
+        $item = $invoice->get_item($item_id);
716 716
 
717
-        if ( empty( $item ) ) {
717
+        if (empty($item)) {
718 718
             exit;
719 719
         }
720 720
 
721
-        $invoice->remove_item( $item_id );
721
+        $invoice->remove_item($item_id);
722 722
 
723 723
         // Update totals.
724 724
         $invoice->recalculate_total();
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
         // Return an array of invoice items.
730 730
         $items = array();
731 731
 
732
-        foreach ( $invoice->get_items() as $item ) {
733
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
732
+        foreach ($invoice->get_items() as $item) {
733
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
734 734
         }
735 735
 
736
-        wp_send_json_success( compact( 'items' ) );
736
+        wp_send_json_success(compact('items'));
737 737
     }
738 738
 
739 739
     /**
@@ -741,69 +741,69 @@  discard block
 block discarded – undo
741 741
      */
742 742
     public static function recalculate_full_prices() {
743 743
         // Verify nonce.
744
-        check_ajax_referer( 'wpinv-nonce' );
744
+        check_ajax_referer('wpinv-nonce');
745 745
 
746
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
746
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
747 747
 
748
-        if ( empty( $invoice_id ) ) {
748
+        if (empty($invoice_id)) {
749 749
             exit;
750 750
         }
751 751
 
752
-        if ( ! wpinv_current_user_can( 'invoice_recalculate_full_prices', array( 'invoice_id' => $invoice_id ) ) ) {
752
+        if (!wpinv_current_user_can('invoice_recalculate_full_prices', array('invoice_id' => $invoice_id))) {
753 753
             exit;
754 754
         }
755 755
 
756 756
         // Fetch the invoice.
757
-        $invoice = new WPInv_Invoice( $invoice_id );
757
+        $invoice = new WPInv_Invoice($invoice_id);
758 758
         $alert   = false;
759 759
 
760 760
         // Ensure it exists and its not been paid for.
761
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
761
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
762 762
             exit;
763 763
         }
764 764
 
765
-        $invoice->set_items( array() );
765
+        $invoice->set_items(array());
766 766
 
767
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
767
+        if (!empty($_POST['getpaid_items'])) {
768 768
 
769
-            foreach ( wp_kses_post_deep( $_POST['getpaid_items'] ) as $item_id => $args ) {
770
-                $item = new GetPaid_Form_Item( $item_id );
769
+            foreach (wp_kses_post_deep($_POST['getpaid_items']) as $item_id => $args) {
770
+                $item = new GetPaid_Form_Item($item_id);
771 771
 
772
-                if ( $item->exists() ) {
773
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
774
-                    $item->set_quantity( floatval( $args['quantity'] ) );
775
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
776
-                    $item->set_description( wp_kses_post( $args['description'] ) );
777
-                    $invoice->add_item( $item );
772
+                if ($item->exists()) {
773
+                    $item->set_price(getpaid_standardize_amount($args['price']));
774
+                    $item->set_quantity(floatval($args['quantity']));
775
+                    $item->set_name(sanitize_text_field($args['name']));
776
+                    $item->set_description(wp_kses_post($args['description']));
777
+                    $invoice->add_item($item);
778 778
                 }
779 779
             }
780 780
 }
781 781
 
782
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
782
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
783 783
 
784 784
         // Maybe set the country, state, currency.
785
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
786
-            if ( isset( $_POST[ $key ] ) ) {
787
-                $_key   = str_replace( 'wpinv_', '', $key );
785
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
786
+            if (isset($_POST[$key])) {
787
+                $_key   = str_replace('wpinv_', '', $key);
788 788
                 $method = "set_$_key";
789
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
789
+                $invoice->$method(sanitize_text_field($_POST[$key]));
790 790
             }
791 791
         }
792 792
 
793
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
794
-        if ( $discount->exists() ) {
795
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
793
+        $discount = new WPInv_Discount($invoice->get_discount_code());
794
+        if ($discount->exists()) {
795
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
796 796
         } else {
797
-            $invoice->remove_discount( 'discount_code' );
797
+            $invoice->remove_discount('discount_code');
798 798
         }
799 799
 
800 800
         // Save the invoice.
801 801
         $invoice->recalculate_total();
802 802
         $invoice->save();
803 803
         ob_start();
804
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
804
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
805 805
         $table = ob_get_clean();
806
-        wp_send_json_success( compact( 'table' ) );
806
+        wp_send_json_success(compact('table'));
807 807
     }
808 808
 
809 809
     /**
@@ -811,47 +811,47 @@  discard block
 block discarded – undo
811 811
      */
812 812
     public static function admin_add_invoice_item() {
813 813
         // Verify nonce.
814
-        check_ajax_referer( 'wpinv-nonce' );
814
+        check_ajax_referer('wpinv-nonce');
815 815
 
816 816
         // We need an invoice and item.
817
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
818
-        $item_id = ! empty( $_POST['item_id'] ) ? absint( $_POST['item_id'] ) : 0;
817
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
818
+        $item_id = !empty($_POST['item_id']) ? absint($_POST['item_id']) : 0;
819 819
 
820
-        if ( empty( $invoice_id ) || empty( $item_id ) ) {
820
+        if (empty($invoice_id) || empty($item_id)) {
821 821
             exit;
822 822
         }
823 823
 
824 824
         // Can the user manage the plugin?
825
-        if ( ! wpinv_current_user_can( 'invoice_add_item', array( 'invoice_id' => $invoice_id, 'item_id' => $item_id ) ) ) {
825
+        if (!wpinv_current_user_can('invoice_add_item', array('invoice_id' => $invoice_id, 'item_id' => $item_id))) {
826 826
             exit;
827 827
         }
828 828
 
829 829
         // Fetch the invoice.
830
-        $invoice = new WPInv_Invoice( $invoice_id );
830
+        $invoice = new WPInv_Invoice($invoice_id);
831 831
         $alert   = false;
832 832
 
833 833
         // Ensure it exists and its not been paid for.
834
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
834
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
835 835
             exit;
836 836
         }
837 837
 
838 838
         // Add the item.
839
-        $item  = new GetPaid_Form_Item( $item_id );
839
+        $item  = new GetPaid_Form_Item($item_id);
840 840
 
841
-        $error = $invoice->add_item( $item );
841
+        $error = $invoice->add_item($item);
842 842
 
843
-        if ( is_wp_error( $error ) ) {
843
+        if (is_wp_error($error)) {
844 844
             $alert = $error->get_error_message();
845
-            wp_send_json_success( compact( 'alert' ) );
845
+            wp_send_json_success(compact('alert'));
846 846
         }
847 847
 
848 848
         // Save the invoice.
849 849
         $invoice->recalculate_total();
850 850
         $invoice->save();
851 851
         ob_start();
852
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
852
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
853 853
         $row = ob_get_clean();
854
-        wp_send_json_success( compact( 'row' ) );
854
+        wp_send_json_success(compact('row'));
855 855
     }
856 856
 
857 857
     /**
@@ -859,42 +859,42 @@  discard block
 block discarded – undo
859 859
      */
860 860
     public static function add_invoice_items() {
861 861
         // Verify nonce.
862
-        check_ajax_referer( 'wpinv-nonce' );
862
+        check_ajax_referer('wpinv-nonce');
863 863
 
864
-        $invoice_id = ! empty( $_POST['post_id'] ) ? absint( $_POST['post_id'] ) : 0;
864
+        $invoice_id = !empty($_POST['post_id']) ? absint($_POST['post_id']) : 0;
865 865
 
866 866
         // We need an invoice and items.
867
-        if ( empty( $invoice_id ) || empty( $_POST['items'] ) ) {
867
+        if (empty($invoice_id) || empty($_POST['items'])) {
868 868
             exit;
869 869
         }
870 870
 
871 871
         // Can the user manage the plugin?
872
-        if ( ! wpinv_current_user_can( 'invoice_add_items', array( 'invoice_id' => $invoice_id ) ) ) {
872
+        if (!wpinv_current_user_can('invoice_add_items', array('invoice_id' => $invoice_id))) {
873 873
             exit;
874 874
         }
875 875
 
876 876
         // Fetch the invoice.
877
-        $invoice = new WPInv_Invoice( $invoice_id );
877
+        $invoice = new WPInv_Invoice($invoice_id);
878 878
         $alert   = false;
879 879
 
880 880
         // Ensure it exists and its not been paid for.
881
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
881
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
882 882
             exit;
883 883
         }
884 884
 
885 885
         // Add the items.
886
-        foreach ( wp_kses_post_deep( wp_unslash( $_POST['items'] ) ) as $data ) {
886
+        foreach (wp_kses_post_deep(wp_unslash($_POST['items'])) as $data) {
887 887
 
888
-            $item = new GetPaid_Form_Item( (int) $data['id'] );
888
+            $item = new GetPaid_Form_Item((int) $data['id']);
889 889
 
890
-            if ( is_numeric( $data['qty'] ) && (float) $data['qty'] > 0 ) {
891
-                $item->set_quantity( floatval( $data['qty'] ) );
890
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
891
+                $item->set_quantity(floatval($data['qty']));
892 892
             }
893 893
 
894
-            if ( $item->get_id() > 0 ) {
895
-                $error = $invoice->add_item( $item );
894
+            if ($item->get_id() > 0) {
895
+                $error = $invoice->add_item($item);
896 896
 
897
-                if ( is_wp_error( $error ) ) {
897
+                if (is_wp_error($error)) {
898 898
                     $alert = $error->get_error_message();
899 899
                 }
900 900
 }
@@ -907,11 +907,11 @@  discard block
 block discarded – undo
907 907
         // Return an array of invoice items.
908 908
         $items = array();
909 909
 
910
-        foreach ( $invoice->get_items() as $item ) {
911
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
910
+        foreach ($invoice->get_items() as $item) {
911
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
912 912
         }
913 913
 
914
-        wp_send_json_success( compact( 'items', 'alert' ) );
914
+        wp_send_json_success(compact('items', 'alert'));
915 915
     }
916 916
 
917 917
     /**
@@ -919,16 +919,16 @@  discard block
 block discarded – undo
919 919
      */
920 920
     public static function get_invoicing_items() {
921 921
         // Verify nonce.
922
-        check_ajax_referer( 'wpinv-nonce' );
922
+        check_ajax_referer('wpinv-nonce');
923 923
 
924 924
         // Can the user manage the plugin?
925
-        if ( ! wpinv_current_user_can( 'get_invoicing_items' ) ) {
925
+        if (!wpinv_current_user_can('get_invoicing_items')) {
926 926
             exit;
927 927
         }
928 928
 
929 929
         // We need a search term.
930
-        if ( empty( $_GET['search'] ) ) {
931
-            wp_send_json_success( array() );
930
+        if (empty($_GET['search'])) {
931
+            wp_send_json_success(array());
932 932
         }
933 933
 
934 934
         // Retrieve items.
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
             'orderby'        => 'title',
938 938
             'order'          => 'ASC',
939 939
             'posts_per_page' => -1,
940
-            'post_status'    => array( 'publish' ),
941
-            's'              => sanitize_text_field( urldecode( $_GET['search'] ) ),
940
+            'post_status'    => array('publish'),
941
+            's'              => sanitize_text_field(urldecode($_GET['search'])),
942 942
             'meta_query'     => array(
943 943
                 array(
944 944
                     'key'     => '_wpinv_type',
@@ -952,25 +952,25 @@  discard block
 block discarded – undo
952 952
             ),
953 953
         );
954 954
 
955
-        if ( ! empty( $_GET['ignore'] ) ) {
956
-            $item_args['exclude'] = wp_parse_id_list( sanitize_text_field( $_GET['ignore'] ) );
955
+        if (!empty($_GET['ignore'])) {
956
+            $item_args['exclude'] = wp_parse_id_list(sanitize_text_field($_GET['ignore']));
957 957
         }
958 958
 
959
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
959
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
960 960
         $data  = array();
961 961
 
962
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( (int) $_GET['post_id'] ) );
962
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type((int) $_GET['post_id']));
963 963
 
964
-        foreach ( $items as $item ) {
965
-            $item      = new GetPaid_Form_Item( $item );
964
+        foreach ($items as $item) {
965
+            $item = new GetPaid_Form_Item($item);
966 966
             $data[] = array(
967 967
                 'id'        => (int) $item->get_id(),
968
-                'text'      => strip_tags( $item->get_name() ),
969
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
968
+                'text'      => strip_tags($item->get_name()),
969
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
970 970
             );
971 971
         }
972 972
 
973
-        wp_send_json_success( $data );
973
+        wp_send_json_success($data);
974 974
 
975 975
     }
976 976
 
@@ -979,40 +979,40 @@  discard block
 block discarded – undo
979 979
      */
980 980
     public static function get_customers() {
981 981
         // Verify nonce.
982
-        check_ajax_referer( 'wpinv-nonce' );
982
+        check_ajax_referer('wpinv-nonce');
983 983
 
984
-        $invoice_id = ! empty( $_REQUEST['post_id'] ) ? (int) $_REQUEST['post_id'] : 0;
984
+        $invoice_id = !empty($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;
985 985
 
986 986
         // Can the user manage the plugin?
987
-        if ( ! wpinv_current_user_can( 'invoice_get_customers', array( 'invoice_id' => $invoice_id ) ) ) {
987
+        if (!wpinv_current_user_can('invoice_get_customers', array('invoice_id' => $invoice_id))) {
988 988
             die( -1 );
989 989
         }
990 990
 
991 991
         // We need a search term.
992
-        if ( empty( $_GET['search'] ) ) {
993
-            wp_send_json_success( array() );
992
+        if (empty($_GET['search'])) {
993
+            wp_send_json_success(array());
994 994
         }
995 995
 
996 996
         // Retrieve customers.
997 997
 
998 998
         $customer_args = array(
999
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
999
+            'fields'         => array('ID', 'user_email', 'display_name'),
1000 1000
             'orderby'        => 'display_name',
1001
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
1002
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
1001
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
1002
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
1003 1003
         );
1004 1004
 
1005
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
1005
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
1006 1006
         $data      = array();
1007 1007
 
1008
-        foreach ( $customers as $customer ) {
1008
+        foreach ($customers as $customer) {
1009 1009
             $data[] = array(
1010 1010
                 'id'   => (int) $customer->ID,
1011
-                'text' => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
1011
+                'text' => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
1012 1012
             );
1013 1013
         }
1014 1014
 
1015
-        wp_send_json_success( $data );
1015
+        wp_send_json_success($data);
1016 1016
 
1017 1017
     }
1018 1018
 
@@ -1022,25 +1022,25 @@  discard block
 block discarded – undo
1022 1022
     public static function get_aui_states_field() {
1023 1023
 
1024 1024
         // We need a country.
1025
-        if ( empty( $_GET['country'] ) ) {
1025
+        if (empty($_GET['country'])) {
1026 1026
             exit;
1027 1027
         }
1028 1028
 
1029
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
1030
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
1031
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
1032
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
1029
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
1030
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
1031
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
1032
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
1033 1033
 
1034
-        if ( empty( $states ) ) {
1034
+        if (empty($states)) {
1035 1035
 
1036 1036
             $html = aui()->input(
1037 1037
                 array(
1038 1038
                     'type'        => 'text',
1039 1039
                     'id'          => 'wpinv_state',
1040 1040
                     'name'        => $name,
1041
-                    'label'       => __( 'State', 'invoicing' ),
1041
+                    'label'       => __('State', 'invoicing'),
1042 1042
                     'label_type'  => 'vertical',
1043
-                    'placeholder' => __( 'State', 'invoicing' ),
1043
+                    'placeholder' => __('State', 'invoicing'),
1044 1044
                     'class'       => $class,
1045 1045
                     'value'       => $state,
1046 1046
                 )
@@ -1052,9 +1052,9 @@  discard block
 block discarded – undo
1052 1052
                 array(
1053 1053
                     'id'               => 'wpinv_state',
1054 1054
                     'name'             => $name,
1055
-                    'label'            => __( 'State', 'invoicing' ),
1055
+                    'label'            => __('State', 'invoicing'),
1056 1056
                     'label_type'       => 'vertical',
1057
-                    'placeholder'      => __( 'Select a state', 'invoicing' ),
1057
+                    'placeholder'      => __('Select a state', 'invoicing'),
1058 1058
                     'class'            => $class,
1059 1059
                     'value'            => $state,
1060 1060
                     'options'          => $states,
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
         wp_send_json_success(
1069 1069
             array(
1070 1070
                 'html'   => $html,
1071
-                'select' => ! empty( $states ),
1071
+                'select' => !empty($states),
1072 1072
             )
1073 1073
         );
1074 1074
 
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
     public static function payment_form_refresh_prices() {
1083 1083
 
1084 1084
         // ... form fields...
1085
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1086
-            esc_html_e( 'Error: Reload the page and try again.', 'invoicing' );
1085
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1086
+            esc_html_e('Error: Reload the page and try again.', 'invoicing');
1087 1087
             exit;
1088 1088
         }
1089 1089
 
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
         $submission = new GetPaid_Payment_Form_Submission();
1092 1092
 
1093 1093
         // Do we have an error?
1094
-        if ( ! empty( $submission->last_error ) ) {
1094
+        if (!empty($submission->last_error)) {
1095 1095
             wp_send_json_error(
1096 1096
                 array(
1097 1097
                     'code'  => $submission->last_error_code,
@@ -1101,12 +1101,12 @@  discard block
 block discarded – undo
1101 1101
         }
1102 1102
 
1103 1103
         // Prepare the response.
1104
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1104
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1105 1105
 
1106 1106
         // Filter the response.
1107
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1107
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1108 1108
 
1109
-        wp_send_json_success( $response );
1109
+        wp_send_json_success($response);
1110 1110
     }
1111 1111
 
1112 1112
     /**
@@ -1118,63 +1118,63 @@  discard block
 block discarded – undo
1118 1118
 	public static function file_upload() {
1119 1119
 
1120 1120
         // Check nonce.
1121
-        check_ajax_referer( 'getpaid_form_nonce' );
1121
+        check_ajax_referer('getpaid_form_nonce');
1122 1122
 
1123
-        if ( empty( $_POST['form_id'] ) || empty( $_POST['field_name'] ) || empty( $_FILES['file'] ) ) {
1124
-            wp_die( esc_html_e( 'Bad Request', 'invoicing' ), 400 );
1123
+        if (empty($_POST['form_id']) || empty($_POST['field_name']) || empty($_FILES['file'])) {
1124
+            wp_die(esc_html_e('Bad Request', 'invoicing'), 400);
1125 1125
         }
1126 1126
 
1127 1127
         // Fetch form.
1128
-        $form = new GetPaid_Payment_Form( intval( $_POST['form_id'] ) );
1128
+        $form = new GetPaid_Payment_Form(intval($_POST['form_id']));
1129 1129
 
1130
-        if ( ! $form->is_active() ) {
1131
-            wp_send_json_error( __( 'Payment form not active', 'invoicing' ) );
1130
+        if (!$form->is_active()) {
1131
+            wp_send_json_error(__('Payment form not active', 'invoicing'));
1132 1132
         }
1133 1133
 
1134 1134
         // Fetch appropriate field.
1135
-        $upload_field = current( wp_list_filter( $form->get_elements(), array( 'id' => sanitize_text_field( $_POST['field_name'] ) ) ) );
1136
-        if ( empty( $upload_field ) ) {
1137
-            wp_send_json_error( __( 'Invalid upload field.', 'invoicing' ) );
1135
+        $upload_field = current(wp_list_filter($form->get_elements(), array('id' => sanitize_text_field($_POST['field_name']))));
1136
+        if (empty($upload_field)) {
1137
+            wp_send_json_error(__('Invalid upload field.', 'invoicing'));
1138 1138
         }
1139 1139
 
1140 1140
         // Prepare allowed file types.
1141
-        $file_types = isset( $upload_field['file_types'] ) ? $upload_field['file_types'] : array( 'jpg|jpeg|jpe', 'gif', 'png' );
1141
+        $file_types = isset($upload_field['file_types']) ? $upload_field['file_types'] : array('jpg|jpeg|jpe', 'gif', 'png');
1142 1142
         $all_types  = getpaid_get_allowed_mime_types();
1143 1143
         $mime_types = array();
1144 1144
 
1145
-        foreach ( $file_types as $file_type ) {
1146
-            if ( isset( $all_types[ $file_type ] ) ) {
1147
-                $mime_types[] = $all_types[ $file_type ];
1145
+        foreach ($file_types as $file_type) {
1146
+            if (isset($all_types[$file_type])) {
1147
+                $mime_types[] = $all_types[$file_type];
1148 1148
             }
1149 1149
         }
1150 1150
 
1151
-        if ( ! in_array( $_FILES['file']['type'], $mime_types ) ) {
1152
-            wp_send_json_error( __( 'Unsupported file type.', 'invoicing' ) );
1151
+        if (!in_array($_FILES['file']['type'], $mime_types)) {
1152
+            wp_send_json_error(__('Unsupported file type.', 'invoicing'));
1153 1153
         }
1154 1154
 
1155 1155
         // Upload file.
1156
-        $file_name = explode( '.', strtolower( $_FILES['file']['name'] ) );
1157
-        $file_name = uniqid( 'getpaid-' ) . '.' . array_pop( $file_name );
1156
+        $file_name = explode('.', strtolower($_FILES['file']['name']));
1157
+        $file_name = uniqid('getpaid-') . '.' . array_pop($file_name);
1158 1158
 
1159 1159
         $uploaded = wp_upload_bits(
1160 1160
             $file_name,
1161 1161
             null,
1162
-            file_get_contents( $_FILES['file']['tmp_name'] )
1162
+            file_get_contents($_FILES['file']['tmp_name'])
1163 1163
         );
1164 1164
 
1165
-        if ( ! empty( $uploaded['error'] ) ) {
1166
-            wp_send_json_error( $uploaded['error'] );
1165
+        if (!empty($uploaded['error'])) {
1166
+            wp_send_json_error($uploaded['error']);
1167 1167
         }
1168 1168
 
1169 1169
         // Retrieve response.
1170 1170
         $response = sprintf(
1171 1171
             '<input type="hidden" name="%s[%s]" value="%s" />',
1172
-            esc_attr( sanitize_text_field( $_POST['field_name'] ) ),
1173
-            esc_url( $uploaded['url'] ),
1174
-            esc_attr( sanitize_text_field( strtolower( $_FILES['file']['name'] ) ) )
1172
+            esc_attr(sanitize_text_field($_POST['field_name'])),
1173
+            esc_url($uploaded['url']),
1174
+            esc_attr(sanitize_text_field(strtolower($_FILES['file']['name'])))
1175 1175
         );
1176 1176
 
1177
-        wp_send_json_success( $response );
1177
+        wp_send_json_success($response);
1178 1178
 
1179 1179
 	}
1180 1180
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-authorize-net-gateway.php 1 patch
Spacing   +206 added lines, -206 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
  * Authorize.net Payment Gateway class.
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @var array
63 63
 	 */
64
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
64
+	public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD');
65 65
 
66 66
     /**
67 67
 	 * URL to view a transaction.
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function __construct() {
77 77
 
78
-        $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
79
-        $this->method_title         = __( 'Authorize.Net', 'invoicing' );
80
-        $this->notify_url           = getpaid_get_non_query_string_ipn_url( $this->id );
78
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
79
+        $this->method_title         = __('Authorize.Net', 'invoicing');
80
+        $this->notify_url           = getpaid_get_non_query_string_ipn_url($this->id);
81 81
 
82
-        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
83
-        add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) );
82
+        add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
83
+        add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice'));
84 84
         parent::__construct();
85 85
     }
86 86
 
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
 	 * @param int $invoice_id 0 or invoice id.
91 91
 	 * @param GetPaid_Payment_Form $form Current payment form.
92 92
 	 */
93
-    public function payment_fields( $invoice_id, $form ) {
93
+    public function payment_fields($invoice_id, $form) {
94 94
 
95 95
         // Let the user select a payment method.
96 96
         $this->saved_payment_methods();
97 97
 
98 98
         // Show the credit card entry form.
99
-        $this->new_payment_method_entry( $this->get_cc_form( true ) );
99
+        $this->new_payment_method_entry($this->get_cc_form(true));
100 100
     }
101 101
 
102 102
     /**
@@ -109,79 +109,79 @@  discard block
 block discarded – undo
109 109
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
110 110
 	 * @return string|WP_Error Payment profile id.
111 111
 	 */
112
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
112
+	public function create_customer_profile($invoice, $submission_data, $save = true) {
113 113
 
114 114
         // Remove non-digits from the number
115
-        $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
115
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
116 116
 
117 117
         // Generate args.
118 118
         $args = array(
119 119
             'createCustomerProfileRequest' => array(
120 120
                 'merchantAuthentication' => $this->get_auth_params(),
121 121
                 'profile'                => array(
122
-                    'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ),
123
-                    'description'        => getpaid_limit_length( $invoice->get_full_name(), 255 ),
124
-                    'email'              => getpaid_limit_length( $invoice->get_email(), 255 ),
122
+                    'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20),
123
+                    'description'        => getpaid_limit_length($invoice->get_full_name(), 255),
124
+                    'email'              => getpaid_limit_length($invoice->get_email(), 255),
125 125
                     'paymentProfiles'    => array(
126 126
                         'customerType' => 'individual',
127 127
 
128 128
                         // Billing information.
129 129
                         'billTo'       => array(
130
-                            'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ),
131
-                            'lastName'  => getpaid_limit_length( $invoice->get_last_name(), 50 ),
132
-                            'address'   => getpaid_limit_length( $invoice->get_address(), 60 ),
133
-                            'city'      => getpaid_limit_length( $invoice->get_city(), 40 ),
134
-                            'state'     => getpaid_limit_length( $invoice->get_state(), 40 ),
135
-                            'zip'       => getpaid_limit_length( $invoice->get_zip(), 20 ),
136
-                            'country'   => getpaid_limit_length( $invoice->get_country(), 60 ),
130
+                            'firstName' => getpaid_limit_length($invoice->get_first_name(), 50),
131
+                            'lastName'  => getpaid_limit_length($invoice->get_last_name(), 50),
132
+                            'address'   => getpaid_limit_length($invoice->get_address(), 60),
133
+                            'city'      => getpaid_limit_length($invoice->get_city(), 40),
134
+                            'state'     => getpaid_limit_length($invoice->get_state(), 40),
135
+                            'zip'       => getpaid_limit_length($invoice->get_zip(), 20),
136
+                            'country'   => getpaid_limit_length($invoice->get_country(), 60),
137 137
                         ),
138 138
 
139 139
                         // Payment information.
140
-                        'payment'      => $this->get_payment_information( $submission_data['authorizenet'] ),
140
+                        'payment'      => $this->get_payment_information($submission_data['authorizenet']),
141 141
                     ),
142 142
                 ),
143
-                'validationMode'         => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
143
+                'validationMode'         => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
144 144
             ),
145 145
         );
146 146
 
147
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice );
147
+        $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice);
148 148
 
149
-        if ( is_wp_error( $response ) ) {
149
+        if (is_wp_error($response)) {
150 150
 
151 151
             // In case the payment profile already exists remotely.
152
-            if ( 'dup_payment_profile' === $response->get_error_code() ) {
153
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
154
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
155
-                return strtok( '.' );
152
+            if ('dup_payment_profile' === $response->get_error_code()) {
153
+                $customer_profile_id = strtok($response->get_error_message(), '.');
154
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
155
+                return strtok('.');
156 156
             }
157 157
 
158 158
             // In case the customer profile already exists remotely.
159
-            if ( 'E00039' === $response->get_error_code() ) {
160
-                $customer_profile_id = str_replace( 'A duplicate record with ID ', '', $response->get_error_message() );
161
-                $customer_profile_id = str_replace( ' already exists.', '', $customer_profile_id );
162
-                return $this->create_customer_payment_profile( trim( $customer_profile_id ), $invoice, $submission_data, $save );
159
+            if ('E00039' === $response->get_error_code()) {
160
+                $customer_profile_id = str_replace('A duplicate record with ID ', '', $response->get_error_message());
161
+                $customer_profile_id = str_replace(' already exists.', '', $customer_profile_id);
162
+                return $this->create_customer_payment_profile(trim($customer_profile_id), $invoice, $submission_data, $save);
163 163
             }
164 164
 
165 165
             return $response;
166 166
         }
167 167
 
168
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
168
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
169 169
 
170 170
         // Save the payment token.
171
-        if ( $save ) {
171
+        if ($save) {
172 172
             $this->save_token(
173 173
                 array(
174 174
                     'id'      => $response->customerPaymentProfileIdList[0],
175
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '&middot;&middot;&middot;&middot;' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
175
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '&middot;&middot;&middot;&middot;' . substr($submission_data['authorizenet']['cc_number'], -4),
176 176
                     'default' => true,
177
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
177
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
178 178
                 )
179 179
             );
180 180
         }
181 181
 
182 182
         // Add a note about the validation response.
183 183
         $invoice->add_note(
184
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
184
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
185 185
             false,
186 186
             false,
187 187
             true
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string|WP_Error Profile id.
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
200 200
 	 */
201
-	public function get_customer_profile( $profile_id ) {
201
+	public function get_customer_profile($profile_id) {
202 202
 
203 203
         // Generate args.
204 204
         $args = array(
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
             ),
209 209
         );
210 210
 
211
-        return $this->post( $args, false );
211
+        return $this->post($args, false);
212 212
 
213 213
     }
214 214
 
@@ -223,18 +223,18 @@  discard block
 block discarded – undo
223 223
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
224 224
 	 * @return string|WP_Error Profile id.
225 225
 	 */
226
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
226
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
227 227
 
228 228
         // Remove non-digits from the number
229
-        $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
229
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
230 230
 
231 231
         // Prepare card details.
232
-        $payment_information                          = $this->get_payment_information( $submission_data['authorizenet'] );
232
+        $payment_information                          = $this->get_payment_information($submission_data['authorizenet']);
233 233
 
234 234
         // Authorize.NET does not support saving the same card twice.
235
-        $cached_information                           = $this->retrieve_payment_profile_from_cache( $payment_information, $customer_profile, $invoice );
235
+        $cached_information                           = $this->retrieve_payment_profile_from_cache($payment_information, $customer_profile, $invoice);
236 236
 
237
-        if ( $cached_information ) {
237
+        if ($cached_information) {
238 238
             return $cached_information;
239 239
         }
240 240
 
@@ -247,34 +247,34 @@  discard block
 block discarded – undo
247 247
 
248 248
                     // Billing information.
249 249
                     'billTo'  => array(
250
-                        'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ),
251
-                        'lastName'  => getpaid_limit_length( $invoice->get_last_name(), 50 ),
252
-                        'address'   => getpaid_limit_length( $invoice->get_address(), 60 ),
253
-                        'city'      => getpaid_limit_length( $invoice->get_city(), 40 ),
254
-                        'state'     => getpaid_limit_length( $invoice->get_state(), 40 ),
255
-                        'zip'       => getpaid_limit_length( $invoice->get_zip(), 20 ),
256
-                        'country'   => getpaid_limit_length( $invoice->get_country(), 60 ),
250
+                        'firstName' => getpaid_limit_length($invoice->get_first_name(), 50),
251
+                        'lastName'  => getpaid_limit_length($invoice->get_last_name(), 50),
252
+                        'address'   => getpaid_limit_length($invoice->get_address(), 60),
253
+                        'city'      => getpaid_limit_length($invoice->get_city(), 40),
254
+                        'state'     => getpaid_limit_length($invoice->get_state(), 40),
255
+                        'zip'       => getpaid_limit_length($invoice->get_zip(), 20),
256
+                        'country'   => getpaid_limit_length($invoice->get_country(), 60),
257 257
                     ),
258 258
 
259 259
                     // Payment information.
260 260
                     'payment' => $payment_information,
261 261
                 ),
262
-                'validationMode'         => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
262
+                'validationMode'         => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
263 263
             ),
264 264
         );
265 265
 
266
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
266
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
267 267
 
268
-        if ( is_wp_error( $response ) ) {
268
+        if (is_wp_error($response)) {
269 269
 
270 270
             // In case the payment profile already exists remotely.
271
-            if ( 'dup_payment_profile' == $response->get_error_code() ) {
272
-                $customer_profile_id = strtok( $response->get_error_message(), '.' );
273
-                $payment_profile_id  = strtok( '.' );
274
-                update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile_id );
271
+            if ('dup_payment_profile' == $response->get_error_code()) {
272
+                $customer_profile_id = strtok($response->get_error_message(), '.');
273
+                $payment_profile_id  = strtok('.');
274
+                update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile_id);
275 275
 
276 276
                 // Cache payment profile id.
277
-                $this->add_payment_profile_to_cache( $payment_information, $payment_profile_id );
277
+                $this->add_payment_profile_to_cache($payment_information, $payment_profile_id);
278 278
 
279 279
                 return $payment_profile_id;
280 280
             }
@@ -283,29 +283,29 @@  discard block
 block discarded – undo
283 283
         }
284 284
 
285 285
         // Save the payment token.
286
-        if ( $save ) {
286
+        if ($save) {
287 287
             $this->save_token(
288 288
                 array(
289 289
                     'id'      => $response->customerPaymentProfileId,
290
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' &middot;&middot;&middot;&middot; ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
290
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' &middot;&middot;&middot;&middot; ' . substr($submission_data['authorizenet']['cc_number'], -4),
291 291
                     'default' => true,
292
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
292
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
293 293
                 )
294 294
             );
295 295
         }
296 296
 
297 297
         // Cache payment profile id.
298
-        $this->add_payment_profile_to_cache( $payment_information, $response->customerPaymentProfileId );
298
+        $this->add_payment_profile_to_cache($payment_information, $response->customerPaymentProfileId);
299 299
 
300 300
         // Add a note about the validation response.
301 301
         $invoice->add_note(
302
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
302
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
303 303
             false,
304 304
             false,
305 305
             true
306 306
         );
307 307
 
308
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $customer_profile );
308
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $customer_profile);
309 309
 
310 310
         return $response->customerPaymentProfileId;
311 311
     }
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
      * @param array $payment_details.
318 318
 	 * @return array|false Profile id.
319 319
 	 */
320
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
320
+	public function retrieve_payment_profile_from_cache($payment_details, $customer_profile, $invoice) {
321 321
 
322
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
323
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
322
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
323
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
324 324
 
325
-        if ( ! is_array( $cached_information ) || ! array_key_exists( $payment_details, $cached_information ) ) {
325
+        if (!is_array($cached_information) || !array_key_exists($payment_details, $cached_information)) {
326 326
             return false;
327 327
         }
328 328
 
@@ -331,13 +331,13 @@  discard block
 block discarded – undo
331 331
             'getCustomerPaymentProfileRequest' => array(
332 332
                 'merchantAuthentication'   => $this->get_auth_params(),
333 333
                 'customerProfileId'        => $customer_profile,
334
-                'customerPaymentProfileId' => $cached_information[ $payment_details ],
334
+                'customerPaymentProfileId' => $cached_information[$payment_details],
335 335
             ),
336 336
         );
337 337
 
338
-        $response = $this->post( $args, $invoice );
338
+        $response = $this->post($args, $invoice);
339 339
 
340
-        return is_wp_error( $response ) ? false : $cached_information[ $payment_details ];
340
+        return is_wp_error($response) ? false : $cached_information[$payment_details];
341 341
 
342 342
     }
343 343
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
      * @param array $payment_details.
349 349
      * @param string $payment_profile_id.
350 350
 	 */
351
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
351
+	public function add_payment_profile_to_cache($payment_details, $payment_profile_id) {
352 352
 
353
-        $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
354
-        $cached_information = is_array( $cached_information ) ? $cached_information : array();
355
-        $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
353
+        $cached_information = get_option('getpaid_authorize_net_cached_profiles', array());
354
+        $cached_information = is_array($cached_information) ? $cached_information : array();
355
+        $payment_details    = hash_hmac('sha256', json_encode($payment_details), SECURE_AUTH_KEY);
356 356
 
357
-        $cached_information[ $payment_details ] = $payment_profile_id;
358
-        update_option( 'getpaid_authorize_net_cached_profiles', $cached_information );
357
+        $cached_information[$payment_details] = $payment_profile_id;
358
+        update_option('getpaid_authorize_net_cached_profiles', $cached_information);
359 359
 
360 360
     }
361 361
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 * @return string|WP_Error Profile id.
369 369
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
370 370
 	 */
371
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
371
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
372 372
 
373 373
         // Generate args.
374 374
         $args = array(
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
             ),
380 380
         );
381 381
 
382
-        return $this->post( $args, false );
382
+        return $this->post($args, false);
383 383
 
384 384
     }
385 385
 
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
393 393
 	 * @return WP_Error|object
394 394
 	 */
395
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
395
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
396 396
 
397 397
         // Generate args.
398 398
         $args = array(
@@ -412,28 +412,28 @@  discard block
 block discarded – undo
412 412
                         ),
413 413
                     ),
414 414
                     'order'           => array(
415
-                        'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ),
415
+                        'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20),
416 416
                     ),
417
-                    'lineItems'       => array( 'lineItem' => $this->get_line_items( $invoice ) ),
417
+                    'lineItems'       => array('lineItem' => $this->get_line_items($invoice)),
418 418
                     'tax'             => array(
419 419
                         'amount' => $invoice->get_total_tax(),
420
-                        'name'   => __( 'TAX', 'invoicing' ),
420
+                        'name'   => __('TAX', 'invoicing'),
421 421
                     ),
422
-                    'poNumber'        => getpaid_limit_length( $invoice->get_number(), 25 ),
422
+                    'poNumber'        => getpaid_limit_length($invoice->get_number(), 25),
423 423
                     'customer'        => array(
424
-                        'id'    => getpaid_limit_length( $invoice->get_user_id(), 25 ),
425
-                        'email' => getpaid_limit_length( $invoice->get_email(), 25 ),
424
+                        'id'    => getpaid_limit_length($invoice->get_user_id(), 25),
425
+                        'email' => getpaid_limit_length($invoice->get_email(), 25),
426 426
                     ),
427 427
                     'customerIP'      => $invoice->get_ip(),
428 428
                 ),
429 429
             ),
430 430
         );
431 431
 
432
-        if ( 0 == $invoice->get_total_tax() ) {
433
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
432
+        if (0 == $invoice->get_total_tax()) {
433
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
434 434
         }
435 435
 
436
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
436
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
437 437
 
438 438
     }
439 439
 
@@ -443,31 +443,31 @@  discard block
 block discarded – undo
443 443
      * @param stdClass $result Api response.
444 444
 	 * @param WPInv_Invoice $invoice Invoice.
445 445
 	 */
446
-	public function process_charge_response( $result, $invoice ) {
446
+	public function process_charge_response($result, $invoice) {
447 447
 
448 448
         wpinv_clear_errors();
449 449
 		$response_code = (int) $result->transactionResponse->responseCode;
450 450
 
451
-        $invoice->add_note( 'Transaction Response: ' . print_r( $result->transactionResponse, true ), false, false, true );
451
+        $invoice->add_note('Transaction Response: ' . print_r($result->transactionResponse, true), false, false, true);
452 452
 
453 453
 		// Succeeded.
454
-		if ( 1 == $response_code || 4 == $response_code ) {
454
+		if (1 == $response_code || 4 == $response_code) {
455 455
 
456 456
 			// Maybe set a transaction id.
457
-			if ( ! empty( $result->transactionResponse->transId ) ) {
458
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
457
+			if (!empty($result->transactionResponse->transId)) {
458
+				$invoice->set_transaction_id($result->transactionResponse->transId);
459 459
 			}
460 460
 
461
-			$invoice->add_note( sprintf( __( 'Authentication code: %1$s (%2$s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
461
+			$invoice->add_note(sprintf(__('Authentication code: %1$s (%2$s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
462 462
 
463
-			if ( 1 == $response_code ) {
463
+			if (1 == $response_code) {
464 464
 				return $invoice->mark_paid();
465 465
 			}
466 466
 
467
-			$invoice->set_status( 'wpi-onhold' );
467
+			$invoice->set_status('wpi-onhold');
468 468
         	$invoice->add_note(
469 469
                 sprintf(
470
-                    __( 'Held for review: %s', 'invoicing' ),
470
+                    __('Held for review: %s', 'invoicing'),
471 471
                     $result->transactionResponse->messages->message[0]->description
472 472
                 )
473 473
 			);
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
 		}
478 478
 
479
-        wpinv_set_error( 'card_declined' );
479
+        wpinv_set_error('card_declined');
480 480
 
481
-        if ( ! empty( $result->transactionResponse->errors ) ) {
481
+        if (!empty($result->transactionResponse->errors)) {
482 482
             $errors = (object) $result->transactionResponse->errors;
483
-            wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) );
483
+            wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText));
484 484
         }
485 485
 
486 486
     }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * @param array $card Card details.
493 493
 	 * @return array
494 494
 	 */
495
-	public function get_payment_information( $card ) {
495
+	public function get_payment_information($card) {
496 496
         return array(
497 497
 
498 498
             'creditCard' => array(
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @param WPInv_Invoice $invoice Invoice.
512 512
 	 * @return string
513 513
 	 */
514
-	public function get_customer_profile_meta_name( $invoice ) {
515
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
514
+	public function get_customer_profile_meta_name($invoice) {
515
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
516 516
     }
517 517
 
518 518
     /**
@@ -523,34 +523,34 @@  discard block
 block discarded – undo
523 523
      * @param WPInv_Invoice $invoice
524 524
 	 * @return WP_Error|string The payment profile id
525 525
 	 */
526
-	public function validate_submission_data( $submission_data, $invoice ) {
526
+	public function validate_submission_data($submission_data, $invoice) {
527 527
 
528 528
         // Validate authentication details.
529 529
         $auth = $this->get_auth_params();
530 530
 
531
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
532
-            return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing' ) );
531
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
532
+            return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing'));
533 533
         }
534 534
 
535 535
         // Validate the payment method.
536
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
537
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing' ) );
536
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
537
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
538 538
         }
539 539
 
540 540
         // Are we adding a new payment method?
541
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
541
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
542 542
             return $submission_data['getpaid-authorizenet-payment-method'];
543 543
         }
544 544
 
545 545
         // Retrieve the customer profile id.
546
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
546
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
547 547
 
548 548
         // Create payment method.
549
-        if ( empty( $profile_id ) ) {
550
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
549
+        if (empty($profile_id)) {
550
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
551 551
         }
552 552
 
553
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
553
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
554 554
 
555 555
     }
556 556
 
@@ -561,32 +561,32 @@  discard block
 block discarded – undo
561 561
 	 * @param WPInv_Invoice $invoice Invoice.
562 562
 	 * @return array
563 563
 	 */
564
-	public function get_line_items( $invoice ) {
564
+	public function get_line_items($invoice) {
565 565
         $items = array();
566 566
 
567
-        foreach ( $invoice->get_items() as $item ) {
567
+        foreach ($invoice->get_items() as $item) {
568 568
 
569 569
             $amount  = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
570 570
             $items[] = array(
571
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
572
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
573
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
574
-                'quantity'    => (string) ( $invoice->get_template() == 'amount' ? 1 : $item->get_quantity() ),
571
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
572
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
573
+                'description' => getpaid_limit_length($item->get_description(), 255),
574
+                'quantity'    => (string) ($invoice->get_template() == 'amount' ? 1 : $item->get_quantity()),
575 575
                 'unitPrice'   => (float) $amount,
576 576
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
577 577
             );
578 578
 
579 579
         }
580 580
 
581
-        foreach ( $invoice->get_fees() as $fee_name => $fee ) {
581
+        foreach ($invoice->get_fees() as $fee_name => $fee) {
582 582
 
583
-            $amount  = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
583
+            $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
584 584
 
585
-            if ( $amount > 0 ) {
585
+            if ($amount > 0) {
586 586
                 $items[] = array(
587
-                    'itemId'      => getpaid_limit_length( $fee_name, 31 ),
588
-                    'name'        => getpaid_limit_length( $fee_name, 31 ),
589
-                    'description' => getpaid_limit_length( $fee_name, 255 ),
587
+                    'itemId'      => getpaid_limit_length($fee_name, 31),
588
+                    'name'        => getpaid_limit_length($fee_name, 31),
589
+                    'description' => getpaid_limit_length($fee_name, 255),
590 590
                     'quantity'    => '1',
591 591
                     'unitPrice'   => (float) $amount,
592 592
                     'taxable'     => false,
@@ -606,36 +606,36 @@  discard block
 block discarded – undo
606 606
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
607 607
 	 * @return array
608 608
 	 */
609
-	public function process_payment( $invoice, $submission_data, $submission ) {
609
+	public function process_payment($invoice, $submission_data, $submission) {
610 610
 
611 611
         // Validate the submitted data.
612
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
612
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
613 613
 
614 614
         // Do we have an error?
615
-        if ( is_wp_error( $payment_profile_id ) ) {
616
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
617
-            wpinv_send_back_to_checkout( $invoice );
615
+        if (is_wp_error($payment_profile_id)) {
616
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
617
+            wpinv_send_back_to_checkout($invoice);
618 618
         }
619 619
 
620 620
         // Save the payment method to the order.
621
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
621
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
622 622
 
623 623
         // Check if this is a subscription or not.
624
-        $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
625
-        if ( ! empty( $subscriptions ) ) {
626
-            $this->process_subscription( $invoice, $subscriptions );
624
+        $subscriptions = getpaid_get_invoice_subscriptions($invoice);
625
+        if (!empty($subscriptions)) {
626
+            $this->process_subscription($invoice, $subscriptions);
627 627
         }
628 628
 
629 629
         // If it is free, send to the success page.
630
-        if ( ! $invoice->needs_payment() ) {
630
+        if (!$invoice->needs_payment()) {
631 631
             $invoice->mark_paid();
632
-            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
632
+            wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
633 633
         }
634 634
 
635 635
         // Charge the payment profile.
636
-        $this->process_initial_payment( $invoice );
636
+        $this->process_initial_payment($invoice);
637 637
 
638
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
638
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
639 639
 
640 640
         exit;
641 641
 
@@ -646,23 +646,23 @@  discard block
 block discarded – undo
646 646
 	 *
647 647
      * @param WPInv_Invoice $invoice Invoice.
648 648
 	 */
649
-	protected function process_initial_payment( $invoice ) {
649
+	protected function process_initial_payment($invoice) {
650 650
 
651
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
652
-        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
653
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
651
+		$payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
652
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
653
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
654 654
 
655 655
 		// Do we have an error?
656
-		if ( is_wp_error( $result ) ) {
657
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
658
-			wpinv_send_back_to_checkout( $invoice );
656
+		if (is_wp_error($result)) {
657
+			wpinv_set_error($result->get_error_code(), $result->get_error_message());
658
+			wpinv_send_back_to_checkout($invoice);
659 659
 		}
660 660
 
661 661
 		// Process the response.
662
-		$this->process_charge_response( $result, $invoice );
662
+		$this->process_charge_response($result, $invoice);
663 663
 
664
-		if ( wpinv_get_errors() ) {
665
-			wpinv_send_back_to_checkout( $invoice );
664
+		if (wpinv_get_errors()) {
665
+			wpinv_send_back_to_checkout($invoice);
666 666
 		}
667 667
 
668 668
 	}
@@ -673,30 +673,30 @@  discard block
 block discarded – undo
673 673
      * @param WPInv_Invoice $invoice Invoice.
674 674
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
675 675
 	 */
676
-	public function process_subscription( $invoice, $subscriptions ) {
676
+	public function process_subscription($invoice, $subscriptions) {
677 677
 
678 678
         // Check if there is an initial amount to charge.
679
-        if ( (float) $invoice->get_total() > 0 ) {
680
-			$this->process_initial_payment( $invoice );
679
+        if ((float) $invoice->get_total() > 0) {
680
+			$this->process_initial_payment($invoice);
681 681
         }
682 682
 
683 683
         // Activate the subscriptions.
684
-        $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
684
+        $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
685 685
 
686
-        foreach ( $subscriptions as $subscription ) {
687
-            if ( $subscription->exists() ) {
688
-                $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
689
-                $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
686
+        foreach ($subscriptions as $subscription) {
687
+            if ($subscription->exists()) {
688
+                $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
689
+                $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
690 690
 
691
-                $subscription->set_next_renewal_date( $expiry );
692
-                $subscription->set_date_created( current_time( 'mysql' ) );
693
-                $subscription->set_profile_id( $invoice->generate_key( 'authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ) );
691
+                $subscription->set_next_renewal_date($expiry);
692
+                $subscription->set_date_created(current_time('mysql'));
693
+                $subscription->set_profile_id($invoice->generate_key('authnet_sub_' . $invoice->get_id() . '_' . $subscription->get_id()));
694 694
                 $subscription->activate();
695 695
             }
696 696
         }
697 697
 
698 698
 		// Redirect to the success page.
699
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
699
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
700 700
 
701 701
     }
702 702
 
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 	 *
707 707
      * @param WPInv_Subscription $subscription
708 708
 	 */
709
-	public function maybe_renew_subscription( $subscription ) {
709
+	public function maybe_renew_subscription($subscription) {
710 710
 
711 711
         // Ensure its our subscription && it's active.
712
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
713
-            $this->renew_subscription( $subscription );
712
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
713
+            $this->renew_subscription($subscription);
714 714
         }
715 715
 
716 716
 	}
@@ -720,28 +720,28 @@  discard block
 block discarded – undo
720 720
 	 *
721 721
      * @param WPInv_Subscription $subscription
722 722
 	 */
723
-	public function renew_subscription( $subscription ) {
723
+	public function renew_subscription($subscription) {
724 724
 
725 725
 		// Generate the renewal invoice.
726 726
 		$new_invoice = $subscription->create_payment();
727 727
 		$old_invoice = $subscription->get_parent_payment();
728 728
 
729
-        if ( empty( $new_invoice ) ) {
730
-            $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
729
+        if (empty($new_invoice)) {
730
+            $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
731 731
             $subscription->failing();
732 732
             return;
733 733
         }
734 734
 
735 735
         // Charge the payment method.
736
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
737
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
738
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
736
+		$payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
737
+		$customer_profile   = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true);
738
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
739 739
 
740 740
 		// Do we have an error?
741
-		if ( is_wp_error( $result ) ) {
741
+		if (is_wp_error($result)) {
742 742
 
743 743
 			$old_invoice->add_note(
744
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
744
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
745 745
 				true,
746 746
 				false,
747 747
 				true
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 		}
753 753
 
754 754
 		// Process the response.
755
-		$this->process_charge_response( $result, $new_invoice );
755
+		$this->process_charge_response($result, $new_invoice);
756 756
 
757
-		if ( wpinv_get_errors() ) {
757
+		if (wpinv_get_errors()) {
758 758
 
759 759
 			$old_invoice->add_note(
760
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
760
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
761 761
 				true,
762 762
 				false,
763 763
 				true
@@ -767,9 +767,9 @@  discard block
 block discarded – undo
767 767
 
768 768
         }
769 769
 
770
-        if ( ! $new_invoice->needs_payment() ) {
770
+        if (!$new_invoice->needs_payment()) {
771 771
             $subscription->renew();
772
-            $subscription->after_add_payment( $new_invoice );
772
+            $subscription->after_add_payment($new_invoice);
773 773
         } else {
774 774
             $subscription->failing();
775 775
         }
@@ -782,33 +782,33 @@  discard block
 block discarded – undo
782 782
 	 * @param GetPaid_Form_Item[] $items
783 783
 	 * @return WPInv_Invoice
784 784
 	 */
785
-	public function process_addons( $invoice, $items ) {
785
+	public function process_addons($invoice, $items) {
786 786
 
787 787
         global $getpaid_authorize_addons;
788 788
 
789 789
         $getpaid_authorize_addons = array();
790
-        foreach ( $items as $item ) {
790
+        foreach ($items as $item) {
791 791
 
792
-            if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) {
792
+            if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) {
793 793
                 $getpaid_authorize_addons[] = $item;
794 794
             }
795 795
 }
796 796
 
797
-        if ( empty( $getpaid_authorize_addons ) ) {
797
+        if (empty($getpaid_authorize_addons)) {
798 798
             return;
799 799
         }
800 800
 
801 801
         $invoice->recalculate_total();
802 802
 
803
-        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
804
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
803
+        $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
804
+		$customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
805 805
 
806
-        add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
807
-        $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
808
-        remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) );
806
+        add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2);
807
+        $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
808
+        remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'));
809 809
 
810
-        if ( is_wp_error( $result ) ) {
811
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
810
+        if (is_wp_error($result)) {
811
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
812 812
             return;
813 813
         }
814 814
 
@@ -821,19 +821,19 @@  discard block
 block discarded – undo
821 821
      * @param array $args
822 822
 	 * @return array
823 823
 	 */
824
-    public function filter_addons_request( $args ) {
824
+    public function filter_addons_request($args) {
825 825
 
826 826
         global $getpaid_authorize_addons;
827 827
         $total = 0;
828 828
 
829
-        foreach ( $getpaid_authorize_addons as $addon ) {
829
+        foreach ($getpaid_authorize_addons as $addon) {
830 830
             $total += $addon->get_sub_total();
831 831
         }
832 832
 
833 833
         $args['createTransactionRequest']['transactionRequest']['amount'] = $total;
834 834
 
835
-        if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) {
836
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
835
+        if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) {
836
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
837 837
         }
838 838
 
839 839
         return $args;
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
     public function sandbox_notice() {
847 847
 
848 848
         return sprintf(
849
-            __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
849
+            __('SANDBOX ENABLED. You can use sandbox testing details only. See the %1$sAuthorize.NET Sandbox Testing Guide%2$s for more details.', 'invoicing'),
850 850
             '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
851 851
             '</a>'
852 852
         );
@@ -858,42 +858,42 @@  discard block
 block discarded – undo
858 858
 	 *
859 859
 	 * @param array $admin_settings
860 860
 	 */
861
-	public function admin_settings( $admin_settings ) {
861
+	public function admin_settings($admin_settings) {
862 862
 
863 863
         $currencies = sprintf(
864
-            __( 'Supported Currencies: %s', 'invoicing' ),
865
-            implode( ', ', $this->currencies )
864
+            __('Supported Currencies: %s', 'invoicing'),
865
+            implode(', ', $this->currencies)
866 866
         );
867 867
 
868 868
         $admin_settings['authorizenet_active']['desc'] .= " ($currencies)";
869
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
869
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
870 870
 
871 871
         $admin_settings['authorizenet_login_id'] = array(
872 872
             'type' => 'text',
873 873
             'id'   => 'authorizenet_login_id',
874
-            'name' => __( 'API Login ID', 'invoicing' ),
875
-            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>',
874
+            'name' => __('API Login ID', 'invoicing'),
875
+            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>',
876 876
         );
877 877
 
878 878
         $admin_settings['authorizenet_transaction_key'] = array(
879 879
             'type' => 'text',
880 880
             'id'   => 'authorizenet_transaction_key',
881
-            'name' => __( 'Transaction Key', 'invoicing' ),
881
+            'name' => __('Transaction Key', 'invoicing'),
882 882
         );
883 883
 
884 884
         $admin_settings['authorizenet_signature_key'] = array(
885 885
             'type' => 'text',
886 886
             'id'   => 'authorizenet_signature_key',
887
-            'name' => __( 'Signature Key', 'invoicing' ),
888
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
887
+            'name' => __('Signature Key', 'invoicing'),
888
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
889 889
         );
890 890
 
891 891
         $admin_settings['authorizenet_ipn_url'] = array(
892 892
             'type'     => 'ipn_url',
893 893
             'id'       => 'authorizenet_ipn_url',
894
-            'name'     => __( 'Webhook URL', 'invoicing' ),
894
+            'name'     => __('Webhook URL', 'invoicing'),
895 895
             'std'      => $this->notify_url,
896
-            'desc'     => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
896
+            'desc'     => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
897 897
             'custom'   => 'authorizenet',
898 898
             'readonly' => true,
899 899
         );
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Spacing   +234 added lines, -234 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
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 			'getpaid_subscriptions'                                       => $this->get_id(),
163 163
 		);
164 164
 
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
165
+		foreach ($caches as $cache => $value) {
166
+			if ('' !== $value && false !== $value) {
167
+				wp_cache_delete($value, $cache);
168 168
 			}
169 169
 		}
170 170
 	}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
      * Checks if a subscription key is set.
174 174
      */
175
-    public function _isset( $key ) {
176
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
175
+    public function _isset($key) {
176
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
177 177
 	}
178 178
 
179 179
 	/*
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param  string $context View or edit context.
199 199
 	 * @return int
200 200
 	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
201
+	public function get_customer_id($context = 'view') {
202
+		return (int) $this->get_prop('customer_id', $context);
203 203
 	}
204 204
 
205 205
 	/**
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param  string $context View or edit context.
210 210
 	 * @return WP_User|false WP_User object on success, false on failure.
211 211
 	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
212
+	public function get_customer($context = 'view') {
213
+		return get_userdata($this->get_customer_id($context));
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * @param  string $context View or edit context.
221 221
 	 * @return int
222 222
 	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
223
+	public function get_parent_invoice_id($context = 'view') {
224
+		return (int) $this->get_prop('parent_payment_id', $context);
225 225
 	}
226 226
 
227 227
 	/**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 * @param  string $context View or edit context.
232 232
 	 * @return int
233 233
 	 */
234
-    public function get_parent_payment_id( $context = 'view' ) {
235
-        return $this->get_parent_invoice_id( $context );
234
+    public function get_parent_payment_id($context = 'view') {
235
+        return $this->get_parent_invoice_id($context);
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
      * @since  1.0.0
242 242
      * @return int
243 243
      */
244
-    public function get_original_payment_id( $context = 'view' ) {
245
-        return $this->get_parent_invoice_id( $context );
244
+    public function get_original_payment_id($context = 'view') {
245
+        return $this->get_parent_invoice_id($context);
246 246
     }
247 247
 
248 248
 	/**
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @param  string $context View or edit context.
253 253
 	 * @return WPInv_Invoice
254 254
 	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
255
+	public function get_parent_invoice($context = 'view') {
256
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
257 257
 	}
258 258
 
259 259
 	/**
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @param  string $context View or edit context.
264 264
 	 * @return WPInv_Invoice
265 265
 	 */
266
-    public function get_parent_payment( $context = 'view' ) {
267
-        return $this->get_parent_invoice( $context );
266
+    public function get_parent_payment($context = 'view') {
267
+        return $this->get_parent_invoice($context);
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 	 * @param  string $context View or edit context.
275 275
 	 * @return int
276 276
 	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
277
+	public function get_product_id($context = 'view') {
278
+		return (int) $this->get_prop('product_id', $context);
279 279
 	}
280 280
 
281 281
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param  string $context View or edit context.
286 286
 	 * @return WPInv_Item
287 287
 	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
288
+	public function get_product($context = 'view') {
289
+		return new WPInv_Item($this->get_product_id($context));
290 290
 	}
291 291
 
292 292
 	/**
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	 * @param  string $context View or edit context.
299 299
 	 * @return string
300 300
 	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
301
+	public function get_gateway($context = 'view') {
302
+		return $this->get_parent_invoice($context)->get_gateway();
303 303
 	}
304 304
 
305 305
 	/**
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 	 * @param  string $context View or edit context.
310 310
 	 * @return string
311 311
 	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
312
+	public function get_period($context = 'view') {
313
+		return $this->get_prop('period', $context);
314 314
 	}
315 315
 
316 316
 	/**
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 	 * @param  string $context View or edit context.
321 321
 	 * @return int
322 322
 	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
323
+	public function get_frequency($context = 'view') {
324
+		return (int) $this->get_prop('frequency', $context);
325 325
 	}
326 326
 
327 327
 	/**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param  string $context View or edit context.
332 332
 	 * @return float
333 333
 	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
334
+	public function get_initial_amount($context = 'view') {
335
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 * @param  string $context View or edit context.
343 343
 	 * @return float
344 344
 	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
345
+	public function get_recurring_amount($context = 'view') {
346
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
347 347
 	}
348 348
 
349 349
 	/**
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 * @param  string $context View or edit context.
354 354
 	 * @return int
355 355
 	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
356
+	public function get_bill_times($context = 'view') {
357
+		return (int) $this->get_prop('bill_times', $context);
358 358
 	}
359 359
 
360 360
 	/**
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	 * @param  string $context View or edit context.
365 365
 	 * @return string
366 366
 	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
367
+	public function get_transaction_id($context = 'view') {
368
+		return $this->get_prop('transaction_id', $context);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $context View or edit context.
376 376
 	 * @return string
377 377
 	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
378
+	public function get_created($context = 'view') {
379
+		return $this->get_prop('created', $context);
380 380
 	}
381 381
 
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $context View or edit context.
387 387
 	 * @return string
388 388
 	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
389
+	public function get_date_created($context = 'view') {
390
+		return $this->get_created($context);
391 391
 	}
392 392
 
393 393
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function get_time_created() {
400 400
 		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
401
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
402 402
 	}
403 403
 
404 404
 	/**
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	 * @param  string $context View or edit context.
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
412
-        $date = $this->get_date_created( $context );
411
+	public function get_date_created_gmt($context = 'view') {
412
+        $date = $this->get_date_created($context);
413 413
 
414
-        if ( $date ) {
415
-            $date = get_gmt_from_date( $date );
414
+        if ($date) {
415
+            $date = get_gmt_from_date($date);
416 416
         }
417 417
 		return $date;
418 418
 	}
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 * @param  string $context View or edit context.
425 425
 	 * @return string
426 426
 	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
427
+	public function get_next_renewal_date($context = 'view') {
428
+		return $this->get_prop('expiration', $context);
429 429
 	}
430 430
 
431 431
 	/**
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $context View or edit context.
436 436
 	 * @return string
437 437
 	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
438
+	public function get_expiration($context = 'view') {
439
+		return $this->get_next_renewal_date($context);
440 440
 	}
441 441
 
442 442
 	/**
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	public function get_expiration_time() {
449 449
 		$expiration = $this->get_expiration();
450 450
 
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
451
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
452
+			return current_time('timestamp');
453 453
 		}
454 454
 
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
455
+		$expiration = strtotime($expiration, current_time('timestamp'));
456
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
457 457
 	}
458 458
 
459 459
 	/**
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_next_renewal_date( $context );
466
+	public function get_next_renewal_date_gmt($context = 'view') {
467
+        $date = $this->get_next_renewal_date($context);
468 468
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
469
+        if ($date) {
470
+            $date = get_gmt_from_date($date);
471 471
         }
472 472
 		return $date;
473 473
 	}
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
482
+	public function get_trial_period($context = 'view') {
483
+		return $this->get_prop('trial_period', $context);
484 484
 	}
485 485
 
486 486
 	/**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
493
+	public function get_status($context = 'view') {
494
+		return $this->get_prop('status', $context);
495 495
 	}
496 496
 
497 497
 	/**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
504
+	public function get_profile_id($context = 'view') {
505
+		return $this->get_prop('profile_id', $context);
506 506
 	}
507 507
 
508 508
 	/*
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @since 1.0.19
518 518
 	 * @param  int $value The customer's id.
519 519
 	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
520
+	public function set_customer_id($value) {
521
+		$this->set_prop('customer_id', (int) $value);
522 522
 	}
523 523
 
524 524
 	/**
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @since 1.0.19
528 528
 	 * @param  int $value The parent invoice id.
529 529
 	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
530
+	public function set_parent_invoice_id($value) {
531
+		$this->set_prop('parent_payment_id', (int) $value);
532 532
 	}
533 533
 
534 534
 	/**
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @since 1.0.19
538 538
 	 * @param  int $value The parent invoice id.
539 539
 	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
540
+    public function set_parent_payment_id($value) {
541
+        $this->set_parent_invoice_id($value);
542 542
 	}
543 543
 
544 544
 	/**
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
      * @since 1.0.19
548 548
 	 * @param  int $value The parent invoice id.
549 549
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
550
+    public function set_original_payment_id($value) {
551
+        $this->set_parent_invoice_id($value);
552 552
 	}
553 553
 
554 554
 	/**
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 	 * @since 1.0.19
558 558
 	 * @param  int $value The subscription product id.
559 559
 	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
560
+	public function set_product_id($value) {
561
+		$this->set_prop('product_id', (int) $value);
562 562
 	}
563 563
 
564 564
 	/**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @since 1.0.19
568 568
 	 * @param  string $value The renewal period.
569 569
 	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
570
+	public function set_period($value) {
571
+		$this->set_prop('period', $value);
572 572
 	}
573 573
 
574 574
 	/**
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 	 * @since 1.0.19
578 578
 	 * @param  int $value The subscription frequency.
579 579
 	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
580
+	public function set_frequency($value) {
581
+		$value = empty($value) ? 1 : (int) $value;
582
+		$this->set_prop('frequency', absint($value));
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 * @since 1.0.19
589 589
 	 * @param  float $value The initial subcription amount.
590 590
 	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
591
+	public function set_initial_amount($value) {
592
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
593 593
 	}
594 594
 
595 595
 	/**
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 * @param  float $value The recurring subcription amount.
600 600
 	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
601
+	public function set_recurring_amount($value) {
602
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
603 603
 	}
604 604
 
605 605
 	/**
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @since 1.0.19
609 609
 	 * @param  int $value Bill times.
610 610
 	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
611
+	public function set_bill_times($value) {
612
+		$this->set_prop('bill_times', (int) $value);
613 613
 	}
614 614
 
615 615
 	/**
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * @since 1.0.19
619 619
 	 * @param string $value Bill times.
620 620
 	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
621
+	public function set_transaction_id($value) {
622
+		$this->set_prop('transaction_id', sanitize_text_field($value));
623 623
 	}
624 624
 
625 625
 	/**
@@ -628,15 +628,15 @@  discard block
 block discarded – undo
628 628
 	 * @since 1.0.19
629 629
 	 * @param string $value strtotime compliant date.
630 630
 	 */
631
-	public function set_created( $value ) {
632
-        $date = strtotime( $value );
631
+	public function set_created($value) {
632
+        $date = strtotime($value);
633 633
 
634
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
635
-            $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) );
634
+        if ($date && $value !== '0000-00-00 00:00:00') {
635
+            $this->set_prop('created', gmdate('Y-m-d H:i:s', $date));
636 636
             return;
637 637
         }
638 638
 
639
-		$this->set_prop( 'created', '' );
639
+		$this->set_prop('created', '');
640 640
 
641 641
 	}
642 642
 
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @since 1.0.19
647 647
 	 * @param string $value strtotime compliant date.
648 648
 	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
649
+	public function set_date_created($value) {
650
+		$this->set_created($value);
651 651
     }
652 652
 
653 653
 	/**
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * @since 1.0.19
657 657
 	 * @param string $value strtotime compliant date.
658 658
 	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
659
+	public function set_next_renewal_date($value) {
660
+		$date = strtotime($value);
661 661
 
662
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
663
-            $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
662
+        if ($date && $value !== '0000-00-00 00:00:00') {
663
+            $this->set_prop('expiration', gmdate('Y-m-d H:i:s', $date));
664 664
             return;
665 665
 		}
666 666
 
667
-		$this->set_prop( 'expiration', '' );
667
+		$this->set_prop('expiration', '');
668 668
 
669 669
 	}
670 670
 
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
 	 * @since 1.0.19
675 675
 	 * @param string $value strtotime compliant date.
676 676
 	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
677
+	public function set_expiration($value) {
678
+		$this->set_next_renewal_date($value);
679 679
     }
680 680
 
681 681
 	/**
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 * @since 1.0.19
685 685
 	 * @param string $value trial period e.g 1 year.
686 686
 	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
687
+	public function set_trial_period($value) {
688
+		$this->set_prop('trial_period', $value);
689 689
 	}
690 690
 
691 691
 	/**
@@ -694,22 +694,22 @@  discard block
 block discarded – undo
694 694
 	 * @since 1.0.19
695 695
 	 * @param string $new_status    New subscription status.
696 696
 	 */
697
-	public function set_status( $new_status ) {
697
+	public function set_status($new_status) {
698 698
 
699 699
 		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
700
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
701 701
 			return;
702 702
 		}
703 703
 
704
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
-		if ( true === $this->object_read && $old_status !== $new_status ) {
704
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
705
+		if (true === $this->object_read && $old_status !== $new_status) {
706 706
 			$this->status_transition = array(
707 707
 				'from' => $old_status,
708 708
 				'to'   => $new_status,
709 709
 			);
710 710
 		}
711 711
 
712
-		$this->set_prop( 'status', $new_status );
712
+		$this->set_prop('status', $new_status);
713 713
 	}
714 714
 
715 715
 	/**
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
 	 * @since 1.0.19
719 719
 	 * @param  string $value the remote profile id.
720 720
 	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
721
+	public function set_profile_id($value) {
722
+		$this->set_prop('profile_id', sanitize_text_field($value));
723 723
 	}
724 724
 
725 725
 	/*
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param string|array String or array of strings to check for.
738 738
 	 * @return bool
739 739
      */
740
-    public function has_status( $status ) {
741
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
740
+    public function has_status($status) {
741
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
742 742
 	}
743 743
 
744 744
 	/**
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function has_trial_period() {
750 750
 		$period = $this->get_trial_period();
751
-        return ! empty( $period );
751
+        return !empty($period);
752 752
 	}
753 753
 
754 754
 	/**
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 * @return bool
758 758
 	 */
759 759
 	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
760
+		return $this->has_status('active trialling') && !$this->is_expired();
761 761
 	}
762 762
 
763 763
 	/**
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	 * @return bool
767 767
 	 */
768 768
 	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
769
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp'));
770 770
 	}
771 771
 
772 772
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public function is_last_renewal() {
778 778
 		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
779
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
780 780
 	}
781 781
 
782 782
 	/*
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function create( $data = array() ) {
794
+	public function create($data = array()) {
795 795
 
796 796
 		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
797
+		if (is_array($data)) {
798
+			$this->set_props($data);
799 799
 		}
800 800
 
801 801
 		// Save the item.
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 	/**
807 807
 	 * Backwards compatibilty.
808 808
 	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
809
+	public function update($args = array()) {
810
+		return $this->create($args);
811 811
 	}
812 812
 
813 813
     /**
@@ -816,12 +816,12 @@  discard block
 block discarded – undo
816 816
      * @since  1.0.0
817 817
      * @return WP_Post[]
818 818
      */
819
-    public function get_child_payments( $hide_pending = true ) {
819
+    public function get_child_payments($hide_pending = true) {
820 820
 
821
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
821
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
822 822
 
823
-		if ( ! $hide_pending ) {
824
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
823
+		if (!$hide_pending) {
824
+			$statuses = array_keys(wpinv_get_invoice_statuses());
825 825
 		}
826 826
 
827 827
         return get_posts(
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return int
844 844
      */
845 845
     public function get_total_payments() {
846
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
846
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
847 847
     }
848 848
 
849 849
     /**
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     public function get_times_billed() {
856 856
         $times_billed = $this->get_total_payments();
857 857
 
858
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
858
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
859 859
             $times_billed--;
860 860
         }
861 861
 
@@ -870,52 +870,52 @@  discard block
 block discarded – undo
870 870
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873
-    public function add_payment( $args = array(), $invoice = false ) {
873
+    public function add_payment($args = array(), $invoice = false) {
874 874
 
875 875
 		// Process each payment once.
876
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
876
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
877 877
             return false;
878 878
         }
879 879
 
880 880
 		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
881
+		if (empty($invoice)) {
882
+			$invoice = $this->create_payment(false);
883 883
 
884
-			if ( empty( $invoice ) ) {
884
+			if (empty($invoice)) {
885 885
 				return false;
886 886
 			}
887 887
 		}
888 888
 
889 889
 		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
890
+		if (!empty($args['transaction_id'])) {
891
+			$invoice->set_transaction_id($args['transaction_id']);
892 892
 		}
893 893
 
894 894
 		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
895
+		$invoice->set_completed_date(current_time('mysql'));
896 896
 
897 897
 		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
898
+		if (!empty($args['gateway'])) {
899
+			$invoice->set_gateway($args['gateway']);
900 900
 		}
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
902
+		$invoice->set_status('wpi-renewal');
903 903
 		$invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
905
+		if (!$invoice->exists()) {
906 906
 			return false;
907 907
 		}
908 908
 
909
-		return $this->after_add_payment( $invoice );
909
+		return $this->after_add_payment($invoice);
910 910
 	}
911 911
 
912
-    public function after_add_payment( $invoice ) {
912
+    public function after_add_payment($invoice) {
913 913
 
914
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
914
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
915
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
916
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
917 917
 
918
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
918
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
919 919
 
920 920
         return $invoice->get_id();
921 921
 	}
@@ -927,47 +927,47 @@  discard block
 block discarded – undo
927 927
 	 * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930
-    public function create_payment( $save = true ) {
930
+    public function create_payment($save = true) {
931 931
 
932 932
 		$parent_invoice = $this->get_parent_payment();
933 933
 
934
-		if ( ! $parent_invoice->exists() ) {
934
+		if (!$parent_invoice->exists()) {
935 935
 			return false;
936 936
 		}
937 937
 
938 938
 		// Duplicate the parent invoice.
939
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
940
-		$invoice->set_parent_id( $parent_invoice->get_id() );
941
-		$invoice->set_subscription_id( $this->get_id() );
942
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
939
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
940
+		$invoice->set_parent_id($parent_invoice->get_id());
941
+		$invoice->set_subscription_id($this->get_id());
942
+		$invoice->set_remote_subscription_id($this->get_profile_id());
943 943
 
944 944
 		// Set invoice items.
945
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
945
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
946
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
947 947
 		$invoice_items      = array();
948 948
 
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
949
+		foreach ($invoice->get_items() as $item) {
950
+			if (in_array($item->get_id(), $allowed_items)) {
951 951
 				$invoice_items[] = $item;
952 952
 			}
953 953
 		}
954 954
 
955
-		$invoice->set_items( $invoice_items );
955
+		$invoice->set_items($invoice_items);
956 956
 
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
957
+		if (!empty($subscription_group['fees'])) {
958
+			$invoice->set_fees($subscription_group['fees']);
959 959
 		}
960 960
 
961 961
 		// Maybe recalculate discount (Pre-GetPaid Fix).
962
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
963
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
964
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
962
+		$discount = new WPInv_Discount($invoice->get_discount_code());
963
+		if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) {
964
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
965 965
 		}
966 966
 
967 967
 		$invoice->recalculate_total();
968
-		$invoice->set_status( 'wpi-pending' );
968
+		$invoice->set_status('wpi-pending');
969 969
 
970
-		if ( ! $save ) {
970
+		if (!$save) {
971 971
 			return $invoice;
972 972
 		}
973 973
 
@@ -982,24 +982,24 @@  discard block
 block discarded – undo
982 982
 	 * @since  1.0.0
983 983
 	 * @return int The subscription's id
984 984
 	 */
985
-	public function renew( $calculate_from = null ) {
985
+	public function renew($calculate_from = null) {
986 986
 
987 987
 		// Complete subscription if applicable
988
-		if ( $this->is_last_renewal() ) {
988
+		if ($this->is_last_renewal()) {
989 989
 			return $this->complete();
990 990
 		}
991 991
 
992 992
 		// Calculate new expiration
993 993
 		$frequency      = $this->get_frequency();
994 994
 		$period         = $this->get_period();
995
-		$calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
996
-		$new_expiration = strtotime( "+ $frequency $period", $calculate_from );
995
+		$calculate_from = empty($calculate_from) ? $this->get_expiration_time() : $calculate_from;
996
+		$new_expiration = strtotime("+ $frequency $period", $calculate_from);
997 997
 
998
-		$this->set_expiration( date( 'Y-m-d H:i:s', $new_expiration ) );
999
-		$this->set_status( 'active' );
998
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
999
+		$this->set_status('active');
1000 1000
 		$this->save();
1001 1001
 
1002
-		do_action( 'getpaid_subscription_renewed', $this );
1002
+		do_action('getpaid_subscription_renewed', $this);
1003 1003
 
1004 1004
 		return $this->get_id();
1005 1005
 	}
@@ -1015,11 +1015,11 @@  discard block
 block discarded – undo
1015 1015
 	public function complete() {
1016 1016
 
1017 1017
 		// Only mark a subscription as complete if it's not already cancelled.
1018
-		if ( $this->has_status( 'cancelled' ) ) {
1018
+		if ($this->has_status('cancelled')) {
1019 1019
 			return false;
1020 1020
 		}
1021 1021
 
1022
-		$this->set_status( 'completed' );
1022
+		$this->set_status('completed');
1023 1023
 		return $this->save();
1024 1024
 
1025 1025
 	}
@@ -1031,14 +1031,14 @@  discard block
 block discarded – undo
1031 1031
 	 * @param  bool $check_expiration
1032 1032
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1033 1033
 	 */
1034
-	public function expire( $check_expiration = false ) {
1034
+	public function expire($check_expiration = false) {
1035 1035
 
1036
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1036
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1037 1037
 			// Do not mark as expired since real expiration date is in the future
1038 1038
 			return false;
1039 1039
 		}
1040 1040
 
1041
-		$this->set_status( 'expired' );
1041
+		$this->set_status('expired');
1042 1042
 		return $this->save();
1043 1043
 
1044 1044
 	}
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 	 * @return int Subscription id.
1051 1051
 	 */
1052 1052
 	public function failing() {
1053
-		$this->set_status( 'failing' );
1053
+		$this->set_status('failing');
1054 1054
 		return $this->save();
1055 1055
 	}
1056 1056
 
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
      * @return int Subscription id.
1062 1062
      */
1063 1063
     public function cancel() {
1064
-		$this->set_status( 'cancelled' );
1064
+		$this->set_status('cancelled');
1065 1065
 		return $this->save();
1066 1066
     }
1067 1067
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 	 * @return bool
1073 1073
 	 */
1074 1074
 	public function can_cancel() {
1075
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1075
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1076 1076
 	}
1077 1077
 
1078 1078
     /**
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
      * @return      array
1084 1084
      */
1085 1085
     public function get_cancellable_statuses() {
1086
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1086
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1087 1087
     }
1088 1088
 
1089 1089
 	/**
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	 * @return string
1094 1094
 	 */
1095 1095
 	public function get_cancel_url() {
1096
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1097
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1096
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1097
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1098 1098
 	}
1099 1099
 
1100 1100
 	/**
@@ -1105,10 +1105,10 @@  discard block
 block discarded – undo
1105 1105
 	 */
1106 1106
 	public function get_view_url() {
1107 1107
 
1108
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1109
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1108
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1109
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1110 1110
 
1111
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1111
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1112 1112
 	}
1113 1113
 
1114 1114
 	/**
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 	 * @return bool
1122 1122
 	 */
1123 1123
 	public function can_renew() {
1124
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1124
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1125 1125
 	}
1126 1126
 
1127 1127
 	/**
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
             ),
1141 1141
             'getpaid-nonce'
1142 1142
         );
1143
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1143
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1144 1144
 	}
1145 1145
 
1146 1146
 	/**
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 	 * @return bool
1151 1151
 	 */
1152 1152
 	public function can_update() {
1153
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1153
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 				'subscription_id' => $this->get_id(),
1167 1167
             )
1168 1168
         );
1169
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1169
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1170 1170
 	}
1171 1171
 
1172 1172
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 	 * @return string
1177 1177
 	 */
1178 1178
 	public function get_status_label() {
1179
-		return getpaid_get_subscription_status_label( $this->get_status() );
1179
+		return getpaid_get_subscription_status_label($this->get_status());
1180 1180
 	}
1181 1181
 
1182 1182
 	/**
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
 	 */
1188 1188
 	public function get_status_class() {
1189 1189
 		$statuses = getpaid_get_subscription_status_classes();
1190
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1190
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark';
1191 1191
 	}
1192 1192
 
1193 1193
     /**
@@ -1198,9 +1198,9 @@  discard block
 block discarded – undo
1198 1198
      */
1199 1199
     public function get_status_label_html() {
1200 1200
 
1201
-		$status_label = sanitize_text_field( $this->get_status_label() );
1202
-		$class        = esc_attr( $this->get_status_class() );
1203
-		$status       = sanitize_html_class( $this->get_status() );
1201
+		$status_label = sanitize_text_field($this->get_status_label());
1202
+		$class        = esc_attr($this->get_status_class());
1203
+		$status       = sanitize_html_class($this->get_status());
1204 1204
 
1205 1205
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1206 1206
     }
@@ -1212,9 +1212,9 @@  discard block
 block discarded – undo
1212 1212
      * @param  string $txn_id The transaction ID from the merchant processor
1213 1213
      * @return bool
1214 1214
      */
1215
-    public function payment_exists( $txn_id = '' ) {
1216
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1217
-        return ! empty( $invoice_id );
1215
+    public function payment_exists($txn_id = '') {
1216
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1217
+        return !empty($invoice_id);
1218 1218
 	}
1219 1219
 
1220 1220
 	/**
@@ -1226,35 +1226,35 @@  discard block
 block discarded – undo
1226 1226
 		// Reset status transition variable.
1227 1227
 		$this->status_transition = false;
1228 1228
 
1229
-		if ( $status_transition ) {
1229
+		if ($status_transition) {
1230 1230
 			try {
1231 1231
 
1232 1232
 				// Fire a hook for the status change.
1233
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1234
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1233
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1234
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1235 1235
 
1236
-				if ( ! empty( $status_transition['from'] ) ) {
1236
+				if (!empty($status_transition['from'])) {
1237 1237
 
1238 1238
 					/* translators: 1: old subscription status 2: new subscription status */
1239
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1239
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1240 1240
 
1241 1241
 					// Note the transition occurred.
1242
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1242
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1243 1243
 
1244 1244
 					// Fire another hook.
1245
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1246
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1245
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1246
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1247 1247
 
1248 1248
 				} else {
1249 1249
 					/* translators: %s: new invoice status */
1250
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1250
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1251 1251
 
1252 1252
 					// Note the transition occurred.
1253
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1253
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1254 1254
 
1255 1255
 				}
1256
-			} catch ( Exception $e ) {
1257
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1256
+			} catch (Exception $e) {
1257
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1258 1258
 			}
1259 1259
 		}
1260 1260
 
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	 */
1281 1281
 	public function activate() {
1282 1282
 		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1283
-		$this->set_status( $status );
1283
+		$this->set_status($status);
1284 1284
 		return $this->save();
1285 1285
 	}
1286 1286
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-profile.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit; // Exit if accessed directly
9 9
 }
10 10
 
11
-if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
11
+if (!class_exists('GetPaid_Admin_Profile', false)) :
12 12
 
13 13
 	/**
14 14
 	 * GetPaid_Admin_Profile Class.
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		 * Hook in tabs.
20 20
 		 */
21 21
 		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
22
+			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100);
23
+			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100);
24 24
 
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
25
+			add_action('personal_options_update', array($this, 'save_customer_meta_fields'));
26
+			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields'));
27 27
 		}
28 28
 
29 29
 		/**
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
 				'getpaid_customer_meta_fields',
38 38
 				array(
39 39
 					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
40
+						'title'  => __('Billing Details (GetPaid)', 'invoicing'),
41 41
 						'fields' => array(
42 42
 							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
43
+								'label'       => __('First name', 'invoicing'),
44 44
 								'description' => '',
45 45
 							),
46 46
 							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
47
+								'label'       => __('Last name', 'invoicing'),
48 48
 								'description' => '',
49 49
 							),
50 50
 							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
51
+								'label'       => __('Company', 'invoicing'),
52 52
 								'description' => '',
53 53
 							),
54 54
 							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
55
+								'label'       => __('Company ID', 'invoicing'),
56 56
 								'description' => '',
57 57
 							),
58 58
 							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
59
+								'label'       => __('Address', 'invoicing'),
60 60
 								'description' => '',
61 61
 							),
62 62
 							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
63
+								'label'       => __('City', 'invoicing'),
64 64
 								'description' => '',
65 65
 							),
66 66
 							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
67
+								'label'       => __('Postcode / ZIP', 'invoicing'),
68 68
 								'description' => '',
69 69
 							),
70 70
 							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
71
+								'label'       => __('Country / Region', 'invoicing'),
72 72
 								'description' => '',
73 73
 								'class'       => 'getpaid_js_field-country',
74 74
 								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region&hellip;', 'invoicing')) + wpinv_get_country_list(),
76 76
 							),
77 77
 							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
78
+								'label'       => __('State / County', 'invoicing'),
79
+								'description' => __('State / County or state code', 'invoicing'),
80 80
 								'class'       => 'getpaid_js_field-state regular-text',
81 81
 							),
82 82
 							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
83
+								'label'       => __('Phone', 'invoicing'),
84 84
 								'description' => '',
85 85
 							),
86 86
 							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
87
+								'label'       => __('VAT Number', 'invoicing'),
88 88
 								'description' => '',
89 89
 							),
90 90
 						),
@@ -99,39 +99,39 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param WP_User $user
101 101
 		 */
102
-		public function add_customer_meta_fields( $user ) {
102
+		public function add_customer_meta_fields($user) {
103 103
 
104
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) {
105 105
 				return;
106 106
 			}
107 107
 
108 108
 			$show_fields = $this->get_customer_meta_fields();
109 109
 
110
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
110
+			foreach ($show_fields as $fieldset_key => $fieldset) :
111 111
 				?>
112
-				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
113
-				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
114
-					<?php foreach ( $fieldset['fields'] as $key => $field ) : ?>
112
+				<h2><?php echo esc_html($fieldset['title']); ?></h2>
113
+				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>">
114
+					<?php foreach ($fieldset['fields'] as $key => $field) : ?>
115 115
 						<tr>
116 116
 							<th>
117
-								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
117
+								<label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label>
118 118
 							</th>
119 119
 							<td>
120
-								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
121
-									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
120
+								<?php if (!empty($field['type']) && 'select' === $field['type']) : ?>
121
+									<select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;">
122 122
 										<?php
123
-											$selected = esc_attr( get_user_meta( $user->ID, $key, true ) );
124
-										foreach ( $field['options'] as $option_key => $option_value ) :
123
+											$selected = esc_attr(get_user_meta($user->ID, $key, true));
124
+										foreach ($field['options'] as $option_key => $option_value) :
125 125
 											?>
126
-											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $selected, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
126
+											<option value="<?php echo esc_attr($option_key); ?>" <?php selected($selected, $option_key, true); ?>><?php echo esc_html($option_value); ?></option>
127 127
 										<?php endforeach; ?>
128 128
 									</select>
129
-								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
130
-									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) get_user_meta( $user->ID, $key, true ), 1, true ); ?> />
129
+								<?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?>
130
+									<input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) get_user_meta($user->ID, $key, true), 1, true); ?> />
131 131
 								<?php else : ?>
132
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $this->get_user_meta( $user->ID, $key ) ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
132
+									<input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($this->get_user_meta($user->ID, $key)); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" />
133 133
 								<?php endif; ?>
134
-								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
134
+								<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
135 135
 							</td>
136 136
 						</tr>
137 137
 					<?php endforeach; ?>
@@ -145,28 +145,28 @@  discard block
 block discarded – undo
145 145
 		 *
146 146
 		 * @param int $user_id User ID of the user being saved
147 147
 		 */
148
-		public function save_customer_meta_fields( $user_id ) {
149
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
148
+		public function save_customer_meta_fields($user_id) {
149
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) {
150 150
 				return;
151 151
 			}
152 152
 
153 153
 			$save_fields = $this->get_customer_meta_fields();
154 154
 
155
-			$customer = getpaid_get_customer_by_user_id( get_current_user_id() );
155
+			$customer = getpaid_get_customer_by_user_id(get_current_user_id());
156 156
 
157
-			if ( empty( $customer ) ) {
158
-				$customer = new GetPaid_Customer( 0 );
159
-				$customer->clone_user( get_current_user_id() );
157
+			if (empty($customer)) {
158
+				$customer = new GetPaid_Customer(0);
159
+				$customer->clone_user(get_current_user_id());
160 160
 			}
161 161
 
162
-			foreach ( $save_fields as $fieldset ) {
162
+			foreach ($save_fields as $fieldset) {
163 163
 
164
-				foreach ( $fieldset['fields'] as $key => $field ) {
164
+				foreach ($fieldset['fields'] as $key => $field) {
165 165
 
166
-					if ( isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
167
-						$customer->set( $key, ! empty( $_POST[ $key ] ) );
168
-					} elseif ( isset( $_POST[ $key ] ) ) {
169
-						$customer->set( $key, wpinv_clean( $_POST[ $key ] ) );
166
+					if (isset($field['type']) && 'checkbox' === $field['type']) {
167
+						$customer->set($key, !empty($_POST[$key]));
168
+					} elseif (isset($_POST[$key])) {
169
+						$customer->set($key, wpinv_clean($_POST[$key]));
170 170
 					}
171 171
 				}
172 172
 			}
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		 * @param string $key     Key for user meta field
181 181
 		 * @return string
182 182
 		 */
183
-		protected function get_user_meta( $user_id, $key ) {
184
-			$value           = get_user_meta( $user_id, $key, true );
185
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
186
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
187
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
183
+		protected function get_user_meta($user_id, $key) {
184
+			$value           = get_user_meta($user_id, $key, true);
185
+			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name');
186
+			if (!$value && in_array($key, $existing_fields)) {
187
+				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true);
188 188
 			}
189 189
 
190 190
 			return $value;
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-customer-data-store.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Customer_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @param GetPaid_Customer $customer customer object.
28 28
 	 */
29
-	public function create( &$customer ) {
29
+	public function create(&$customer) {
30 30
 		global $wpdb;
31 31
 
32 32
 		$values  = array();
33 33
 		$formats = array();
34 34
 
35 35
 		$fields = self::get_database_fields();
36
-		unset( $fields['id'] );
36
+		unset($fields['id']);
37 37
 
38
-		foreach ( $fields as $key => $format ) {
39
-			$values[ $key ] = $customer->get( $key, 'edit' );
38
+		foreach ($fields as $key => $format) {
39
+			$values[$key] = $customer->get($key, 'edit');
40 40
 			$formats[]      = $format;
41 41
 		}
42 42
 
43
-		$result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
43
+		$result = $wpdb->insert($wpdb->prefix . 'getpaid_customers', $values, $formats);
44 44
 
45
-		if ( $result ) {
46
-			$customer->set_id( $wpdb->insert_id );
45
+		if ($result) {
46
+			$customer->set_id($wpdb->insert_id);
47 47
 			$customer->apply_changes();
48 48
 			$customer->clear_cache();
49
-			do_action( 'getpaid_new_customer', $customer );
49
+			do_action('getpaid_new_customer', $customer);
50 50
 			return true;
51 51
 		}
52 52
 
@@ -59,22 +59,22 @@  discard block
 block discarded – undo
59 59
 	 * @param GetPaid_Customer $customer customer object.
60 60
 	 *
61 61
 	 */
62
-	public function read( &$customer ) {
62
+	public function read(&$customer) {
63 63
 		global $wpdb;
64 64
 
65 65
 		$customer->set_defaults();
66 66
 
67
-		if ( ! $customer->get_id() ) {
67
+		if (!$customer->get_id()) {
68 68
 			$customer->last_error = 'Invalid customer.';
69
-			$customer->set_id( 0 );
69
+			$customer->set_id(0);
70 70
 			return false;
71 71
 		}
72 72
 
73 73
 		// Maybe retrieve from the cache.
74
-		$raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
74
+		$raw_customer = wp_cache_get($customer->get_id(), 'getpaid_customers');
75 75
 
76 76
 		// If not found, retrieve from the db.
77
-		if ( false === $raw_customer ) {
77
+		if (false === $raw_customer) {
78 78
 
79 79
 			$raw_customer = $wpdb->get_row(
80 80
 				$wpdb->prepare(
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 			);
85 85
 
86 86
 			// Update the cache with our data
87
-			wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
87
+			wp_cache_set($customer->get_id(), $raw_customer, 'getpaid_customers');
88 88
 
89 89
 		}
90 90
 
91
-		if ( ! $raw_customer ) {
91
+		if (!$raw_customer) {
92 92
 			$raw_customer->last_error = 'Invalid customer.';
93 93
 			return false;
94 94
 		}
95 95
 
96 96
 		// Loop through raw customer fields.
97
-		foreach ( (array) $raw_customer as $key => $value ) {
98
-			$customer->set( $key, $value );
97
+		foreach ((array) $raw_customer as $key => $value) {
98
+			$customer->set($key, $value);
99 99
 		}
100 100
 
101
-		$customer->set_object_read( true );
102
-		do_action( 'getpaid_read_customer', $customer );
101
+		$customer->set_object_read(true);
102
+		do_action('getpaid_read_customer', $customer);
103 103
 
104 104
 	}
105 105
 
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param GetPaid_Customer $customer Customer object.
110 110
 	 */
111
-	public function update( &$customer ) {
111
+	public function update(&$customer) {
112 112
 		global $wpdb;
113 113
 
114
-		do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
114
+		do_action('getpaid_before_update_customer', $customer, $customer->get_changes());
115 115
 
116 116
 		$changes = $customer->get_changes();
117 117
 		$values  = array();
118 118
 		$format  = array();
119 119
 
120
-		foreach ( self::get_database_fields() as $key => $format ) {
121
-			if ( array_key_exists( $key, $changes ) ) {
122
-				$values[ $key ] = $customer->get( $key, 'edit' );
120
+		foreach (self::get_database_fields() as $key => $format) {
121
+			if (array_key_exists($key, $changes)) {
122
+				$values[$key] = $customer->get($key, 'edit');
123 123
 				$formats[]      = $format;
124 124
 			}
125 125
 		}
126 126
 
127
-		if ( empty( $values ) ) {
127
+		if (empty($values)) {
128 128
 			return;
129 129
 		}
130 130
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$customer->clear_cache();
146 146
 
147 147
 		// Fire a hook.
148
-		do_action( 'getpaid_update_customer', $customer );
148
+		do_action('getpaid_update_customer', $customer);
149 149
 
150 150
 	}
151 151
 
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @param GetPaid_Customer $customer
156 156
 	 */
157
-	public function delete( &$customer ) {
157
+	public function delete(&$customer) {
158 158
 		global $wpdb;
159 159
 
160
-		do_action( 'getpaid_before_delete_customer', $customer );
160
+		do_action('getpaid_before_delete_customer', $customer);
161 161
 
162 162
 		$wpdb->delete(
163 163
 			$wpdb->prefix . 'getpaid_customers',
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		$customer->clear_cache();
172 172
 
173 173
 		// Fire a hook.
174
-		do_action( 'getpaid_delete_customer', $customer );
174
+		do_action('getpaid_delete_customer', $customer);
175 175
 
176
-		$customer->set_id( 0 );
176
+		$customer->set_id(0);
177 177
 	}
178 178
 
179 179
 	/*
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 		);
198 198
 
199 199
 		// Add address fields.
200
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
200
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
201 201
 
202 202
 			// Skip id, user_id and email.
203
-			if ( ! in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
204
-				$fields[ $field ] = '%s';
203
+			if (!in_array($field, array('id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid'), true)) {
204
+				$fields[$field] = '%s';
205 205
 			}
206 206
 		}
207 207
 
Please login to merge, or discard this patch.