Passed
Push — master ( 0f9edb...599c71 )
by Kiran
12:27 queued 07:01
created
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
128 128
 
129 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
 
Please login to merge, or discard this patch.
Indentation   +821 added lines, -821 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,406 +21,406 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 */
29
-	class WP_Font_Awesome_Settings {
30
-
31
-		/**
32
-		 * Class version version.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $version = '1.1.7';
37
-
38
-		/**
39
-		 * Class textdomain.
40
-		 *
41
-		 * @var string
42
-		 */
43
-		public $textdomain = 'font-awesome-settings';
44
-
45
-		/**
46
-		 * Latest version of Font Awesome at time of publish published.
47
-		 *
48
-		 * @var string
49
-		 */
50
-		public $latest = "6.4.2";
51
-
52
-		/**
53
-		 * The title.
54
-		 *
55
-		 * @var string
56
-		 */
57
-		public $name = 'Font Awesome';
58
-
59
-		/**
60
-		 * Holds the settings values.
61
-		 *
62
-		 * @var array
63
-		 */
64
-		private $settings;
65
-
66
-		/**
67
-		 * WP_Font_Awesome_Settings instance.
68
-		 *
69
-		 * @access private
70
-		 * @since  1.0.0
71
-		 * @var    WP_Font_Awesome_Settings There can be only one!
72
-		 */
73
-		private static $instance = null;
74
-
75
-		/**
76
-		 * Main WP_Font_Awesome_Settings Instance.
77
-		 *
78
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
-		 *
80
-		 * @since 1.0.0
81
-		 * @static
82
-		 * @return WP_Font_Awesome_Settings - Main instance.
83
-		 */
84
-		public static function instance() {
85
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
-				self::$instance = new WP_Font_Awesome_Settings;
87
-
88
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
-
90
-				if ( is_admin() ) {
91
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
-					add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
-				}
96
-
97
-				do_action( 'wp_font_awesome_settings_loaded' );
98
-			}
99
-
100
-			return self::$instance;
101
-		}
102
-
103
-		/**
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     */
29
+    class WP_Font_Awesome_Settings {
30
+
31
+        /**
32
+         * Class version version.
33
+         *
34
+         * @var string
35
+         */
36
+        public $version = '1.1.7';
37
+
38
+        /**
39
+         * Class textdomain.
40
+         *
41
+         * @var string
42
+         */
43
+        public $textdomain = 'font-awesome-settings';
44
+
45
+        /**
46
+         * Latest version of Font Awesome at time of publish published.
47
+         *
48
+         * @var string
49
+         */
50
+        public $latest = "6.4.2";
51
+
52
+        /**
53
+         * The title.
54
+         *
55
+         * @var string
56
+         */
57
+        public $name = 'Font Awesome';
58
+
59
+        /**
60
+         * Holds the settings values.
61
+         *
62
+         * @var array
63
+         */
64
+        private $settings;
65
+
66
+        /**
67
+         * WP_Font_Awesome_Settings instance.
68
+         *
69
+         * @access private
70
+         * @since  1.0.0
71
+         * @var    WP_Font_Awesome_Settings There can be only one!
72
+         */
73
+        private static $instance = null;
74
+
75
+        /**
76
+         * Main WP_Font_Awesome_Settings Instance.
77
+         *
78
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
79
+         *
80
+         * @since 1.0.0
81
+         * @static
82
+         * @return WP_Font_Awesome_Settings - Main instance.
83
+         */
84
+        public static function instance() {
85
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
86
+                self::$instance = new WP_Font_Awesome_Settings;
87
+
88
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
89
+
90
+                if ( is_admin() ) {
91
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
+                    add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
+                    add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
95
+                }
96
+
97
+                do_action( 'wp_font_awesome_settings_loaded' );
98
+            }
99
+
100
+            return self::$instance;
101
+        }
102
+
103
+        /**
104 104
          * Define any constants that may be needed by other packages.
105 105
          *
106
-		 * @return void
107
-		 */
108
-		public function constants(){
106
+         * @return void
107
+         */
108
+        public function constants(){
109 109
 
110
-			// register iconpicker constant
111
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
-				$url = $this->get_path_url();
113
-				$version = $this->settings['version'];
110
+            // register iconpicker constant
111
+            if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
112
+                $url = $this->get_path_url();
113
+                $version = $this->settings['version'];
114 114
 
115
-				if( !$version || version_compare($version,'5.999','>')){
116
-					$url .= 'assets/js/fa-iconpicker-v6.min.js';
117
-				}else{
118
-					$url .= 'assets/js/fa-iconpicker-v5.min.js';
119
-				}
115
+                if( !$version || version_compare($version,'5.999','>')){
116
+                    $url .= 'assets/js/fa-iconpicker-v6.min.js';
117
+                }else{
118
+                    $url .= 'assets/js/fa-iconpicker-v5.min.js';
119
+                }
120 120
 
121
-				define( 'FAS_ICONPICKER_JS_URL', $url );
121
+                define( 'FAS_ICONPICKER_JS_URL', $url );
122 122
 
123
-			}
123
+            }
124 124
 
125 125
             // Set a constant if pro enbaled
126
-			if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
-				define( 'FAS_PRO', true );
128
-			}
129
-		}
130
-
131
-		/**
132
-		 * Get the url path to the current folder.
133
-		 *
134
-		 * @return string
135
-		 */
136
-		public function get_path_url() {
137
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
-			$content_url = untrailingslashit( WP_CONTENT_URL );
139
-
140
-			// Replace http:// to https://.
141
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
-				$content_url = str_replace( 'http://', 'https://', $content_url );
143
-			}
144
-
145
-			// Check if we are inside a plugin
146
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
-			$url = str_replace( $content_dir, $content_url, $file_dir );
148
-
149
-			return trailingslashit( $url );
150
-		}
151
-
152
-		/**
153
-		 * Initiate the settings and add the required action hooks.
154
-		 *
155
-		 * @since 1.0.8 Settings name wrong - FIXED
156
-		 */
157
-		public function init() {
158
-			// Download fontawesome locally.
159
-			add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
-			add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
-
162
-			$this->settings = $this->get_settings();
163
-
164
-			// Check if the official plugin is active and use that instead if so.
165
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
-					add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
-				}
169
-
170
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
-					add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
-				}
173
-
174
-				if ( $this->settings['type'] == 'CSS' ) {
175
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
-						//add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
-					}
179
-
180
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
-					}
184
-				} else {
185
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
-					}
188
-
189
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
-					}
193
-				}
194
-
195
-				// remove font awesome if set to do so
196
-				if ( $this->settings['dequeue'] == '1' ) {
197
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
-				}
199
-			}
200
-
201
-		}
202
-
203
-		/**
204
-		 * Add FA to the FSE.
205
-		 *
206
-		 * @param $editor_settings
207
-		 * @param $block_editor_context
208
-		 *
209
-		 * @return array
210
-		 */
211
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
-
213
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
-				$url = $this->get_url();
215
-				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
-			}
217
-
218
-			return $editor_settings;
219
-		}
220
-
221
-		/**
222
-		 * Add FA to the FSE.
223
-		 *
224
-		 * @param $editor_settings
225
-		 * @param $block_editor_context
226
-		 *
227
-		 * @return array
228
-		 */
229
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
-
231
-			$url = $this->get_url();
232
-			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
-
234
-			return $editor_settings;
235
-		}
236
-
237
-		/**
238
-		 * Adds the Font Awesome styles.
239
-		 */
240
-		public function enqueue_style() {
241
-			// build url
242
-			$url = $this->get_url();
243
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
-
245
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
-			wp_register_style( 'font-awesome', $url, array(), $version );
247
-			wp_enqueue_style( 'font-awesome' );
248
-
249
-			// RTL language support CSS.
250
-			if ( is_rtl() ) {
251
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
-			}
253
-
254
-			if ( $this->settings['shims'] ) {
255
-				$url = $this->get_url( true );
256
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
-				wp_enqueue_style( 'font-awesome-shims' );
259
-			}
260
-		}
261
-
262
-		/**
263
-		 * Adds the Font Awesome JS.
264
-		 */
265
-		public function enqueue_scripts() {
266
-			// build url
267
-			$url = $this->get_url();
268
-
269
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
-			wp_register_script( 'font-awesome', $url, array(), null );
272
-			wp_enqueue_script( 'font-awesome' );
273
-
274
-			if ( $this->settings['shims'] ) {
275
-				$url = $this->get_url( true );
276
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
278
-				wp_enqueue_script( 'font-awesome-shims' );
279
-			}
280
-		}
281
-
282
-		/**
283
-		 * Get the url of the Font Awesome files.
284
-		 *
285
-		 * @param bool $shims If this is a shim file or not.
286
-		 * @param bool $local Load locally if allowed.
287
-		 *
288
-		 * @return string The url to the file.
289
-		 */
290
-		public function get_url( $shims = false, $local = true ) {
291
-			$script  = $shims ? 'v4-shims' : 'all';
292
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
293
-			$type    = $this->settings['type'];
294
-			$version = $this->settings['version'];
295
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
-			$url     = '';
297
-
298
-			if ( $type == 'KIT' && $kit_url ) {
299
-				if ( $shims ) {
300
-					// if its a kit then we don't add shims here
301
-					return '';
302
-				}
303
-				$url .= $kit_url; // CDN
304
-				$url .= "?wpfas=true"; // set our var so our version is not removed
305
-			} else {
306
-				$v = '';
307
-				// Check and load locally.
308
-				if ( $local && $this->has_local() ) {
309
-					$script .= ".min";
310
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
-					$url .= $this->get_fonts_url(); // Local fonts url.
312
-				} else {
313
-					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
-				}
316
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
-				$url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
-			}
320
-
321
-			return $url;
322
-		}
323
-
324
-		/**
325
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
-		 *
327
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
328
-		 *
329
-		 * @param $url
330
-		 * @param $original_url
331
-		 * @param $_context
332
-		 *
333
-		 * @return string The filtered url.
334
-		 */
335
-		public function remove_font_awesome( $url, $original_url, $_context ) {
336
-
337
-			if ( $_context == 'display'
338
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
-			) {// it's a font-awesome-url (probably)
341
-
342
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
343
-					if ( $this->settings['type'] == 'JS' ) {
344
-						if ( $this->settings['js-pseudo'] ) {
345
-							$url .= "' data-search-pseudo-elements defer='defer";
346
-						} else {
347
-							$url .= "' defer='defer";
348
-						}
349
-					}
350
-				} else {
351
-					$url = ''; // removing the url removes the file
352
-				}
353
-
354
-			}
355
-
356
-			return $url;
357
-		}
358
-
359
-		/**
360
-		 * Register the database settings with WordPress.
361
-		 */
362
-		public function register_settings() {
363
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
-		}
365
-
366
-		/**
367
-		 * Add the WordPress settings menu item.
368
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
-		 */
370
-		public function menu_item() {
371
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
-				$this,
374
-				'settings_page'
375
-			) );
376
-		}
377
-
378
-		/**
379
-		 * Get the current Font Awesome output settings.
380
-		 *
381
-		 * @return array The array of settings.
382
-		 */
383
-		public function get_settings() {
384
-			$db_settings = get_option( 'wp-font-awesome-settings' );
385
-
386
-			$defaults = array(
387
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
388
-				'version'   => '', // latest
389
-				'enqueue'   => '', // front and backend
390
-				'shims'     => '0', // default OFF now in 2020
391
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
-				'pro'       => '0', // if pro CDN url should be used
394
-				'local'     => '0', // Store fonts locally.
395
-				'local_version' => '', // Local fonts version.
396
-				'kit-url'   => '', // the kit url
397
-			);
398
-
399
-			$settings = wp_parse_args( $db_settings, $defaults );
400
-
401
-			/**
402
-			 * Filter the Font Awesome settings.
403
-			 *
404
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
-			 */
406
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
-		}
408
-
409
-		/**
410
-		 * The settings page html output.
411
-		 */
412
-		public function settings_page() {
413
-			if ( ! current_user_can( 'manage_options' ) ) {
414
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
-			}
416
-
417
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
419
-				$this->get_latest_version( $force_api = true );
420
-			}
421
-
422
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
-				?>
126
+            if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
+                define( 'FAS_PRO', true );
128
+            }
129
+        }
130
+
131
+        /**
132
+         * Get the url path to the current folder.
133
+         *
134
+         * @return string
135
+         */
136
+        public function get_path_url() {
137
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
+            $content_url = untrailingslashit( WP_CONTENT_URL );
139
+
140
+            // Replace http:// to https://.
141
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
+                $content_url = str_replace( 'http://', 'https://', $content_url );
143
+            }
144
+
145
+            // Check if we are inside a plugin
146
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
+            $url = str_replace( $content_dir, $content_url, $file_dir );
148
+
149
+            return trailingslashit( $url );
150
+        }
151
+
152
+        /**
153
+         * Initiate the settings and add the required action hooks.
154
+         *
155
+         * @since 1.0.8 Settings name wrong - FIXED
156
+         */
157
+        public function init() {
158
+            // Download fontawesome locally.
159
+            add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
+            add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
161
+
162
+            $this->settings = $this->get_settings();
163
+
164
+            // Check if the official plugin is active and use that instead if so.
165
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
+                    add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
168
+                }
169
+
170
+                if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
+                    add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
172
+                }
173
+
174
+                if ( $this->settings['type'] == 'CSS' ) {
175
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
177
+                        //add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178
+                    }
179
+
180
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
183
+                    }
184
+                } else {
185
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
187
+                    }
188
+
189
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
192
+                    }
193
+                }
194
+
195
+                // remove font awesome if set to do so
196
+                if ( $this->settings['dequeue'] == '1' ) {
197
+                    add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
198
+                }
199
+            }
200
+
201
+        }
202
+
203
+        /**
204
+         * Add FA to the FSE.
205
+         *
206
+         * @param $editor_settings
207
+         * @param $block_editor_context
208
+         *
209
+         * @return array
210
+         */
211
+        public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
212
+
213
+            if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
214
+                $url = $this->get_url();
215
+                $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216
+            }
217
+
218
+            return $editor_settings;
219
+        }
220
+
221
+        /**
222
+         * Add FA to the FSE.
223
+         *
224
+         * @param $editor_settings
225
+         * @param $block_editor_context
226
+         *
227
+         * @return array
228
+         */
229
+        public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
230
+
231
+            $url = $this->get_url();
232
+            $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
233
+
234
+            return $editor_settings;
235
+        }
236
+
237
+        /**
238
+         * Adds the Font Awesome styles.
239
+         */
240
+        public function enqueue_style() {
241
+            // build url
242
+            $url = $this->get_url();
243
+            $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
244
+
245
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
+            wp_register_style( 'font-awesome', $url, array(), $version );
247
+            wp_enqueue_style( 'font-awesome' );
248
+
249
+            // RTL language support CSS.
250
+            if ( is_rtl() ) {
251
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
252
+            }
253
+
254
+            if ( $this->settings['shims'] ) {
255
+                $url = $this->get_url( true );
256
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
+                wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
+                wp_enqueue_style( 'font-awesome-shims' );
259
+            }
260
+        }
261
+
262
+        /**
263
+         * Adds the Font Awesome JS.
264
+         */
265
+        public function enqueue_scripts() {
266
+            // build url
267
+            $url = $this->get_url();
268
+
269
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
+            wp_register_script( 'font-awesome', $url, array(), null );
272
+            wp_enqueue_script( 'font-awesome' );
273
+
274
+            if ( $this->settings['shims'] ) {
275
+                $url = $this->get_url( true );
276
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
278
+                wp_enqueue_script( 'font-awesome-shims' );
279
+            }
280
+        }
281
+
282
+        /**
283
+         * Get the url of the Font Awesome files.
284
+         *
285
+         * @param bool $shims If this is a shim file or not.
286
+         * @param bool $local Load locally if allowed.
287
+         *
288
+         * @return string The url to the file.
289
+         */
290
+        public function get_url( $shims = false, $local = true ) {
291
+            $script  = $shims ? 'v4-shims' : 'all';
292
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
293
+            $type    = $this->settings['type'];
294
+            $version = $this->settings['version'];
295
+            $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
296
+            $url     = '';
297
+
298
+            if ( $type == 'KIT' && $kit_url ) {
299
+                if ( $shims ) {
300
+                    // if its a kit then we don't add shims here
301
+                    return '';
302
+                }
303
+                $url .= $kit_url; // CDN
304
+                $url .= "?wpfas=true"; // set our var so our version is not removed
305
+            } else {
306
+                $v = '';
307
+                // Check and load locally.
308
+                if ( $local && $this->has_local() ) {
309
+                    $script .= ".min";
310
+                    $v .= '&ver=' . strip_tags( $this->settings['local_version'] );
311
+                    $url .= $this->get_fonts_url(); // Local fonts url.
312
+                } else {
313
+                    $url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
+                    $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315
+                }
316
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
318
+                $url .= "?wpfas=true" . $v; // set our var so our version is not removed
319
+            }
320
+
321
+            return $url;
322
+        }
323
+
324
+        /**
325
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
326
+         *
327
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
328
+         *
329
+         * @param $url
330
+         * @param $original_url
331
+         * @param $_context
332
+         *
333
+         * @return string The filtered url.
334
+         */
335
+        public function remove_font_awesome( $url, $original_url, $_context ) {
336
+
337
+            if ( $_context == 'display'
338
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
340
+            ) {// it's a font-awesome-url (probably)
341
+
342
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
343
+                    if ( $this->settings['type'] == 'JS' ) {
344
+                        if ( $this->settings['js-pseudo'] ) {
345
+                            $url .= "' data-search-pseudo-elements defer='defer";
346
+                        } else {
347
+                            $url .= "' defer='defer";
348
+                        }
349
+                    }
350
+                } else {
351
+                    $url = ''; // removing the url removes the file
352
+                }
353
+
354
+            }
355
+
356
+            return $url;
357
+        }
358
+
359
+        /**
360
+         * Register the database settings with WordPress.
361
+         */
362
+        public function register_settings() {
363
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
364
+        }
365
+
366
+        /**
367
+         * Add the WordPress settings menu item.
368
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
369
+         */
370
+        public function menu_item() {
371
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373
+                $this,
374
+                'settings_page'
375
+            ) );
376
+        }
377
+
378
+        /**
379
+         * Get the current Font Awesome output settings.
380
+         *
381
+         * @return array The array of settings.
382
+         */
383
+        public function get_settings() {
384
+            $db_settings = get_option( 'wp-font-awesome-settings' );
385
+
386
+            $defaults = array(
387
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
388
+                'version'   => '', // latest
389
+                'enqueue'   => '', // front and backend
390
+                'shims'     => '0', // default OFF now in 2020
391
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
392
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
393
+                'pro'       => '0', // if pro CDN url should be used
394
+                'local'     => '0', // Store fonts locally.
395
+                'local_version' => '', // Local fonts version.
396
+                'kit-url'   => '', // the kit url
397
+            );
398
+
399
+            $settings = wp_parse_args( $db_settings, $defaults );
400
+
401
+            /**
402
+             * Filter the Font Awesome settings.
403
+             *
404
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405
+             */
406
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
407
+        }
408
+
409
+        /**
410
+         * The settings page html output.
411
+         */
412
+        public function settings_page() {
413
+            if ( ! current_user_can( 'manage_options' ) ) {
414
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
415
+            }
416
+
417
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
419
+                $this->get_latest_version( $force_api = true );
420
+            }
421
+
422
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
423
+                ?>
424 424
                 <style>
425 425
                     .wpfas-kit-show {
426 426
                         display: none;
@@ -446,16 +446,16 @@  discard block
 block discarded – undo
446 446
                     <h1><?php echo $this->name; ?></h1>
447 447
                     <form method="post" action="options.php" class="fas-settings-form">
448 448
 						<?php
449
-						settings_fields( 'wp-font-awesome-settings' );
450
-						do_settings_sections( 'wp-font-awesome-settings' );
451
-						$table_class = '';
452
-						if ( $this->settings['type'] ) {
453
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
-						}
455
-						if ( ! empty( $this->settings['pro'] ) ) {
456
-							$table_class .= ' wpfas-has-pro';
457
-						}
458
-						?>
449
+                        settings_fields( 'wp-font-awesome-settings' );
450
+                        do_settings_sections( 'wp-font-awesome-settings' );
451
+                        $table_class = '';
452
+                        if ( $this->settings['type'] ) {
453
+                            $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
454
+                        }
455
+                        if ( ! empty( $this->settings['pro'] ) ) {
456
+                            $table_class .= ' wpfas-has-pro';
457
+                        }
458
+                        ?>
459 459
 						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
460 460
 							<?php if ( $this->has_local() ) { ?>
461 461
                                 <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
                                 <td>
481 481
                                     <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 :(?>"/>
482 482
                                     <span><?php
483
-										echo wp_sprintf(
484
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
-											'</a>'
487
-										);
488
-										?></span>
483
+                                        echo wp_sprintf(
484
+                                            __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
485
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486
+                                            '</a>'
487
+                                        );
488
+                                        ?></span>
489 489
                                 </td>
490 490
                             </tr>
491 491
 
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
527 527
                                     <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')}"/>
528 528
                                     <span><?php
529
-										echo wp_sprintf(
530
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
-											' <i class="fas fa-external-link-alt"></i></a>',
533
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
-											' <i class="fas fa-external-link-alt"></i></a>'
535
-										);
536
-										?></span>
529
+                                        echo wp_sprintf(
530
+                                            __( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
531
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532
+                                            ' <i class="fas fa-external-link-alt"></i></a>',
533
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
534
+                                            ' <i class="fas fa-external-link-alt"></i></a>'
535
+                                        );
536
+                                        ?></span>
537 537
                                 </td>
538 538
                             </tr>
539 539
 
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
                         </table>
588 588
                         <div class="fas-buttons">
589 589
 							<?php
590
-							submit_button();
591
-							?>
590
+                            submit_button();
591
+                            ?>
592 592
                             <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','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
593 593
 
594 594
                         </div>
@@ -597,414 +597,414 @@  discard block
 block discarded – undo
597 597
                     <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
598 598
                 </div>
599 599
 				<?php
600
-			}
601
-		}
602
-
603
-		/**
604
-		 * Check a version number is valid and if so return it or else return an empty string.
605
-		 *
606
-		 * @param $version string The version number to check.
607
-		 *
608
-		 * @since 1.0.6
609
-		 *
610
-		 * @return string Either a valid version number or an empty string.
611
-		 */
612
-		public function validate_version_number( $version ) {
613
-
614
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
-				// valid
616
-			} else {
617
-				$version = '';// not validated
618
-			}
619
-
620
-			return $version;
621
-		}
622
-
623
-
624
-		/**
625
-		 * Get the latest version of Font Awesome.
626
-		 *
627
-		 * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
-		 *
629
-		 * @since 1.0.7
630
-		 * @return mixed|string The latest version number found.
631
-		 */
632
-		public function get_latest_version( $force_api = false ) {
633
-			$latest_version = $this->latest;
634
-
635
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
636
-
637
-			if ( $cache === false || $force_api ) { // its not set
638
-				$api_ver = $this->get_latest_version_from_api();
639
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
-					$latest_version = $api_ver;
641
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
-				}
643
-			} elseif ( $this->validate_version_number( $cache ) ) {
644
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
-					$latest_version = $cache;
646
-				}
647
-			}
648
-
649
-			// Check and auto download fonts locally.
650
-			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 ) ) {
651
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
-					$this->download_package( $latest_version );
653
-				}
654
-			}
655
-
656
-			return $latest_version;
657
-		}
658
-
659
-		/**
660
-		 * Get the latest Font Awesome version from the github API.
661
-		 *
662
-		 * @since 1.0.7
663
-		 * @return string The latest version number or `0` on API fail.
664
-		 */
665
-		public function get_latest_version_from_api() {
666
-			$version  = "0";
667
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
-					$version = $api_response['tag_name'];
672
-				}
673
-			}
674
-
675
-			return $version;
676
-		}
677
-
678
-		/**
679
-		 * Inline CSS for RTL language support.
680
-		 *
681
-		 * @since 1.0.13
682
-		 * @return string Inline CSS.
683
-		 */
684
-		public function rtl_inline_css() {
685
-			$inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
-
687
-			return $inline_css;
688
-		}
689
-
690
-		/**
691
-		 * Show any warnings as an admin notice.
692
-		 *
693
-		 * @return void
694
-		 */
695
-		public function admin_notices() {
696
-			$settings = $this->settings;
697
-
698
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
-					?>
600
+            }
601
+        }
602
+
603
+        /**
604
+         * Check a version number is valid and if so return it or else return an empty string.
605
+         *
606
+         * @param $version string The version number to check.
607
+         *
608
+         * @since 1.0.6
609
+         *
610
+         * @return string Either a valid version number or an empty string.
611
+         */
612
+        public function validate_version_number( $version ) {
613
+
614
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
615
+                // valid
616
+            } else {
617
+                $version = '';// not validated
618
+            }
619
+
620
+            return $version;
621
+        }
622
+
623
+
624
+        /**
625
+         * Get the latest version of Font Awesome.
626
+         *
627
+         * We check for a cached version and if none we will check for a live version via API and then cache it for 48 hours.
628
+         *
629
+         * @since 1.0.7
630
+         * @return mixed|string The latest version number found.
631
+         */
632
+        public function get_latest_version( $force_api = false ) {
633
+            $latest_version = $this->latest;
634
+
635
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
636
+
637
+            if ( $cache === false || $force_api ) { // its not set
638
+                $api_ver = $this->get_latest_version_from_api();
639
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
640
+                    $latest_version = $api_ver;
641
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
642
+                }
643
+            } elseif ( $this->validate_version_number( $cache ) ) {
644
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
645
+                    $latest_version = $cache;
646
+                }
647
+            }
648
+
649
+            // Check and auto download fonts locally.
650
+            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 ) ) {
651
+                if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
+                    $this->download_package( $latest_version );
653
+                }
654
+            }
655
+
656
+            return $latest_version;
657
+        }
658
+
659
+        /**
660
+         * Get the latest Font Awesome version from the github API.
661
+         *
662
+         * @since 1.0.7
663
+         * @return string The latest version number or `0` on API fail.
664
+         */
665
+        public function get_latest_version_from_api() {
666
+            $version  = "0";
667
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
671
+                    $version = $api_response['tag_name'];
672
+                }
673
+            }
674
+
675
+            return $version;
676
+        }
677
+
678
+        /**
679
+         * Inline CSS for RTL language support.
680
+         *
681
+         * @since 1.0.13
682
+         * @return string Inline CSS.
683
+         */
684
+        public function rtl_inline_css() {
685
+            $inline_css = '[dir=rtl] .fa-address,[dir=rtl] .fa-address-card,[dir=rtl] .fa-adjust,[dir=rtl] .fa-alarm-clock,[dir=rtl] .fa-align-left,[dir=rtl] .fa-align-right,[dir=rtl] .fa-analytics,[dir=rtl] .fa-angle-double-left,[dir=rtl] .fa-angle-double-right,[dir=rtl] .fa-angle-left,[dir=rtl] .fa-angle-right,[dir=rtl] .fa-arrow-alt-circle-left,[dir=rtl] .fa-arrow-alt-circle-right,[dir=rtl] .fa-arrow-alt-from-left,[dir=rtl] .fa-arrow-alt-from-right,[dir=rtl] .fa-arrow-alt-left,[dir=rtl] .fa-arrow-alt-right,[dir=rtl] .fa-arrow-alt-square-left,[dir=rtl] .fa-arrow-alt-square-right,[dir=rtl] .fa-arrow-alt-to-left,[dir=rtl] .fa-arrow-alt-to-right,[dir=rtl] .fa-arrow-circle-left,[dir=rtl] .fa-arrow-circle-right,[dir=rtl] .fa-arrow-from-left,[dir=rtl] .fa-arrow-from-right,[dir=rtl] .fa-arrow-left,[dir=rtl] .fa-arrow-right,[dir=rtl] .fa-arrow-square-left,[dir=rtl] .fa-arrow-square-right,[dir=rtl] .fa-arrow-to-left,[dir=rtl] .fa-arrow-to-right,[dir=rtl] .fa-balance-scale-left,[dir=rtl] .fa-balance-scale-right,[dir=rtl] .fa-bed,[dir=rtl] .fa-bed-bunk,[dir=rtl] .fa-bed-empty,[dir=rtl] .fa-border-left,[dir=rtl] .fa-border-right,[dir=rtl] .fa-calendar-check,[dir=rtl] .fa-caret-circle-left,[dir=rtl] .fa-caret-circle-right,[dir=rtl] .fa-caret-left,[dir=rtl] .fa-caret-right,[dir=rtl] .fa-caret-square-left,[dir=rtl] .fa-caret-square-right,[dir=rtl] .fa-cart-arrow-down,[dir=rtl] .fa-cart-plus,[dir=rtl] .fa-chart-area,[dir=rtl] .fa-chart-bar,[dir=rtl] .fa-chart-line,[dir=rtl] .fa-chart-line-down,[dir=rtl] .fa-chart-network,[dir=rtl] .fa-chart-pie,[dir=rtl] .fa-chart-pie-alt,[dir=rtl] .fa-chart-scatter,[dir=rtl] .fa-check-circle,[dir=rtl] .fa-check-square,[dir=rtl] .fa-chevron-circle-left,[dir=rtl] .fa-chevron-circle-right,[dir=rtl] .fa-chevron-double-left,[dir=rtl] .fa-chevron-double-right,[dir=rtl] .fa-chevron-left,[dir=rtl] .fa-chevron-right,[dir=rtl] .fa-chevron-square-left,[dir=rtl] .fa-chevron-square-right,[dir=rtl] .fa-clock,[dir=rtl] .fa-file,[dir=rtl] .fa-file-alt,[dir=rtl] .fa-file-archive,[dir=rtl] .fa-file-audio,[dir=rtl] .fa-file-chart-line,[dir=rtl] .fa-file-chart-pie,[dir=rtl] .fa-file-code,[dir=rtl] .fa-file-excel,[dir=rtl] .fa-file-image,[dir=rtl] .fa-file-pdf,[dir=rtl] .fa-file-powerpoint,[dir=rtl] .fa-file-video,[dir=rtl] .fa-file-word,[dir=rtl] .fa-flag,[dir=rtl] .fa-folder,[dir=rtl] .fa-folder-open,[dir=rtl] .fa-hand-lizard,[dir=rtl] .fa-hand-point-down,[dir=rtl] .fa-hand-point-left,[dir=rtl] .fa-hand-point-right,[dir=rtl] .fa-hand-point-up,[dir=rtl] .fa-hand-scissors,[dir=rtl] .fa-image,[dir=rtl] .fa-long-arrow-alt-left,[dir=rtl] .fa-long-arrow-alt-right,[dir=rtl] .fa-long-arrow-left,[dir=rtl] .fa-long-arrow-right,[dir=rtl] .fa-luggage-cart,[dir=rtl] .fa-moon,[dir=rtl] .fa-pencil,[dir=rtl] .fa-pencil-alt,[dir=rtl] .fa-play-circle,[dir=rtl] .fa-project-diagram,[dir=rtl] .fa-quote-left,[dir=rtl] .fa-quote-right,[dir=rtl] .fa-shopping-cart,[dir=rtl] .fa-thumbs-down,[dir=rtl] .fa-thumbs-up,[dir=rtl] .fa-user-chart{filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);transform:scale(-1,1)}[dir=rtl] .fa-spin{animation-direction:reverse}';
686
+
687
+            return $inline_css;
688
+        }
689
+
690
+        /**
691
+         * Show any warnings as an admin notice.
692
+         *
693
+         * @return void
694
+         */
695
+        public function admin_notices() {
696
+            $settings = $this->settings;
697
+
698
+            if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
+                if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
700
+                    ?>
701 701
                     <div class="notice  notice-error is-dismissible">
702 702
                         <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
703 703
                     </div>
704 704
 					<?php
705
-				}
706
-			} else {
707
-				if ( ! empty( $settings ) ) {
708
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
-						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
-						?>
705
+                }
706
+            } else {
707
+                if ( ! empty( $settings ) ) {
708
+                    if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
709
+                        $link = admin_url('options-general.php?page=wp-font-awesome-settings');
710
+                        ?>
711 711
                         <div class="notice  notice-error is-dismissible">
712 712
                             <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
713 713
                         </div>
714 714
 						<?php
715
-					}
716
-				}
717
-			}
718
-		}
719
-
720
-		/**
721
-		 * Handle fontawesome add settings to download fontawesome to store locally.
722
-		 *
723
-		 * @since 1.1.1
724
-		 *
725
-		 * @param string $option The option name.
726
-		 * @param mixed  $value  The option value.
727
-		 */
728
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
729
-			// Do nothing if WordPress is being installed.
730
-			if ( wp_installing() ) {
731
-				return;
732
-			}
733
-
734
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
-
737
-				if ( ! empty( $version ) ) {
738
-					$response = $this->download_package( $version, $value );
739
-
740
-					if ( is_wp_error( $response ) ) {
741
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
-					}
743
-				}
744
-			}
745
-		}
746
-
747
-		/**
748
-		 * Handle fontawesome update settings to download fontawesome to store locally.
749
-		 *
750
-		 * @since 1.1.0
751
-		 *
752
-		 * @param mixed $old_value The old option value.
753
-		 * @param mixed $value     The new option value.
754
-		 */
755
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
-			// Do nothing if WordPress is being installed.
757
-			if ( wp_installing() ) {
758
-				return;
759
-			}
760
-
761
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
-				// Old values
763
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
-
766
-				// New values
767
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
-
769
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
-					$response = $this->download_package( $new_version, $new_value );
771
-
772
-					if ( is_wp_error( $response ) ) {
773
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
-					}
775
-				}
776
-			}
777
-		}
778
-
779
-		/**
780
-		 * Get the fonts directory local path.
781
-		 *
782
-		 * @since 1.1.0
783
-		 *
784
-		 * @param string Fonts directory local path.
785
-		 */
786
-		public function get_fonts_dir() {
787
-			$upload_dir = wp_upload_dir( null, false );
788
-
789
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
-		}
791
-
792
-		/**
793
-		 * Get the fonts directory local url.
794
-		 *
795
-		 * @since 1.1.0
796
-		 *
797
-		 * @param string Fonts directory local url.
798
-		 */
799
-		public function get_fonts_url() {
800
-			$upload_dir = wp_upload_dir( null, false );
801
-
802
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
-		}
804
-
805
-		/**
806
-		 * Check whether load locally active.
807
-		 *
808
-		 * @since 1.1.0
809
-		 *
810
-		 * @return bool True if active else false.
811
-		 */
812
-		public function has_local() {
813
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
-				return true;
815
-			}
816
-
817
-			return false;
818
-		}
819
-
820
-		/**
821
-		 * Get the WP Filesystem access.
822
-		 *
823
-		 * @since 1.1.0
824
-		 *
825
-		 * @return object The WP Filesystem.
826
-		 */
827
-		public function get_wp_filesystem() {
828
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
829
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
-			}
831
-
832
-			$access_type = get_filesystem_method();
833
-
834
-			if ( $access_type === 'direct' ) {
835
-				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
-
838
-				/* Initialize the API */
839
-				if ( ! WP_Filesystem( $creds ) ) {
840
-					/* Any problems and we exit */
841
-					return false;
842
-				}
843
-
844
-				global $wp_filesystem;
845
-
846
-				return $wp_filesystem;
847
-				/* Do our file manipulations below */
848
-			} else if ( defined( 'FTP_USER' ) ) {
849
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
-
851
-				/* Initialize the API */
852
-				if ( ! WP_Filesystem( $creds ) ) {
853
-					/* Any problems and we exit */
854
-					return false;
855
-				}
856
-
857
-				global $wp_filesystem;
858
-
859
-				return $wp_filesystem;
860
-			} else {
861
-				/* Don't have direct write access. Prompt user with our notice */
862
-				return false;
863
-			}
864
-		}
865
-
866
-		/**
867
-		 * Download the fontawesome package file.
868
-		 *
869
-		 * @since 1.1.0
870
-		 *
871
-		 * @param mixed $version The font awesome.
872
-		 * @param array $option Fontawesome settings.
873
-		 * @return WP_ERROR|bool Error on fail and true on success.
874
-		 */
875
-		public function download_package( $version, $option = array() ) {
876
-			$filename = 'fontawesome-free-' . $version . '-web';
877
-			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
-
879
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
880
-				require_once ABSPATH . 'wp-admin/includes/file.php';
881
-			}
882
-
883
-			$download_file = download_url( esc_url_raw( $url ) );
884
-
885
-			if ( is_wp_error( $download_file ) ) {
886
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
-			} else if ( empty( $download_file ) ) {
888
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
-			}
890
-
891
-			$response = $this->extract_package( $download_file, $filename, true );
892
-
893
-			// Update local version.
894
-			if ( is_wp_error( $response ) ) {
895
-				return $response;
896
-			} else if ( $response ) {
897
-				if ( empty( $option ) ) {
898
-					$option = get_option( 'wp-font-awesome-settings' );
899
-				}
900
-
901
-				$option['local_version'] = $version;
902
-
903
-				// Remove action to prevent looping.
904
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
-
906
-				update_option( 'wp-font-awesome-settings', $option );
907
-
908
-				return true;
909
-			}
910
-
911
-			return false;
912
-		}
913
-
914
-		/**
915
-		 * Extract the fontawesome package file.
916
-		 *
917
-		 * @since 1.1.0
918
-		 *
919
-		 * @param string $package The package file path.
920
-		 * @param string $dirname Package file name.
921
-		 * @param bool   $delete_package Delete temp file or not.
922
-		 * @return WP_Error|bool True on success WP_Error on fail.
923
-		 */
924
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
-			global $wp_filesystem;
926
-
927
-			$wp_filesystem = $this->get_wp_filesystem();
928
-
929
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
-			} else if ( empty( $wp_filesystem ) ) {
932
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
-			}
934
-
935
-			$fonts_dir = $this->get_fonts_dir();
936
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
-
938
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
940
-			}
941
-
942
-			// Unzip package to working directory.
943
-			$result = unzip_file( $package, $fonts_tmp_dir );
944
-
945
-			if ( is_wp_error( $result ) ) {
946
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
947
-
948
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
949
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
-				}
951
-
952
-				return $result;
953
-			}
954
-
955
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
-				$wp_filesystem->delete( $fonts_dir, true );
957
-			}
958
-
959
-			$extract_dir = $fonts_tmp_dir;
960
-
961
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
-				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
-			}
964
-
965
-			try {
966
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
-			} catch ( Exception $e ) {
968
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
-			}
970
-
971
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
973
-			}
974
-
975
-			// Once extracted, delete the package if required.
976
-			if ( $delete_package ) {
977
-				unlink( $package );
978
-			}
979
-
980
-			return $return;
981
-		}
982
-
983
-		/**
984
-		 * Output the version in the header.
985
-		 */
986
-		public function add_generator() {
987
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
-
990
-			// Find source plugin/theme.
991
-			$source = array();
992
-			if ( strpos( $file, $plugins_dir ) !== false ) {
993
-				$source = explode( "/", plugin_basename( $file ) );
994
-			} else if ( function_exists( 'get_theme_root' ) ) {
995
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
-
997
-				if ( strpos( $file, $themes_dir ) !== false ) {
998
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
-				}
1000
-			}
1001
-
1002
-			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
-		}
1004
-	}
1005
-
1006
-	/**
1007
-	 * Run the class if found.
1008
-	 */
1009
-	WP_Font_Awesome_Settings::instance();
715
+                    }
716
+                }
717
+            }
718
+        }
719
+
720
+        /**
721
+         * Handle fontawesome add settings to download fontawesome to store locally.
722
+         *
723
+         * @since 1.1.1
724
+         *
725
+         * @param string $option The option name.
726
+         * @param mixed  $value  The option value.
727
+         */
728
+        public function add_option_wp_font_awesome_settings( $option, $value ) {
729
+            // Do nothing if WordPress is being installed.
730
+            if ( wp_installing() ) {
731
+                return;
732
+            }
733
+
734
+            if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
+                $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
736
+
737
+                if ( ! empty( $version ) ) {
738
+                    $response = $this->download_package( $version, $value );
739
+
740
+                    if ( is_wp_error( $response ) ) {
741
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
742
+                    }
743
+                }
744
+            }
745
+        }
746
+
747
+        /**
748
+         * Handle fontawesome update settings to download fontawesome to store locally.
749
+         *
750
+         * @since 1.1.0
751
+         *
752
+         * @param mixed $old_value The old option value.
753
+         * @param mixed $value     The new option value.
754
+         */
755
+        public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
756
+            // Do nothing if WordPress is being installed.
757
+            if ( wp_installing() ) {
758
+                return;
759
+            }
760
+
761
+            if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
762
+                // Old values
763
+                $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
+                $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
765
+
766
+                // New values
767
+                $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768
+
769
+                if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
+                    $response = $this->download_package( $new_version, $new_value );
771
+
772
+                    if ( is_wp_error( $response ) ) {
773
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
774
+                    }
775
+                }
776
+            }
777
+        }
778
+
779
+        /**
780
+         * Get the fonts directory local path.
781
+         *
782
+         * @since 1.1.0
783
+         *
784
+         * @param string Fonts directory local path.
785
+         */
786
+        public function get_fonts_dir() {
787
+            $upload_dir = wp_upload_dir( null, false );
788
+
789
+            return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790
+        }
791
+
792
+        /**
793
+         * Get the fonts directory local url.
794
+         *
795
+         * @since 1.1.0
796
+         *
797
+         * @param string Fonts directory local url.
798
+         */
799
+        public function get_fonts_url() {
800
+            $upload_dir = wp_upload_dir( null, false );
801
+
802
+            return $upload_dir['baseurl'] .  '/ayefonts/fa/';
803
+        }
804
+
805
+        /**
806
+         * Check whether load locally active.
807
+         *
808
+         * @since 1.1.0
809
+         *
810
+         * @return bool True if active else false.
811
+         */
812
+        public function has_local() {
813
+            if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
814
+                return true;
815
+            }
816
+
817
+            return false;
818
+        }
819
+
820
+        /**
821
+         * Get the WP Filesystem access.
822
+         *
823
+         * @since 1.1.0
824
+         *
825
+         * @return object The WP Filesystem.
826
+         */
827
+        public function get_wp_filesystem() {
828
+            if ( ! function_exists( 'get_filesystem_method' ) ) {
829
+                require_once( ABSPATH . "/wp-admin/includes/file.php" );
830
+            }
831
+
832
+            $access_type = get_filesystem_method();
833
+
834
+            if ( $access_type === 'direct' ) {
835
+                /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
837
+
838
+                /* Initialize the API */
839
+                if ( ! WP_Filesystem( $creds ) ) {
840
+                    /* Any problems and we exit */
841
+                    return false;
842
+                }
843
+
844
+                global $wp_filesystem;
845
+
846
+                return $wp_filesystem;
847
+                /* Do our file manipulations below */
848
+            } else if ( defined( 'FTP_USER' ) ) {
849
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
850
+
851
+                /* Initialize the API */
852
+                if ( ! WP_Filesystem( $creds ) ) {
853
+                    /* Any problems and we exit */
854
+                    return false;
855
+                }
856
+
857
+                global $wp_filesystem;
858
+
859
+                return $wp_filesystem;
860
+            } else {
861
+                /* Don't have direct write access. Prompt user with our notice */
862
+                return false;
863
+            }
864
+        }
865
+
866
+        /**
867
+         * Download the fontawesome package file.
868
+         *
869
+         * @since 1.1.0
870
+         *
871
+         * @param mixed $version The font awesome.
872
+         * @param array $option Fontawesome settings.
873
+         * @return WP_ERROR|bool Error on fail and true on success.
874
+         */
875
+        public function download_package( $version, $option = array() ) {
876
+            $filename = 'fontawesome-free-' . $version . '-web';
877
+            $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878
+
879
+            if ( ! function_exists( 'wp_handle_upload' ) ) {
880
+                require_once ABSPATH . 'wp-admin/includes/file.php';
881
+            }
882
+
883
+            $download_file = download_url( esc_url_raw( $url ) );
884
+
885
+            if ( is_wp_error( $download_file ) ) {
886
+                return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
+            } else if ( empty( $download_file ) ) {
888
+                return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
889
+            }
890
+
891
+            $response = $this->extract_package( $download_file, $filename, true );
892
+
893
+            // Update local version.
894
+            if ( is_wp_error( $response ) ) {
895
+                return $response;
896
+            } else if ( $response ) {
897
+                if ( empty( $option ) ) {
898
+                    $option = get_option( 'wp-font-awesome-settings' );
899
+                }
900
+
901
+                $option['local_version'] = $version;
902
+
903
+                // Remove action to prevent looping.
904
+                remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
905
+
906
+                update_option( 'wp-font-awesome-settings', $option );
907
+
908
+                return true;
909
+            }
910
+
911
+            return false;
912
+        }
913
+
914
+        /**
915
+         * Extract the fontawesome package file.
916
+         *
917
+         * @since 1.1.0
918
+         *
919
+         * @param string $package The package file path.
920
+         * @param string $dirname Package file name.
921
+         * @param bool   $delete_package Delete temp file or not.
922
+         * @return WP_Error|bool True on success WP_Error on fail.
923
+         */
924
+        public function extract_package( $package, $dirname = '', $delete_package = false ) {
925
+            global $wp_filesystem;
926
+
927
+            $wp_filesystem = $this->get_wp_filesystem();
928
+
929
+            if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
+                return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
+            } else if ( empty( $wp_filesystem ) ) {
932
+                return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
933
+            }
934
+
935
+            $fonts_dir = $this->get_fonts_dir();
936
+            $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937
+
938
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
940
+            }
941
+
942
+            // Unzip package to working directory.
943
+            $result = unzip_file( $package, $fonts_tmp_dir );
944
+
945
+            if ( is_wp_error( $result ) ) {
946
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
947
+
948
+                if ( 'incompatible_archive' === $result->get_error_code() ) {
949
+                    return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
950
+                }
951
+
952
+                return $result;
953
+            }
954
+
955
+            if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
+                $wp_filesystem->delete( $fonts_dir, true );
957
+            }
958
+
959
+            $extract_dir = $fonts_tmp_dir;
960
+
961
+            if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
962
+                $extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963
+            }
964
+
965
+            try {
966
+                $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
+            } catch ( Exception $e ) {
968
+                $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
969
+            }
970
+
971
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
973
+            }
974
+
975
+            // Once extracted, delete the package if required.
976
+            if ( $delete_package ) {
977
+                unlink( $package );
978
+            }
979
+
980
+            return $return;
981
+        }
982
+
983
+        /**
984
+         * Output the version in the header.
985
+         */
986
+        public function add_generator() {
987
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
989
+
990
+            // Find source plugin/theme.
991
+            $source = array();
992
+            if ( strpos( $file, $plugins_dir ) !== false ) {
993
+                $source = explode( "/", plugin_basename( $file ) );
994
+            } else if ( function_exists( 'get_theme_root' ) ) {
995
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
996
+
997
+                if ( strpos( $file, $themes_dir ) !== false ) {
998
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
999
+                }
1000
+            }
1001
+
1002
+            echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1003
+        }
1004
+    }
1005
+
1006
+    /**
1007
+     * Run the class if found.
1008
+     */
1009
+    WP_Font_Awesome_Settings::instance();
1010 1010
 }
Please login to merge, or discard this patch.
Spacing   +242 added lines, -242 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.
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
 		 * @return WP_Font_Awesome_Settings - Main instance.
83 83
 		 */
84 84
 		public static function instance() {
85
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
85
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
86 86
 				self::$instance = new WP_Font_Awesome_Settings;
87 87
 
88
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
88
+				add_action('init', array(self::$instance, 'init')); // set settings
89 89
 
90
-				if ( is_admin() ) {
91
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
92
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
93
-					add_action( 'admin_init', array( self::$instance, 'constants' ) );
94
-					add_action( 'admin_notices', array( self::$instance, 'admin_notices' ) );
90
+				if (is_admin()) {
91
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
92
+					add_action('admin_init', array(self::$instance, 'register_settings'));
93
+					add_action('admin_init', array(self::$instance, 'constants'));
94
+					add_action('admin_notices', array(self::$instance, 'admin_notices'));
95 95
 				}
96 96
 
97
-				do_action( 'wp_font_awesome_settings_loaded' );
97
+				do_action('wp_font_awesome_settings_loaded');
98 98
 			}
99 99
 
100 100
 			return self::$instance;
@@ -105,26 +105,26 @@  discard block
 block discarded – undo
105 105
          *
106 106
 		 * @return void
107 107
 		 */
108
-		public function constants(){
108
+		public function constants() {
109 109
 
110 110
 			// register iconpicker constant
111
-			if ( ! defined( 'FAS_ICONPICKER_JS_URL' ) ) {
111
+			if (!defined('FAS_ICONPICKER_JS_URL')) {
112 112
 				$url = $this->get_path_url();
113 113
 				$version = $this->settings['version'];
114 114
 
115
-				if( !$version || version_compare($version,'5.999','>')){
115
+				if (!$version || version_compare($version, '5.999', '>')) {
116 116
 					$url .= 'assets/js/fa-iconpicker-v6.min.js';
117
-				}else{
117
+				} else {
118 118
 					$url .= 'assets/js/fa-iconpicker-v5.min.js';
119 119
 				}
120 120
 
121
-				define( 'FAS_ICONPICKER_JS_URL', $url );
121
+				define('FAS_ICONPICKER_JS_URL', $url);
122 122
 
123 123
 			}
124 124
 
125 125
             // Set a constant if pro enbaled
126
-			if ( ! defined( 'FAS_PRO' ) && $this->settings['pro'] ) {
127
-				define( 'FAS_PRO', true );
126
+			if (!defined('FAS_PRO') && $this->settings['pro']) {
127
+				define('FAS_PRO', true);
128 128
 			}
129 129
 		}
130 130
 
@@ -134,19 +134,19 @@  discard block
 block discarded – undo
134 134
 		 * @return string
135 135
 		 */
136 136
 		public function get_path_url() {
137
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
138
-			$content_url = untrailingslashit( WP_CONTENT_URL );
137
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
138
+			$content_url = untrailingslashit(WP_CONTENT_URL);
139 139
 
140 140
 			// Replace http:// to https://.
141
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
142
-				$content_url = str_replace( 'http://', 'https://', $content_url );
141
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
142
+				$content_url = str_replace('http://', 'https://', $content_url);
143 143
 			}
144 144
 
145 145
 			// Check if we are inside a plugin
146
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
147
-			$url = str_replace( $content_dir, $content_url, $file_dir );
146
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
147
+			$url = str_replace($content_dir, $content_url, $file_dir);
148 148
 
149
-			return trailingslashit( $url );
149
+			return trailingslashit($url);
150 150
 		}
151 151
 
152 152
 		/**
@@ -156,45 +156,45 @@  discard block
 block discarded – undo
156 156
 		 */
157 157
 		public function init() {
158 158
 			// Download fontawesome locally.
159
-			add_action( 'add_option_wp-font-awesome-settings', array( $this, 'add_option_wp_font_awesome_settings' ), 10, 2 );
160
-			add_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
159
+			add_action('add_option_wp-font-awesome-settings', array($this, 'add_option_wp_font_awesome_settings'), 10, 2);
160
+			add_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2);
161 161
 
162 162
 			$this->settings = $this->get_settings();
163 163
 
164 164
 			// Check if the official plugin is active and use that instead if so.
165
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
166
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
167
-					add_action( 'admin_head', array( $this, 'add_generator' ), 99 );
165
+			if (!defined('FONTAWESOME_PLUGIN_FILE')) {
166
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
167
+					add_action('admin_head', array($this, 'add_generator'), 99);
168 168
 				}
169 169
 
170
-				if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
171
-					add_action( 'wp_head', array( $this, 'add_generator' ), 99 );
170
+				if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
171
+					add_action('wp_head', array($this, 'add_generator'), 99);
172 172
 				}
173 173
 
174
-				if ( $this->settings['type'] == 'CSS' ) {
175
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
176
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
174
+				if ($this->settings['type'] == 'CSS') {
175
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
176
+						add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000);
177 177
 						//add_action( 'wp_footer', array( $this, 'enqueue_style' ), 5000 ); // not sure why this was added, seems to break frontend
178 178
 					}
179 179
 
180
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
181
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
182
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_styles' ), 10, 2 );
180
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
181
+						add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
182
+						add_filter('block_editor_settings_all', array($this, 'enqueue_editor_styles'), 10, 2);
183 183
 					}
184 184
 				} else {
185
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
186
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
185
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') {
186
+						add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
187 187
 					}
188 188
 
189
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
190
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
191
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
189
+					if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') {
190
+						add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
191
+						add_filter('block_editor_settings_all', array($this, 'enqueue_editor_scripts'), 10, 2);
192 192
 					}
193 193
 				}
194 194
 
195 195
 				// remove font awesome if set to do so
196
-				if ( $this->settings['dequeue'] == '1' ) {
197
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
196
+				if ($this->settings['dequeue'] == '1') {
197
+					add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
198 198
 				}
199 199
 			}
200 200
 
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
 		 *
209 209
 		 * @return array
210 210
 		 */
211
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
211
+		public function enqueue_editor_styles($editor_settings, $block_editor_context) {
212 212
 
213
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
213
+			if (!empty($editor_settings['__unstableResolvedAssets']['styles'])) {
214 214
 				$url = $this->get_url();
215 215
 				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
216 216
 			}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		 *
227 227
 		 * @return array
228 228
 		 */
229
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ){
229
+		public function enqueue_editor_scripts($editor_settings, $block_editor_context) {
230 230
 
231 231
 			$url = $this->get_url();
232 232
 			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js'></script>";
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
 		public function enqueue_style() {
241 241
 			// build url
242 242
 			$url = $this->get_url();
243
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
243
+			$version = !empty($this->settings['local']) && empty($this->settings['pro']) ? strip_tags($this->settings['local_version']) : null;
244 244
 
245
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
246
-			wp_register_style( 'font-awesome', $url, array(), $version );
247
-			wp_enqueue_style( 'font-awesome' );
245
+			wp_deregister_style('font-awesome'); // deregister in case its already there
246
+			wp_register_style('font-awesome', $url, array(), $version);
247
+			wp_enqueue_style('font-awesome');
248 248
 
249 249
 			// RTL language support CSS.
250
-			if ( is_rtl() ) {
251
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
250
+			if (is_rtl()) {
251
+				wp_add_inline_style('font-awesome', $this->rtl_inline_css());
252 252
 			}
253 253
 
254
-			if ( $this->settings['shims'] ) {
255
-				$url = $this->get_url( true );
256
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
257
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
258
-				wp_enqueue_style( 'font-awesome-shims' );
254
+			if ($this->settings['shims']) {
255
+				$url = $this->get_url(true);
256
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
257
+				wp_register_style('font-awesome-shims', $url, array(), $version);
258
+				wp_enqueue_style('font-awesome-shims');
259 259
 			}
260 260
 		}
261 261
 
@@ -267,15 +267,15 @@  discard block
 block discarded – undo
267 267
 			$url = $this->get_url();
268 268
 
269 269
 			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
270
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
271
-			wp_register_script( 'font-awesome', $url, array(), null );
272
-			wp_enqueue_script( 'font-awesome' );
270
+			call_user_func($deregister_function, 'font-awesome'); // deregister in case its already there
271
+			wp_register_script('font-awesome', $url, array(), null);
272
+			wp_enqueue_script('font-awesome');
273 273
 
274
-			if ( $this->settings['shims'] ) {
275
-				$url = $this->get_url( true );
276
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
277
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
278
-				wp_enqueue_script( 'font-awesome-shims' );
274
+			if ($this->settings['shims']) {
275
+				$url = $this->get_url(true);
276
+				call_user_func($deregister_function, 'font-awesome-shims'); // deregister in case its already there
277
+				wp_register_script('font-awesome-shims', $url, array(), null);
278
+				wp_enqueue_script('font-awesome-shims');
279 279
 			}
280 280
 		}
281 281
 
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @return string The url to the file.
289 289
 		 */
290
-		public function get_url( $shims = false, $local = true ) {
290
+		public function get_url($shims = false, $local = true) {
291 291
 			$script  = $shims ? 'v4-shims' : 'all';
292 292
 			$sub     = $this->settings['pro'] ? 'pro' : 'use';
293 293
 			$type    = $this->settings['type'];
294 294
 			$version = $this->settings['version'];
295
-			$kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : '';
295
+			$kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : '';
296 296
 			$url     = '';
297 297
 
298
-			if ( $type == 'KIT' && $kit_url ) {
299
-				if ( $shims ) {
298
+			if ($type == 'KIT' && $kit_url) {
299
+				if ($shims) {
300 300
 					// if its a kit then we don't add shims here
301 301
 					return '';
302 302
 				}
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 			} else {
306 306
 				$v = '';
307 307
 				// Check and load locally.
308
-				if ( $local && $this->has_local() ) {
308
+				if ($local && $this->has_local()) {
309 309
 					$script .= ".min";
310
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
310
+					$v .= '&ver=' . strip_tags($this->settings['local_version']);
311 311
 					$url .= $this->get_fonts_url(); // Local fonts url.
312 312
 				} else {
313 313
 					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
314
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
314
+					$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
315 315
 				}
316 316
 				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
317 317
 				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
@@ -332,16 +332,16 @@  discard block
 block discarded – undo
332 332
 		 *
333 333
 		 * @return string The filtered url.
334 334
 		 */
335
-		public function remove_font_awesome( $url, $original_url, $_context ) {
335
+		public function remove_font_awesome($url, $original_url, $_context) {
336 336
 
337
-			if ( $_context == 'display'
338
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
339
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
337
+			if ($_context == 'display'
338
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
339
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
340 340
 			) {// it's a font-awesome-url (probably)
341 341
 
342
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
343
-					if ( $this->settings['type'] == 'JS' ) {
344
-						if ( $this->settings['js-pseudo'] ) {
342
+				if (strstr($url, "wpfas=true") !== false) {
343
+					if ($this->settings['type'] == 'JS') {
344
+						if ($this->settings['js-pseudo']) {
345 345
 							$url .= "' data-search-pseudo-elements defer='defer";
346 346
 						} else {
347 347
 							$url .= "' defer='defer";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 		 * Register the database settings with WordPress.
361 361
 		 */
362 362
 		public function register_settings() {
363
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
363
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
364 364
 		}
365 365
 
366 366
 		/**
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 		 */
370 370
 		public function menu_item() {
371 371
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
372
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
372
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
373 373
 				$this,
374 374
 				'settings_page'
375
-			) );
375
+			));
376 376
 		}
377 377
 
378 378
 		/**
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		 * @return array The array of settings.
382 382
 		 */
383 383
 		public function get_settings() {
384
-			$db_settings = get_option( 'wp-font-awesome-settings' );
384
+			$db_settings = get_option('wp-font-awesome-settings');
385 385
 
386 386
 			$defaults = array(
387 387
 				'type'      => 'CSS', // type to use, CSS or JS or KIT
@@ -396,30 +396,30 @@  discard block
 block discarded – undo
396 396
 				'kit-url'   => '', // the kit url
397 397
 			);
398 398
 
399
-			$settings = wp_parse_args( $db_settings, $defaults );
399
+			$settings = wp_parse_args($db_settings, $defaults);
400 400
 
401 401
 			/**
402 402
 			 * Filter the Font Awesome settings.
403 403
 			 *
404 404
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
405 405
 			 */
406
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
406
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
407 407
 		}
408 408
 
409 409
 		/**
410 410
 		 * The settings page html output.
411 411
 		 */
412 412
 		public function settings_page() {
413
-			if ( ! current_user_can( 'manage_options' ) ) {
414
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
413
+			if (!current_user_can('manage_options')) {
414
+				wp_die(__('You do not have sufficient permissions to access this page.', 'ayecode-connect'));
415 415
 			}
416 416
 
417 417
 			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
418
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
419
-				$this->get_latest_version( $force_api = true );
418
+			if (isset($_REQUEST['force-version-check'])) {
419
+				$this->get_latest_version($force_api = true);
420 420
 			}
421 421
 
422
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
422
+			if (!defined('FONTAWESOME_PLUGIN_FILE')) {
423 423
 				?>
424 424
                 <style>
425 425
                     .wpfas-kit-show {
@@ -446,42 +446,42 @@  discard block
 block discarded – undo
446 446
                     <h1><?php echo $this->name; ?></h1>
447 447
                     <form method="post" action="options.php" class="fas-settings-form">
448 448
 						<?php
449
-						settings_fields( 'wp-font-awesome-settings' );
450
-						do_settings_sections( 'wp-font-awesome-settings' );
449
+						settings_fields('wp-font-awesome-settings');
450
+						do_settings_sections('wp-font-awesome-settings');
451 451
 						$table_class = '';
452
-						if ( $this->settings['type'] ) {
453
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
452
+						if ($this->settings['type']) {
453
+							$table_class .= 'wpfas-' . sanitize_html_class(strtolower($this->settings['type'])) . '-set';
454 454
 						}
455
-						if ( ! empty( $this->settings['pro'] ) ) {
455
+						if (!empty($this->settings['pro'])) {
456 456
 							$table_class .= ' wpfas-has-pro';
457 457
 						}
458 458
 						?>
459
-						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
460
-							<?php if ( $this->has_local() ) { ?>
461
-                                <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
459
+						<?php if ($this->settings['type'] != 'KIT' && !empty($this->settings['local']) && empty($this->settings['pro'])) { ?>
460
+							<?php if ($this->has_local()) { ?>
461
+                                <div class="notice notice-info"><p><strong><?php _e('Font Awesome fonts are loading locally.', 'ayecode-connect'); ?></strong></p></div>
462 462
 							<?php } else { ?>
463
-                                <div class="notice notice-error"><p><strong><?php _e( 'Font Awesome fonts are not loading locally!', 'ayecode-connect' ); ?></strong></p></div>
463
+                                <div class="notice notice-error"><p><strong><?php _e('Font Awesome fonts are not loading locally!', 'ayecode-connect'); ?></strong></p></div>
464 464
 							<?php } ?>
465 465
 						<?php } ?>
466
-                        <table class="form-table wpfas-table-settings <?php echo esc_attr( $table_class ); ?>">
466
+                        <table class="form-table wpfas-table-settings <?php echo esc_attr($table_class); ?>">
467 467
                             <tr valign="top">
468
-                                <th scope="row"><label for="wpfas-type"><?php _e( 'Type', 'ayecode-connect' ); ?></label></th>
468
+                                <th scope="row"><label for="wpfas-type"><?php _e('Type', 'ayecode-connect'); ?></label></th>
469 469
                                 <td>
470 470
                                     <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');}">
471
-                                        <option value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'ayecode-connect' ); ?></option>
472
-                                        <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
473
-                                        <option value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'ayecode-connect' ); ?></option>
471
+                                        <option value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'ayecode-connect'); ?></option>
472
+                                        <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
473
+                                        <option value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'ayecode-connect'); ?></option>
474 474
                                     </select>
475 475
                                 </td>
476 476
                             </tr>
477 477
 
478 478
                             <tr valign="top" class="wpfas-kit-show">
479
-                                <th scope="row"><label for="wpfas-kit-url"><?php _e( 'Kit URL', 'ayecode-connect' ); ?></label></th>
479
+                                <th scope="row"><label for="wpfas-kit-url"><?php _e('Kit URL', 'ayecode-connect'); ?></label></th>
480 480
                                 <td>
481
-                                    <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 :(?>"/>
481
+                                    <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 :(?>"/>
482 482
                                     <span><?php
483 483
 										echo wp_sprintf(
484
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
484
+											__('Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect'),
485 485
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>',
486 486
 											'</a>'
487 487
 										);
@@ -490,44 +490,44 @@  discard block
 block discarded – undo
490 490
                             </tr>
491 491
 
492 492
                             <tr valign="top" class="wpfas-kit-hide">
493
-                                <th scope="row"><label for="wpfas-version"><?php _e( 'Version', 'ayecode-connect' ); ?></label></th>
493
+                                <th scope="row"><label for="wpfas-version"><?php _e('Version', 'ayecode-connect'); ?></label></th>
494 494
                                 <td>
495 495
                                     <select name="wp-font-awesome-settings[version]" id="wpfas-version">
496
-                                        <option value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo wp_sprintf( __( 'Latest - %s (default)', 'ayecode-connect' ), $this->get_latest_version() ); ?></option>
497
-                                        <option value="6.1.0" <?php selected( $this->settings['version'], '6.1.0' ); ?>>6.1.0</option>
498
-                                        <option value="6.0.0" <?php selected( $this->settings['version'], '6.0.0' ); ?>>6.0.0</option>
499
-                                        <option value="5.15.4" <?php selected( $this->settings['version'], '5.15.4' ); ?>>5.15.4</option>
500
-                                        <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>>5.6.0</option>
501
-                                        <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>5.5.0</option>
502
-                                        <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>5.4.0</option>
503
-                                        <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>5.3.0</option>
504
-                                        <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>5.2.0</option>
505
-                                        <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>5.1.0</option>
506
-                                        <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>4.7.1 (CSS only)</option>
496
+                                        <option value="" <?php selected($this->settings['version'], ''); ?>><?php echo wp_sprintf(__('Latest - %s (default)', 'ayecode-connect'), $this->get_latest_version()); ?></option>
497
+                                        <option value="6.1.0" <?php selected($this->settings['version'], '6.1.0'); ?>>6.1.0</option>
498
+                                        <option value="6.0.0" <?php selected($this->settings['version'], '6.0.0'); ?>>6.0.0</option>
499
+                                        <option value="5.15.4" <?php selected($this->settings['version'], '5.15.4'); ?>>5.15.4</option>
500
+                                        <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>>5.6.0</option>
501
+                                        <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>5.5.0</option>
502
+                                        <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>5.4.0</option>
503
+                                        <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>5.3.0</option>
504
+                                        <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>5.2.0</option>
505
+                                        <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>5.1.0</option>
506
+                                        <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>4.7.1 (CSS only)</option>
507 507
                                     </select>
508 508
                                 </td>
509 509
                             </tr>
510 510
 
511 511
                             <tr valign="top">
512
-                                <th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue', 'ayecode-connect' ); ?></label></th>
512
+                                <th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue', 'ayecode-connect'); ?></label></th>
513 513
                                 <td>
514 514
                                     <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
515
-                                        <option value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'ayecode-connect' ); ?></option>
516
-                                        <option value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'ayecode-connect' ); ?></option>
517
-                                        <option value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'ayecode-connect' ); ?></option>
515
+                                        <option value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'ayecode-connect'); ?></option>
516
+                                        <option value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'ayecode-connect'); ?></option>
517
+                                        <option value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'ayecode-connect'); ?></option>
518 518
                                     </select>
519 519
                                 </td>
520 520
                             </tr>
521 521
 
522 522
                             <tr valign="top" class="wpfas-kit-hide">
523 523
                                 <th scope="row"><label
524
-                                            for="wpfas-pro"><?php _e( 'Enable pro', 'ayecode-connect' ); ?></label></th>
524
+                                            for="wpfas-pro"><?php _e('Enable pro', 'ayecode-connect'); ?></label></th>
525 525
                                 <td>
526 526
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
527
-                                    <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')}"/>
527
+                                    <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')}"/>
528 528
                                     <span><?php
529 529
 										echo wp_sprintf(
530
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
530
+											__('Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect'),
531 531
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
532 532
 											' <i class="fas fa-external-link-alt"></i></a>',
533 533
 											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
@@ -538,49 +538,49 @@  discard block
 block discarded – undo
538 538
                             </tr>
539 539
 
540 540
                             <tr valign="top" class="wpfas-kit-hide wpfas-hide-pro">
541
-                                <th scope="row"><label for="wpfas-local"><?php _e( 'Load Fonts Locally', 'ayecode-connect' ); ?></label></th>
541
+                                <th scope="row"><label for="wpfas-local"><?php _e('Load Fonts Locally', 'ayecode-connect'); ?></label></th>
542 542
                                 <td>
543 543
                                     <input type="hidden" name="wp-font-awesome-settings[local]" value="0"/>
544
-                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr( $this->settings['local_version'] ); ?>"/>
545
-                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked( $this->settings['local'], '1' ); ?> id="wpfas-local"/>
546
-                                    <span><?php _e( '(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect' ); ?></span>
544
+                                    <input type="hidden" name="wp-font-awesome-settings[local_version]" value="<?php echo esc_attr($this->settings['local_version']); ?>"/>
545
+                                    <input type="checkbox" name="wp-font-awesome-settings[local]" value="1" <?php checked($this->settings['local'], '1'); ?> id="wpfas-local"/>
546
+                                    <span><?php _e('(For free version only) Load FontAwesome fonts from locally. This downloads FontAwesome fonts from fontawesome.com & stores at the local site.', 'ayecode-connect'); ?></span>
547 547
                                 </td>
548 548
                             </tr>
549 549
 
550 550
                             <tr valign="top" class="wpfas-kit-hide">
551 551
                                 <th scope="row"><label
552
-                                            for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'ayecode-connect' ); ?></label>
552
+                                            for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'ayecode-connect'); ?></label>
553 553
                                 </th>
554 554
                                 <td>
555 555
                                     <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
556 556
                                     <input type="checkbox" name="wp-font-awesome-settings[shims]"
557
-                                           value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
558
-                                    <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect' ); ?></span>
557
+                                           value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
558
+                                    <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'ayecode-connect'); ?></span>
559 559
                                 </td>
560 560
                             </tr>
561 561
 
562 562
                             <tr valign="top" class="wpfas-kit-hide">
563 563
                                 <th scope="row"><label
564
-                                            for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'ayecode-connect' ); ?></label>
564
+                                            for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'ayecode-connect'); ?></label>
565 565
                                 </th>
566 566
                                 <td>
567 567
                                     <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
568 568
                                     <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
569
-                                           value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
569
+                                           value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
570 570
                                            id="wpfas-js-pseudo"/>
571
-                                    <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect' ); ?></span>
571
+                                    <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'ayecode-connect'); ?></span>
572 572
                                 </td>
573 573
                             </tr>
574 574
 
575 575
                             <tr valign="top">
576 576
                                 <th scope="row"><label
577
-                                            for="wpfas-dequeue"><?php _e( 'Dequeue', 'ayecode-connect' ); ?></label></th>
577
+                                            for="wpfas-dequeue"><?php _e('Dequeue', 'ayecode-connect'); ?></label></th>
578 578
                                 <td>
579 579
                                     <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
580 580
                                     <input type="checkbox" name="wp-font-awesome-settings[dequeue]"
581
-                                           value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
581
+                                           value="1" <?php checked($this->settings['dequeue'], '1'); ?>
582 582
                                            id="wpfas-dequeue"/>
583
-                                    <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.', 'ayecode-connect' ); ?></span>
583
+                                    <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.', 'ayecode-connect'); ?></span>
584 584
                                 </td>
585 585
                             </tr>
586 586
 
@@ -589,12 +589,12 @@  discard block
 block discarded – undo
589 589
 							<?php
590 590
 							submit_button();
591 591
 							?>
592
-                            <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','ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
592
+                            <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', 'ayecode-connect'); ?> <i class="fas fa-external-link-alt"></i></a></p>
593 593
 
594 594
                         </div>
595 595
                     </form>
596 596
 
597
-                    <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
597
+                    <div id="wpfas-version"><?php echo wp_sprintf(__('Version: %s (affiliate links provided)', 'ayecode-connect'), $this->version); ?></div>
598 598
                 </div>
599 599
 				<?php
600 600
 			}
@@ -609,12 +609,12 @@  discard block
 block discarded – undo
609 609
 		 *
610 610
 		 * @return string Either a valid version number or an empty string.
611 611
 		 */
612
-		public function validate_version_number( $version ) {
612
+		public function validate_version_number($version) {
613 613
 
614
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
614
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
615 615
 				// valid
616 616
 			} else {
617
-				$version = '';// not validated
617
+				$version = ''; // not validated
618 618
 			}
619 619
 
620 620
 			return $version;
@@ -629,27 +629,27 @@  discard block
 block discarded – undo
629 629
 		 * @since 1.0.7
630 630
 		 * @return mixed|string The latest version number found.
631 631
 		 */
632
-		public function get_latest_version( $force_api = false ) {
632
+		public function get_latest_version($force_api = false) {
633 633
 			$latest_version = $this->latest;
634 634
 
635
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
635
+			$cache = get_transient('wp-font-awesome-settings-version');
636 636
 
637
-			if ( $cache === false || $force_api ) { // its not set
637
+			if ($cache === false || $force_api) { // its not set
638 638
 				$api_ver = $this->get_latest_version_from_api();
639
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
639
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
640 640
 					$latest_version = $api_ver;
641
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
641
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
642 642
 				}
643
-			} elseif ( $this->validate_version_number( $cache ) ) {
644
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
643
+			} elseif ($this->validate_version_number($cache)) {
644
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
645 645
 					$latest_version = $cache;
646 646
 				}
647 647
 			}
648 648
 
649 649
 			// Check and auto download fonts locally.
650
-			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 ) ) {
651
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
652
-					$this->download_package( $latest_version );
650
+			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)) {
651
+				if (version_compare($latest_version, $this->settings['local_version'], '>') && is_admin() && !wp_doing_ajax()) {
652
+					$this->download_package($latest_version);
653 653
 				}
654 654
 			}
655 655
 
@@ -664,10 +664,10 @@  discard block
 block discarded – undo
664 664
 		 */
665 665
 		public function get_latest_version_from_api() {
666 666
 			$version  = "0";
667
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
668
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
669
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
670
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
667
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
668
+			if (!is_wp_error($response) && is_array($response)) {
669
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
670
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
671 671
 					$version = $api_response['tag_name'];
672 672
 				}
673 673
 			}
@@ -695,21 +695,21 @@  discard block
 block discarded – undo
695 695
 		public function admin_notices() {
696 696
 			$settings = $this->settings;
697 697
 
698
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
699
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
698
+			if (defined('FONTAWESOME_PLUGIN_FILE')) {
699
+				if (!empty($_REQUEST['page']) && $_REQUEST['page'] == 'wp-font-awesome-settings') {
700 700
 					?>
701 701
                     <div class="notice  notice-error is-dismissible">
702
-                        <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
702
+                        <p><?php _e('The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect'); ?></p>
703 703
                     </div>
704 704
 					<?php
705 705
 				}
706 706
 			} else {
707
-				if ( ! empty( $settings ) ) {
708
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
707
+				if (!empty($settings)) {
708
+					if ($settings['type'] != 'KIT' && $settings['pro'] && ($settings['version'] == '' || version_compare($settings['version'], '6', '>='))) {
709 709
 						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
710 710
 						?>
711 711
                         <div class="notice  notice-error is-dismissible">
712
-                            <p><?php echo wp_sprintf( __( 'Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect' ),"<a href='". esc_url_raw( $link )."'>","</a>" ); ?></p>
712
+                            <p><?php echo wp_sprintf(__('Font Awesome Pro v6 requires the use of a kit, please setup your kit in %ssettings.%s', 'ayecode-connect'), "<a href='" . esc_url_raw($link) . "'>", "</a>"); ?></p>
713 713
                         </div>
714 714
 						<?php
715 715
 					}
@@ -725,20 +725,20 @@  discard block
 block discarded – undo
725 725
 		 * @param string $option The option name.
726 726
 		 * @param mixed  $value  The option value.
727 727
 		 */
728
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
728
+		public function add_option_wp_font_awesome_settings($option, $value) {
729 729
 			// Do nothing if WordPress is being installed.
730
-			if ( wp_installing() ) {
730
+			if (wp_installing()) {
731 731
 				return;
732 732
 			}
733 733
 
734
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
735
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
734
+			if (!empty($value['local']) && empty($value['pro']) && !(!empty($value['type']) && $value['type'] == 'KIT')) {
735
+				$version = isset($value['version']) && $value['version'] ? $value['version'] : $this->get_latest_version();
736 736
 
737
-				if ( ! empty( $version ) ) {
738
-					$response = $this->download_package( $version, $value );
737
+				if (!empty($version)) {
738
+					$response = $this->download_package($version, $value);
739 739
 
740
-					if ( is_wp_error( $response ) ) {
741
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
740
+					if (is_wp_error($response)) {
741
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error');
742 742
 					}
743 743
 				}
744 744
 			}
@@ -752,25 +752,25 @@  discard block
 block discarded – undo
752 752
 		 * @param mixed $old_value The old option value.
753 753
 		 * @param mixed $value     The new option value.
754 754
 		 */
755
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
755
+		public function update_option_wp_font_awesome_settings($old_value, $new_value) {
756 756
 			// Do nothing if WordPress is being installed.
757
-			if ( wp_installing() ) {
757
+			if (wp_installing()) {
758 758
 				return;
759 759
 			}
760 760
 
761
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
761
+			if (!empty($new_value['local']) && empty($new_value['pro']) && !(!empty($new_value['type']) && $new_value['type'] == 'KIT')) {
762 762
 				// Old values
763
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
764
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
763
+				$old_version = isset($old_value['version']) && $old_value['version'] ? $old_value['version'] : (isset($old_value['local_version']) ? $old_value['local_version'] : '');
764
+				$old_local = isset($old_value['local']) ? (int) $old_value['local'] : 0;
765 765
 
766 766
 				// New values
767
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
767
+				$new_version = isset($new_value['version']) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
768 768
 
769
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
770
-					$response = $this->download_package( $new_version, $new_value );
769
+				if (empty($old_local) || $old_version !== $new_version || !file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) {
770
+					$response = $this->download_package($new_version, $new_value);
771 771
 
772
-					if ( is_wp_error( $response ) ) {
773
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
772
+					if (is_wp_error($response)) {
773
+						add_settings_error('general', 'fontawesome_download', __('ERROR:', 'ayecode-connect') . ' ' . $response->get_error_message(), 'error');
774 774
 					}
775 775
 				}
776 776
 			}
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 		 * @param string Fonts directory local path.
785 785
 		 */
786 786
 		public function get_fonts_dir() {
787
-			$upload_dir = wp_upload_dir( null, false );
787
+			$upload_dir = wp_upload_dir(null, false);
788 788
 
789
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
789
+			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
790 790
 		}
791 791
 
792 792
 		/**
@@ -797,9 +797,9 @@  discard block
 block discarded – undo
797 797
 		 * @param string Fonts directory local url.
798 798
 		 */
799 799
 		public function get_fonts_url() {
800
-			$upload_dir = wp_upload_dir( null, false );
800
+			$upload_dir = wp_upload_dir(null, false);
801 801
 
802
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
802
+			return $upload_dir['baseurl'] . '/ayefonts/fa/';
803 803
 		}
804 804
 
805 805
 		/**
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		 * @return bool True if active else false.
811 811
 		 */
812 812
 		public function has_local() {
813
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
813
+			if (!empty($this->settings['local']) && empty($this->settings['pro']) && file_exists($this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css')) {
814 814
 				return true;
815 815
 			}
816 816
 
@@ -825,18 +825,18 @@  discard block
 block discarded – undo
825 825
 		 * @return object The WP Filesystem.
826 826
 		 */
827 827
 		public function get_wp_filesystem() {
828
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
829
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
828
+			if (!function_exists('get_filesystem_method')) {
829
+				require_once(ABSPATH . "/wp-admin/includes/file.php");
830 830
 			}
831 831
 
832 832
 			$access_type = get_filesystem_method();
833 833
 
834
-			if ( $access_type === 'direct' ) {
834
+			if ($access_type === 'direct') {
835 835
 				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
836
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
836
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
837 837
 
838 838
 				/* Initialize the API */
839
-				if ( ! WP_Filesystem( $creds ) ) {
839
+				if (!WP_Filesystem($creds)) {
840 840
 					/* Any problems and we exit */
841 841
 					return false;
842 842
 				}
@@ -845,11 +845,11 @@  discard block
 block discarded – undo
845 845
 
846 846
 				return $wp_filesystem;
847 847
 				/* Do our file manipulations below */
848
-			} else if ( defined( 'FTP_USER' ) ) {
849
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
848
+			} else if (defined('FTP_USER')) {
849
+				$creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array());
850 850
 
851 851
 				/* Initialize the API */
852
-				if ( ! WP_Filesystem( $creds ) ) {
852
+				if (!WP_Filesystem($creds)) {
853 853
 					/* Any problems and we exit */
854 854
 					return false;
855 855
 				}
@@ -872,38 +872,38 @@  discard block
 block discarded – undo
872 872
 		 * @param array $option Fontawesome settings.
873 873
 		 * @return WP_ERROR|bool Error on fail and true on success.
874 874
 		 */
875
-		public function download_package( $version, $option = array() ) {
875
+		public function download_package($version, $option = array()) {
876 876
 			$filename = 'fontawesome-free-' . $version . '-web';
877 877
 			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
878 878
 
879
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
879
+			if (!function_exists('wp_handle_upload')) {
880 880
 				require_once ABSPATH . 'wp-admin/includes/file.php';
881 881
 			}
882 882
 
883
-			$download_file = download_url( esc_url_raw( $url ) );
883
+			$download_file = download_url(esc_url_raw($url));
884 884
 
885
-			if ( is_wp_error( $download_file ) ) {
886
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
887
-			} else if ( empty( $download_file ) ) {
888
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
885
+			if (is_wp_error($download_file)) {
886
+				return new WP_Error('fontawesome_download_failed', __($download_file->get_error_message(), 'ayecode-connect'));
887
+			} else if (empty($download_file)) {
888
+				return new WP_Error('fontawesome_download_failed', __('Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect'));
889 889
 			}
890 890
 
891
-			$response = $this->extract_package( $download_file, $filename, true );
891
+			$response = $this->extract_package($download_file, $filename, true);
892 892
 
893 893
 			// Update local version.
894
-			if ( is_wp_error( $response ) ) {
894
+			if (is_wp_error($response)) {
895 895
 				return $response;
896
-			} else if ( $response ) {
897
-				if ( empty( $option ) ) {
898
-					$option = get_option( 'wp-font-awesome-settings' );
896
+			} else if ($response) {
897
+				if (empty($option)) {
898
+					$option = get_option('wp-font-awesome-settings');
899 899
 				}
900 900
 
901 901
 				$option['local_version'] = $version;
902 902
 
903 903
 				// Remove action to prevent looping.
904
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
904
+				remove_action('update_option_wp-font-awesome-settings', array($this, 'update_option_wp_font_awesome_settings'), 10, 2);
905 905
 
906
-				update_option( 'wp-font-awesome-settings', $option );
906
+				update_option('wp-font-awesome-settings', $option);
907 907
 
908 908
 				return true;
909 909
 			}
@@ -921,60 +921,60 @@  discard block
 block discarded – undo
921 921
 		 * @param bool   $delete_package Delete temp file or not.
922 922
 		 * @return WP_Error|bool True on success WP_Error on fail.
923 923
 		 */
924
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
924
+		public function extract_package($package, $dirname = '', $delete_package = false) {
925 925
 			global $wp_filesystem;
926 926
 
927 927
 			$wp_filesystem = $this->get_wp_filesystem();
928 928
 
929
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
930
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
931
-			} else if ( empty( $wp_filesystem ) ) {
932
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
929
+			if (empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
930
+				return new WP_Error('fontawesome_filesystem_error', __($wp_filesystem->errors->get_error_message(), 'ayecode-connect'));
931
+			} else if (empty($wp_filesystem)) {
932
+				return new WP_Error('fontawesome_filesystem_error', __('Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect'));
933 933
 			}
934 934
 
935 935
 			$fonts_dir = $this->get_fonts_dir();
936
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
936
+			$fonts_tmp_dir = dirname($fonts_dir) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
937 937
 
938
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
939
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
938
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
939
+				$wp_filesystem->delete($fonts_tmp_dir, true);
940 940
 			}
941 941
 
942 942
 			// Unzip package to working directory.
943
-			$result = unzip_file( $package, $fonts_tmp_dir );
943
+			$result = unzip_file($package, $fonts_tmp_dir);
944 944
 
945
-			if ( is_wp_error( $result ) ) {
946
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
945
+			if (is_wp_error($result)) {
946
+				$wp_filesystem->delete($fonts_tmp_dir, true);
947 947
 
948
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
949
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
948
+				if ('incompatible_archive' === $result->get_error_code()) {
949
+					return new WP_Error('fontawesome_incompatible_archive', __($result->get_error_message(), 'ayecode-connect'));
950 950
 				}
951 951
 
952 952
 				return $result;
953 953
 			}
954 954
 
955
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
956
-				$wp_filesystem->delete( $fonts_dir, true );
955
+			if ($wp_filesystem->is_dir($fonts_dir)) {
956
+				$wp_filesystem->delete($fonts_dir, true);
957 957
 			}
958 958
 
959 959
 			$extract_dir = $fonts_tmp_dir;
960 960
 
961
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
961
+			if ($dirname && $wp_filesystem->is_dir($extract_dir . $dirname . DIRECTORY_SEPARATOR)) {
962 962
 				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
963 963
 			}
964 964
 
965 965
 			try {
966
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
967
-			} catch ( Exception $e ) {
968
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
966
+				$return = $wp_filesystem->move($extract_dir, $fonts_dir, true);
967
+			} catch (Exception $e) {
968
+				$return = new WP_Error('fontawesome_move_package', __('Fail to move font awesome package!', 'ayecode-connect'));
969 969
 			}
970 970
 
971
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
972
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
971
+			if ($wp_filesystem->is_dir($fonts_tmp_dir)) {
972
+				$wp_filesystem->delete($fonts_tmp_dir, true);
973 973
 			}
974 974
 
975 975
 			// Once extracted, delete the package if required.
976
-			if ( $delete_package ) {
977
-				unlink( $package );
976
+			if ($delete_package) {
977
+				unlink($package);
978 978
 			}
979 979
 
980 980
 			return $return;
@@ -984,22 +984,22 @@  discard block
 block discarded – undo
984 984
 		 * Output the version in the header.
985 985
 		 */
986 986
 		public function add_generator() {
987
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
988
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
987
+			$file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
988
+			$plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
989 989
 
990 990
 			// Find source plugin/theme.
991 991
 			$source = array();
992
-			if ( strpos( $file, $plugins_dir ) !== false ) {
993
-				$source = explode( "/", plugin_basename( $file ) );
994
-			} else if ( function_exists( 'get_theme_root' ) ) {
995
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
992
+			if (strpos($file, $plugins_dir) !== false) {
993
+				$source = explode("/", plugin_basename($file));
994
+			} else if (function_exists('get_theme_root')) {
995
+				$themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
996 996
 
997
-				if ( strpos( $file, $themes_dir ) !== false ) {
998
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
997
+				if (strpos($file, $themes_dir) !== false) {
998
+					$source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
999 999
 				}
1000 1000
 			}
1001 1001
 
1002
-			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1002
+			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr($this->version) . '"' . (!empty($source[0]) ? ' data-ac-source="' . esc_attr($source[0]) . '"' : '') . ' />';
1003 1003
 		}
1004 1004
 	}
1005 1005
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 4 patches
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 
463 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 468
 				$rtl = is_rtl() && ! $aui_bs5 ? '-rtl' : '';
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 					// custom changes
553 553
 					if ( $load_fse ) {
554 554
 						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
555
-					}else{
555
+					} else{
556 556
 						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
557 557
 
558 558
 					}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 			ob_start();
577 577
 			if ( $aui_bs5 ) {
578 578
 				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
579
-			}else{
579
+			} else{
580 580
 				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
581 581
             }
582 582
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 
648 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
 
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 				// iconpicker
663 663
 				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
664 664
 					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
665
-				}else{
665
+				} else{
666 666
 					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
667 667
 				}
668 668
 
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
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 1100
 					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
 
1233 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
 
@@ -1517,9 +1517,9 @@  discard block
 block discarded – undo
1517 1517
 
1518 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
 
@@ -2385,7 +2385,9 @@  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) === "") {
2389
+			    return $input;
2390
+			}
2389 2391
 			return preg_replace(
2390 2392
 				array(
2391 2393
 					// Remove comment(s)
@@ -2417,7 +2419,9 @@  discard block
 block discarded – undo
2417 2419
 		 * @return mixed
2418 2420
 		 */
2419 2421
 		public static function minify_css($input) {
2420
-			if(trim($input) === "") return $input;
2422
+			if(trim($input) === "") {
2423
+			    return $input;
2424
+			}
2421 2425
 			return preg_replace(
2422 2426
 				array(
2423 2427
 					// Remove comment(s)
Please login to merge, or discard this patch.
Spacing   +763 added lines, -763 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>'. wp_kses_post( $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>' . wp_kses_post($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;
@@ -541,14 +541,14 @@  discard block
 block discarded – undo
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
544
+						wp_add_inline_style('ayecode-ui', $custom_css);
545 545
 					}
546 546
 
547 547
 					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
548
+					if ($load_fse) {
549
+						wp_add_inline_style('ayecode-ui-fse', self::custom_css($compatibility));
550
+					} else {
551
+						wp_add_inline_style('ayecode-ui', self::custom_css($compatibility));
552 552
 
553 553
 					}
554 554
 
@@ -569,10 +569,10 @@  discard block
 block discarded – undo
569 569
 			$flatpickr_locale = self::flatpickr_locale();
570 570
 
571 571
 			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
572
+			if ($aui_bs5) {
573
+				include_once(dirname(__FILE__) . '/inc/bs5-js.php');
574
+			} else {
575
+				include_once(dirname(__FILE__) . '/inc/bs4-js.php');
576 576
             }
577 577
 
578 578
 			$output = ob_get_clean();
@@ -580,10 +580,10 @@  discard block
 block discarded – undo
580 580
 			/*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
583
+			return str_replace(array(
584 584
 				'<script>',
585 585
 				'</script>'
586
-			), '', self::minify_js($output) );
586
+			), '', self::minify_js($output));
587 587
 		}
588 588
 
589 589
 
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 			ob_start();
598 598
 			?>
599 599
             <script>
600
-				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
600
+				<?php if (defined('FUSION_BUILDER_VERSION')) { ?>
601 601
                 /* With Avada builder */
602 602
 
603 603
 				<?php } ?>
604 604
             </script>
605 605
 			<?php
606
-			return str_replace( array(
606
+			return str_replace(array(
607 607
 				'<script>',
608 608
 				'</script>'
609 609
 			), '', ob_get_clean());
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		 *
615 615
 		 * If this remains small then its best to use this than to add another JS file.
616 616
 		 */
617
-		public function inline_script_file_browser(){
617
+		public function inline_script_file_browser() {
618 618
 			ob_start();
619 619
 			?>
620 620
             <script>
@@ -629,10 +629,10 @@  discard block
 block discarded – undo
629 629
 			/*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
632
+			return str_replace(array(
633 633
 				'<script>',
634 634
 				'</script>'
635
-			), '', $output );
635
+			), '', $output);
636 636
 		}
637 637
 
638 638
 		/**
@@ -640,59 +640,59 @@  discard block
 block discarded – undo
640 640
 		 */
641 641
 		public function enqueue_scripts() {
642 642
 
643
-			if( is_admin() && !$this->is_aui_screen()){
643
+			if (is_admin() && !$this->is_aui_screen()) {
644 644
 				// don't add wp-admin scripts if not requested to
645
-			}else {
645
+			} else {
646 646
 
647 647
 				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648 648
 
649 649
 				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650 650
 
651 651
 				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
652
+				wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version);
653 653
 
654 654
 				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
655
+				wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version);
656 656
 
657 657
 				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
658
+				if (defined('FAS_ICONPICKER_JS_URL')) {
659
+					wp_register_script('iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version);
660
+				} else {
661
+					wp_register_script('iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version);
662 662
 				}
663 663
 
664 664
 				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
665
+				wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version);
666
+				wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser());
667 667
 
668 668
 				$load_inline = false;
669 669
 
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
670
+				if ($this->settings[$js_setting] == 'core-popper') {
671 671
 					// Bootstrap bundle
672 672
 					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
673
+					wp_register_script('bootstrap-js-bundle', $url, array(
674 674
 						'select2',
675 675
 						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
676
+					), $this->version, $this->is_bs3_compat());
677 677
 					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
678
+					is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle');
679 679
 					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
680
+					wp_add_inline_script('bootstrap-js-bundle', $script);
681
+				} elseif ($this->settings[$js_setting] == 'popper') {
682 682
 					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
683
+					wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->version);
684
+					wp_enqueue_script('bootstrap-js-popper');
685 685
 					$load_inline = true;
686 686
 				} else {
687 687
 					$load_inline = true;
688 688
 				}
689 689
 
690 690
 				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
691
+				if ($load_inline) {
692
+					wp_register_script('bootstrap-dummy', '', array('select2', 'jquery'));
693
+					wp_enqueue_script('bootstrap-dummy');
694 694
 					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
695
+					wp_add_inline_script('bootstrap-dummy', $script);
696 696
 				}
697 697
 			}
698 698
 
@@ -701,17 +701,17 @@  discard block
 block discarded – undo
701 701
 		/**
702 702
 		 * Enqueue flatpickr if called.
703 703
 		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
704
+		public function enqueue_flatpickr() {
705
+			wp_enqueue_style('flatpickr');
706
+			wp_enqueue_script('flatpickr');
707 707
 		}
708 708
 
709 709
 		/**
710 710
 		 * Enqueue iconpicker if called.
711 711
 		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
712
+		public function enqueue_iconpicker() {
713
+			wp_enqueue_style('iconpicker');
714
+			wp_enqueue_script('iconpicker');
715 715
 		}
716 716
 
717 717
 		/**
@@ -720,19 +720,19 @@  discard block
 block discarded – undo
720 720
 		 * @return string
721 721
 		 */
722 722
 		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
723
+			$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
724
+			$content_url = untrailingslashit(WP_CONTENT_URL);
725 725
 
726 726
 			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
727
+			if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
728
+				$content_url = str_replace('http://', 'https://', $content_url);
729 729
 			}
730 730
 
731 731
 			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
732
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
733
+			$url = str_replace($content_dir, $content_url, $file_dir);
734 734
 
735
-			return trailingslashit( $url );
735
+			return trailingslashit($url);
736 736
 		}
737 737
 
738 738
 		/**
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
 
745 745
 			$url = '';
746 746
 			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
747
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
748 748
 
749 749
 			// add check in-case user has changed wp-content dir name.
750 750
 			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
751
+			$dir_parts = explode("/$wp_content_folder_name/", $file_dir);
752
+			$url_parts = explode("/$wp_content_folder_name/", plugins_url());
753 753
 
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
754
+			if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
755
+				$url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]);
756 756
 			}
757 757
 
758 758
 			return $url;
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 		 * Register the database settings with WordPress.
763 763
 		 */
764 764
 		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
765
+			register_setting('ayecode-ui-settings', 'ayecode-ui-settings');
766 766
 		}
767 767
 
768 768
 		/**
@@ -771,10 +771,10 @@  discard block
 block discarded – undo
771 771
 		 */
772 772
 		public function menu_item() {
773 773
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
774
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775 775
 				$this,
776 776
 				'settings_page'
777
-			) );
777
+			));
778 778
 		}
779 779
 
780 780
 		/**
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 		 *
783 783
 		 * @return array
784 784
 		 */
785
-		public function theme_js_settings(){
785
+		public function theme_js_settings() {
786 786
 			return array(
787 787
 				'ayetheme' => 'popper',
788 788
 				'listimia' => 'required',
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	        $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
804 804
 
805 805
 	        // Execute the query
806
-	        $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
806
+	        $date = $wpdb->get_var($query); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
807 807
 
808 808
 	        return $date ? $date : false;
809 809
         }
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
 		/**
812 812
 		 * Show admin notice if backend scripts not loaded.
813 813
 		 */
814
-		public function show_admin_version_notice(){
815
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
-			$message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>';
814
+		public function show_admin_version_notice() {
815
+			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings");
816
+			$button = '<a href="' . esc_url($fix_url) . '" class="button-primary">View Settings</a>';
817
+			$message = __('<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)') . " " . $button;
818
+			echo '<div class="notice notice-error aui-settings-error-notice"><p>' . wp_kses_post($message) . '</p></div>';
819 819
 		}
820 820
 
821 821
 		/**
@@ -825,32 +825,32 @@  discard block
 block discarded – undo
825 825
 		 */
826 826
 		public function get_settings() {
827 827
 
828
-			$db_settings = get_option( 'ayecode-ui-settings' );
828
+			$db_settings = get_option('ayecode-ui-settings');
829 829
 
830 830
             // Maybe show default version notice
831
-			$site_install_date = new DateTime( self::get_site_install_date() );
831
+			$site_install_date = new DateTime(self::get_site_install_date());
832 832
 			$switch_over_date = new DateTime("2024-02-01");
833
-			if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
-				add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
833
+			if (empty($db_settings) && $site_install_date < $switch_over_date) {
834
+				add_action('admin_notices', array($this, 'show_admin_version_notice'));
835 835
 			}
836 836
 
837 837
 			$js_default = 'core-popper';
838 838
 			$js_default_backend = $js_default;
839 839
 
840 840
 			// maybe set defaults (if no settings set)
841
-			if(empty($db_settings)){
842
-				$active_theme = strtolower( get_template() ); // active parent theme.
841
+			if (empty($db_settings)) {
842
+				$active_theme = strtolower(get_template()); // active parent theme.
843 843
 				$theme_js_settings = self::theme_js_settings();
844
-				if(isset($theme_js_settings[$active_theme])){
844
+				if (isset($theme_js_settings[$active_theme])) {
845 845
 					$js_default = $theme_js_settings[$active_theme];
846
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
846
+					$js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default;
847 847
 				}
848 848
 			}
849 849
 
850 850
 			/**
851 851
 			 * Filter the default settings.
852 852
 			 */
853
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
853
+			$defaults = apply_filters('ayecode-ui-default-settings', array(
854 854
 				'css'            => 'compatibility', // core, compatibility
855 855
 				'js'             => $js_default, // js to load, core-popper, popper
856 856
 				'html_font_size' => '16', // js to load, core-popper, popper
@@ -858,16 +858,16 @@  discard block
 block discarded – undo
858 858
 				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859 859
 				'disable_admin'  => '', // URL snippets to disable loading on admin
860 860
                 'bs_ver'         => '5', // The default bootstrap version to sue by default
861
-			), $db_settings );
861
+			), $db_settings);
862 862
 
863
-			$settings = wp_parse_args( $db_settings, $defaults );
863
+			$settings = wp_parse_args($db_settings, $defaults);
864 864
 
865 865
 			/**
866 866
 			 * Filter the Bootstrap settings.
867 867
 			 *
868 868
 			 * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869 869
 			 */
870
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
870
+			return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults);
871 871
 		}
872 872
 
873 873
 
@@ -875,109 +875,109 @@  discard block
 block discarded – undo
875 875
 		 * The settings page html output.
876 876
 		 */
877 877
 		public function settings_page() {
878
-			if ( ! current_user_can( 'manage_options' ) ) {
879
-				wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
878
+			if (!current_user_can('manage_options')) {
879
+				wp_die(esc_attr__('You do not have sufficient permissions to access this page.', 'ayecode-connect'));
880 880
 			}
881
-            $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
881
+            $overrides = apply_filters('ayecode-ui-settings', array(), array(), array());
882 882
 
883 883
 			?>
884 884
             <div class="wrap">
885
-                <h1><?php echo esc_attr( $this->name ); ?></h1>
886
-                <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p>
885
+                <h1><?php echo esc_attr($this->name); ?></h1>
886
+                <p><?php echo esc_html(apply_filters('ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect'))); ?></p>
887 887
                 <form method="post" action="options.php">
888 888
 					<?php
889
-					settings_fields( 'ayecode-ui-settings' );
890
-					do_settings_sections( 'ayecode-ui-settings' );
889
+					settings_fields('ayecode-ui-settings');
890
+					do_settings_sections('ayecode-ui-settings');
891 891
 					?>
892 892
 
893
-                    <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
894
-                    <p><?php echo esc_html( 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.", 'ayecode-connect' ) ) );?></p>
893
+                    <h2><?php esc_html_e('BootStrap Version', 'ayecode-connect'); ?></h2>
894
+                    <p><?php echo esc_html(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.", 'ayecode-connect'))); ?></p>
895 895
 	                <div class="bsui"><?php
896
-	                if ( ! empty( $overrides ) ) {
896
+	                if (!empty($overrides)) {
897 897
 		                echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898 898
 			                'type'=> 'info',
899
-			                'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
899
+			                'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect')
900 900
 		                ));
901 901
 	                }
902 902
 	                ?>
903 903
                     </div>
904 904
                     <table class="form-table wpbs-table-version-settings">
905 905
                         <tr valign="top">
906
-                            <th scope="row"><label for="wpbs-css"><?php esc_html_e( 'Version', 'ayecode-connect' ); ?></label></th>
906
+                            <th scope="row"><label for="wpbs-css"><?php esc_html_e('Version', 'ayecode-connect'); ?></label></th>
907 907
                             <td>
908 908
                                 <select name="ayecode-ui-settings[bs_ver]" id="wpbs-css" <?php echo !empty($overrides['bs_ver']) ? 'disabled' : ''; ?>>
909
-                                    <option	value="5" <?php selected( $this->settings['bs_ver'], '5' ); ?>><?php esc_html_e( 'v5 (recommended)', 'ayecode-connect' ); ?></option>
910
-                                    <option value="4" <?php selected( $this->settings['bs_ver'], '4' ); ?>><?php esc_html_e( 'v4 (legacy)', 'ayecode-connect' ); ?></option>
909
+                                    <option	value="5" <?php selected($this->settings['bs_ver'], '5'); ?>><?php esc_html_e('v5 (recommended)', 'ayecode-connect'); ?></option>
910
+                                    <option value="4" <?php selected($this->settings['bs_ver'], '4'); ?>><?php esc_html_e('v4 (legacy)', 'ayecode-connect'); ?></option>
911 911
                                 </select>
912 912
                             </td>
913 913
                         </tr>
914 914
                     </table>
915 915
 
916
-                    <h2><?php esc_html_e( 'Frontend', 'ayecode-connect' ); ?></h2>
916
+                    <h2><?php esc_html_e('Frontend', 'ayecode-connect'); ?></h2>
917 917
                     <table class="form-table wpbs-table-settings">
918 918
                         <tr valign="top">
919
-                            <th scope="row"><label for="wpbs-css"><?php esc_html_e( 'Load CSS', 'ayecode-connect' ); ?></label></th>
919
+                            <th scope="row"><label for="wpbs-css"><?php esc_html_e('Load CSS', 'ayecode-connect'); ?></label></th>
920 920
                             <td>
921 921
                                 <select name="ayecode-ui-settings[css]" id="wpbs-css" <?php echo !empty($overrides['css']) ? 'disabled' : ''; ?>>
922
-                                    <option	value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php esc_html_e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option>
923
-                                    <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php esc_html_e( 'Full Mode', 'ayecode-connect' ); ?></option>
924
-                                    <option	value="" <?php selected( $this->settings['css'], '' ); ?>><?php esc_html_e( 'Disabled', 'ayecode-connect' ); ?></option>
922
+                                    <option	value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php esc_html_e('Compatibility Mode (default)', 'ayecode-connect'); ?></option>
923
+                                    <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php esc_html_e('Full Mode', 'ayecode-connect'); ?></option>
924
+                                    <option	value="" <?php selected($this->settings['css'], ''); ?>><?php esc_html_e('Disabled', 'ayecode-connect'); ?></option>
925 925
                                 </select>
926 926
                             </td>
927 927
                         </tr>
928 928
 
929 929
                         <tr valign="top">
930
-                            <th scope="row"><label for="wpbs-js"><?php esc_html_e( 'Load JS', 'ayecode-connect' ); ?></label></th>
930
+                            <th scope="row"><label for="wpbs-js"><?php esc_html_e('Load JS', 'ayecode-connect'); ?></label></th>
931 931
                             <td>
932 932
                                 <select name="ayecode-ui-settings[js]" id="wpbs-js" <?php echo !empty($overrides['js']) ? 'disabled' : ''; ?>>
933
-                                    <option	value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php esc_html_e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option>
934
-                                    <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php esc_html_e( 'Popper', 'ayecode-connect' ); ?></option>
935
-                                    <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php esc_html_e( 'Required functions only', 'ayecode-connect' ); ?></option>
936
-                                    <option	value="" <?php selected( $this->settings['js'], '' ); ?>><?php esc_html_e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option>
933
+                                    <option	value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php esc_html_e('Core + Popper (default)', 'ayecode-connect'); ?></option>
934
+                                    <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php esc_html_e('Popper', 'ayecode-connect'); ?></option>
935
+                                    <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php esc_html_e('Required functions only', 'ayecode-connect'); ?></option>
936
+                                    <option	value="" <?php selected($this->settings['js'], ''); ?>><?php esc_html_e('Disabled (not recommended)', 'ayecode-connect'); ?></option>
937 937
                                 </select>
938 938
                             </td>
939 939
                         </tr>
940 940
 
941 941
                         <tr valign="top">
942
-                            <th scope="row"><label for="wpbs-font_size"><?php esc_html_e( 'HTML Font Size (px)', 'ayecode-connect' ); ?></label></th>
942
+                            <th scope="row"><label for="wpbs-font_size"><?php esc_html_e('HTML Font Size (px)', 'ayecode-connect'); ?></label></th>
943 943
                             <td>
944
-                                <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' : ''; ?> />
945
-                                <p class="description" ><?php esc_html_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.", 'ayecode-connect' );?></p>
944
+                                <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' : ''; ?> />
945
+                                <p class="description" ><?php esc_html_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.", 'ayecode-connect'); ?></p>
946 946
                             </td>
947 947
                         </tr>
948 948
 
949 949
                     </table>
950 950
 
951
-                    <h2><?php esc_html_e( 'Backend', 'ayecode-connect' ); ?> (wp-admin)</h2>
951
+                    <h2><?php esc_html_e('Backend', 'ayecode-connect'); ?> (wp-admin)</h2>
952 952
                     <table class="form-table wpbs-table-settings">
953 953
                         <tr valign="top">
954
-                            <th scope="row"><label for="wpbs-css-admin"><?php esc_html_e( 'Load CSS', 'ayecode-connect' ); ?></label></th>
954
+                            <th scope="row"><label for="wpbs-css-admin"><?php esc_html_e('Load CSS', 'ayecode-connect'); ?></label></th>
955 955
                             <td>
956 956
                                 <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin" <?php echo !empty($overrides['css_backend']) ? 'disabled' : ''; ?>>
957
-                                    <option	value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php esc_html_e( 'Compatibility Mode (default)', 'ayecode-connect' ); ?></option>
958
-                                    <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php esc_html_e( 'Full Mode (will cause style issues)', 'ayecode-connect' ); ?></option>
959
-                                    <option	value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php esc_html_e( 'Disabled', 'ayecode-connect' ); ?></option>
957
+                                    <option	value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php esc_html_e('Compatibility Mode (default)', 'ayecode-connect'); ?></option>
958
+                                    <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php esc_html_e('Full Mode (will cause style issues)', 'ayecode-connect'); ?></option>
959
+                                    <option	value="" <?php selected($this->settings['css_backend'], ''); ?>><?php esc_html_e('Disabled', 'ayecode-connect'); ?></option>
960 960
                                 </select>
961 961
                             </td>
962 962
                         </tr>
963 963
 
964 964
                         <tr valign="top">
965
-                            <th scope="row"><label for="wpbs-js-admin"><?php esc_html_e( 'Load JS', 'ayecode-connect' ); ?></label></th>
965
+                            <th scope="row"><label for="wpbs-js-admin"><?php esc_html_e('Load JS', 'ayecode-connect'); ?></label></th>
966 966
                             <td>
967 967
                                 <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin" <?php echo !empty($overrides['js_backend']) ? 'disabled' : ''; ?>>
968
-                                    <option	value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php esc_html_e( 'Core + Popper (default)', 'ayecode-connect' ); ?></option>
969
-                                    <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php esc_html_e( 'Popper', 'ayecode-connect' ); ?></option>
970
-                                    <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php esc_html_e( 'Required functions only', 'ayecode-connect' ); ?></option>
971
-                                    <option	value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php esc_html_e( 'Disabled (not recommended)', 'ayecode-connect' ); ?></option>
968
+                                    <option	value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php esc_html_e('Core + Popper (default)', 'ayecode-connect'); ?></option>
969
+                                    <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php esc_html_e('Popper', 'ayecode-connect'); ?></option>
970
+                                    <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php esc_html_e('Required functions only', 'ayecode-connect'); ?></option>
971
+                                    <option	value="" <?php selected($this->settings['js_backend'], ''); ?>><?php esc_html_e('Disabled (not recommended)', 'ayecode-connect'); ?></option>
972 972
                                 </select>
973 973
                             </td>
974 974
                         </tr>
975 975
 
976 976
                         <tr valign="top">
977
-                            <th scope="row"><label for="wpbs-disable-admin"><?php esc_html_e( 'Disable load on URL', 'ayecode-connect' ); ?></label></th>
977
+                            <th scope="row"><label for="wpbs-disable-admin"><?php esc_html_e('Disable load on URL', 'ayecode-connect'); ?></label></th>
978 978
                             <td>
979
-                                <p><?php esc_html_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.', 'ayecode-connect' ); ?></p>
980
-                                <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 esc_textarea( $this->settings['disable_admin'] );?></textarea>
979
+                                <p><?php esc_html_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.', 'ayecode-connect'); ?></p>
980
+                                <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 esc_textarea($this->settings['disable_admin']); ?></textarea>
981 981
                             </td>
982 982
                         </tr>
983 983
                     </table>
@@ -986,33 +986,33 @@  discard block
 block discarded – undo
986 986
 					submit_button();
987 987
 					?>
988 988
                 </form>
989
-                <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div>
989
+                <div id="wpbs-version" data-aui-source="<?php echo esc_attr($this->get_load_source()); ?>"><?php echo esc_html($this->version); ?></div>
990 990
             </div>
991 991
 			<?php
992 992
 		}
993 993
 
994
-        public function get_load_source(){
995
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
994
+        public function get_load_source() {
995
+	        $file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
996
+	        $plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
997 997
 
998 998
 	        // Find source plugin/theme of SD
999 999
 	        $source = array();
1000
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
1001
-		        $source = explode( "/", plugin_basename( $file ) );
1002
-	        } else if ( function_exists( 'get_theme_root' ) ) {
1003
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1000
+	        if (strpos($file, $plugins_dir) !== false) {
1001
+		        $source = explode("/", plugin_basename($file));
1002
+	        } else if (function_exists('get_theme_root')) {
1003
+		        $themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
1004 1004
 
1005
-		        if ( strpos( $file, $themes_dir ) !== false ) {
1006
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1005
+		        if (strpos($file, $themes_dir) !== false) {
1006
+			        $source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
1007 1007
 		        }
1008 1008
 	        }
1009 1009
 
1010 1010
             return isset($source[0]) ? esc_attr($source[0]) : '';
1011 1011
         }
1012 1012
 
1013
-		public function customizer_settings($wp_customize){
1013
+		public function customizer_settings($wp_customize) {
1014 1014
 			$wp_customize->add_section('aui_settings', array(
1015
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
1015
+				'title'    => __('AyeCode UI', 'ayecode-connect'),
1016 1016
 				'priority' => 120,
1017 1017
 			));
1018 1018
 
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 				'type'              => 'option',
1027 1027
 				'transport'         => 'refresh',
1028 1028
 			));
1029
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
-				'label'    => __('Primary Color', 'ayecode-connect' ),
1029
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
+				'label'    => __('Primary Color', 'ayecode-connect'),
1031 1031
 				'section'  => 'aui_settings',
1032 1032
 				'settings' => 'aui_options[color_primary]',
1033 1033
 			)));
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 				'type'              => 'option',
1040 1040
 				'transport'         => 'refresh',
1041 1041
 			));
1042
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1042
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
+				'label'    => __('Secondary Color', 'ayecode-connect'),
1044 1044
 				'section'  => 'aui_settings',
1045 1045
 				'settings' => 'aui_options[color_secondary]',
1046 1046
 			)));
@@ -1066,12 +1066,12 @@  discard block
 block discarded – undo
1066 1066
                 .collapse.show:not(.in){display: inherit;}
1067 1067
                 .fade.show{opacity: 1;}
1068 1068
 
1069
-                <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?>
1069
+                <?php if (defined('SVQ_THEME_VERSION')) { ?>
1070 1070
                 /* KLEO theme specific */
1071 1071
                 .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;}
1072 1072
                 <?php } ?>
1073 1073
 
1074
-                <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1074
+                <?php if (defined('FUSION_BUILDER_VERSION')) { ?>
1075 1075
                 /* With Avada builder */
1076 1076
                 body.modal-open .modal.in  {opacity:1;z-index: 99999}
1077 1077
                 body.modal-open .modal.bsui.in .modal-content  {box-shadow: none;}
@@ -1082,10 +1082,10 @@  discard block
 block discarded – undo
1082 1082
                 <?php } ?>
1083 1083
             </style>
1084 1084
 			<?php
1085
-			return str_replace( array(
1085
+			return str_replace(array(
1086 1086
 				'<style>',
1087 1087
 				'</style>'
1088
-			), '', self::minify_css( ob_get_clean() ) );
1088
+			), '', self::minify_css(ob_get_clean()));
1089 1089
 		}
1090 1090
 
1091 1091
 
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
             global $aui_bs5;
1094 1094
 
1095 1095
 			$colors = array();
1096
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1096
+			if (defined('BLOCKSTRAP_VERSION')) {
1097 1097
 
1098 1098
 
1099 1099
 				$setting = wp_get_global_settings();
@@ -1102,22 +1102,22 @@  discard block
 block discarded – undo
1102 1102
 //                print_r(get_default_block_editor_settings());exit;
1103 1103
 
1104 1104
 //                print_r($setting);echo  '###';exit;
1105
-				if(!empty($setting['color']['palette']['theme'])){
1106
-					foreach($setting['color']['palette']['theme'] as $color){
1105
+				if (!empty($setting['color']['palette']['theme'])) {
1106
+					foreach ($setting['color']['palette']['theme'] as $color) {
1107 1107
 						$colors[$color['slug']] = esc_attr($color['color']);
1108 1108
 					}
1109 1109
 				}
1110 1110
 
1111
-				if(!empty($setting['color']['palette']['custom'])){
1112
-					foreach($setting['color']['palette']['custom'] as $color){
1111
+				if (!empty($setting['color']['palette']['custom'])) {
1112
+					foreach ($setting['color']['palette']['custom'] as $color) {
1113 1113
 						$colors[$color['slug']] = esc_attr($color['color']);
1114 1114
 					}
1115 1115
 				}
1116
-			}else{
1116
+			} else {
1117 1117
 				$settings = get_option('aui_options');
1118 1118
 				$colors = array(
1119
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1119
+					'primary'   => !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
+					'secondary' => !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121 1121
 				);
1122 1122
 			}
1123 1123
 
@@ -1128,25 +1128,25 @@  discard block
 block discarded – undo
1128 1128
                 <?php
1129 1129
 
1130 1130
 					// BS v3 compat
1131
-					if( self::is_bs3_compat() ){
1131
+					if (self::is_bs3_compat()) {
1132 1132
 						echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1133 1133
 					}
1134 1134
 
1135
-                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1135
+                    $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
1136 1136
                     $is_fse = false;
1137
-                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
1137
+                    if (is_admin() && (!empty($_REQUEST['postType']) || $current_screen->is_block_editor()) && (defined('BLOCKSTRAP_VERSION') || defined('AUI_FSE'))) {
1138 1138
                         $is_fse = true;
1139 1139
                     }
1140 1140
 
1141
-					if(!empty($colors)){
1141
+					if (!empty($colors)) {
1142 1142
 						$d_colors = self::get_colors(true);
1143 1143
 
1144 1144
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
-						foreach($colors as $key => $color ){
1146
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1145
+						foreach ($colors as $key => $color) {
1146
+							if ((empty($d_colors[$key]) || $d_colors[$key] != $color) || $is_fse) {
1147 1147
 								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148 1148
 								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1149
+								echo $aui_bs5 ? self::css_overwrite_bs5($key, $var, $compat, $color) : self::css_overwrite($key, $var, $compat, $color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1150 1150
 							}
1151 1151
 						}
1152 1152
 					   // exit;
@@ -1155,71 +1155,71 @@  discard block
 block discarded – undo
1155 1155
 					// Set admin bar z-index lower when modal is open.
1156 1156
 					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1157 1157
 
1158
-					if(is_admin()){
1158
+					if (is_admin()) {
1159 1159
 						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160 1160
 					}
1161 1161
 
1162
-                    if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1162
+                    if ($aui_bs5 && defined('BLOCKSTRAP_VERSION')) {
1163 1163
                         $css = '';
1164 1164
                         $theme_settings = wp_get_global_styles();
1165 1165
 
1166 1166
 //                        print_r( $theme_settings);exit;
1167 1167
 
1168 1168
                         // font face
1169
-                        if( !empty( $theme_settings['typography']['fontFamily'] ) ){
1170
-                            $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily']  ); //var(--wp--preset--font-family--poppins)
1169
+                        if (!empty($theme_settings['typography']['fontFamily'])) {
1170
+                            $t_fontface = str_replace(array('var:preset|', 'font-family|'), array('--wp--preset--', 'font-family--'), $theme_settings['typography']['fontFamily']); //var(--wp--preset--font-family--poppins)
1171 1171
                             $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';';
1172 1172
                         }
1173 1173
 
1174 1174
                         // font size
1175
-                        if( !empty( $theme_settings['typography']['fontSize'] ) ){
1176
-                            $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;';
1175
+                        if (!empty($theme_settings['typography']['fontSize'])) {
1176
+                            $css .= '--bs-body-font-size: ' . esc_attr($theme_settings['typography']['fontSize']) . ' ;';
1177 1177
                         }
1178 1178
 
1179 1179
                         // line height
1180
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181
-                            $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1180
+                         if (!empty($theme_settings['typography']['lineHeight'])) {
1181
+                            $css .= '--bs-body-line-height: ' . esc_attr($theme_settings['typography']['lineHeight']) . ';';
1182 1182
                         }
1183 1183
 
1184 1184
 
1185 1185
                            // font weight
1186
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187
-                            $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1186
+                         if (!empty($theme_settings['typography']['fontWeight'])) {
1187
+                            $css .= '--bs-body-font-weight: ' . esc_attr($theme_settings['typography']['fontWeight']) . ';';
1188 1188
                         }
1189 1189
 
1190 1190
                         // Background
1191
-                         if( !empty( $theme_settings['color']['background'] ) ){
1192
-                            $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1191
+                         if (!empty($theme_settings['color']['background'])) {
1192
+                            $css .= '--bs-body-bg: ' . esc_attr($theme_settings['color']['background']) . ';';
1193 1193
                         }
1194 1194
 
1195 1195
                          // Background Gradient
1196
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1197
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1196
+                         if (!empty($theme_settings['color']['gradient'])) {
1197
+                            $css .= 'background: ' . esc_attr($theme_settings['color']['gradient']) . ';';
1198 1198
                         }
1199 1199
 
1200 1200
                            // Background Gradient
1201
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1202
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1201
+                         if (!empty($theme_settings['color']['gradient'])) {
1202
+                            $css .= 'background: ' . esc_attr($theme_settings['color']['gradient']) . ';';
1203 1203
                         }
1204 1204
 
1205 1205
                         // text color
1206
-                        if( !empty( $theme_settings['color']['text'] ) ){
1207
-                            $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';';
1206
+                        if (!empty($theme_settings['color']['text'])) {
1207
+                            $css .= '--bs-body-color: ' . esc_attr($theme_settings['color']['text']) . ';';
1208 1208
                         }
1209 1209
 
1210 1210
 
1211 1211
                         // link colors
1212
-                        if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){
1213
-                            $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';';
1212
+                        if (!empty($theme_settings['elements']['link']['color']['text'])) {
1213
+                            $css .= '--bs-link-color: ' . esc_attr($theme_settings['elements']['link']['color']['text']) . ';';
1214 1214
                         }
1215
-                        if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){
1216
-                            $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';';
1215
+                        if (!empty($theme_settings['elements']['link'][':hover']['color']['text'])) {
1216
+                            $css .= '--bs-link-hover-color: ' . esc_attr($theme_settings['elements']['link'][':hover']['color']['text']) . ';';
1217 1217
                         }
1218 1218
 
1219 1219
 
1220 1220
 
1221
-                        if($css){
1222
-                            echo  $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}';
1221
+                        if ($css) {
1222
+                            echo  $is_fse ? 'body.editor-styles-wrapper{' . esc_attr($css) . '}' : 'body{' . esc_attr($css) . '}';
1223 1223
                         }
1224 1224
 
1225 1225
                         $bep = $is_fse ? 'body.editor-styles-wrapper ' : '';
@@ -1227,48 +1227,48 @@  discard block
 block discarded – undo
1227 1227
 
1228 1228
                         // Headings
1229 1229
                         $headings_css = '';
1230
-                        if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){
1231
-                            $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";";
1230
+                        if (!empty($theme_settings['elements']['heading']['color']['text'])) {
1231
+                            $headings_css .= "color: " . esc_attr($theme_settings['elements']['heading']['color']['text']) . ";";
1232 1232
                         }
1233 1233
 
1234 1234
                         // heading background
1235
-                        if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){
1236
-                            $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1235
+                        if (!empty($theme_settings['elements']['heading']['color']['background'])) {
1236
+                            $headings_css .= 'background: ' . esc_attr($theme_settings['elements']['heading']['color']['background']) . ';';
1237 1237
                         }
1238 1238
 
1239 1239
                          // heading font family
1240
-                        if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241
-                            $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1240
+                        if (!empty($theme_settings['elements']['heading']['typography']['fontFamily'])) {
1241
+                            $headings_css .= 'font-family: ' . esc_attr($theme_settings['elements']['heading']['typography']['fontFamily']) . ';';
1242 1242
                         }
1243 1243
 
1244
-                        if( $headings_css ){
1245
-                            echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1244
+                        if ($headings_css) {
1245
+                            echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr($headings_css) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1246 1246
                         }
1247 1247
 
1248
-                        $hs = array('h1','h2','h3','h4','h5','h6');
1248
+                        $hs = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6');
1249 1249
 
1250
-                        foreach($hs as $hn){
1250
+                        foreach ($hs as $hn) {
1251 1251
                             $h_css = '';
1252
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253
-                                $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1252
+                             if (!empty($theme_settings['elements'][$hn]['color']['text'])) {
1253
+                                $h_css .= 'color: ' . esc_attr($theme_settings['elements'][$hn]['color']['text']) . ';';
1254 1254
                              }
1255 1255
 
1256
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257
-                                $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1256
+                              if (!empty($theme_settings['elements'][$hn]['typography']['fontSize'])) {
1257
+                                $h_css .= 'font-size: ' . esc_attr($theme_settings['elements'][$hn]['typography']['fontSize']) . ';';
1258 1258
                              }
1259 1259
 
1260
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261
-                                $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1260
+                              if (!empty($theme_settings['elements'][$hn]['typography']['fontFamily'])) {
1261
+                                $h_css .= 'font-family: ' . esc_attr($theme_settings['elements'][$hn]['typography']['fontFamily']) . ';';
1262 1262
                              }
1263 1263
 
1264
-                             if($h_css){
1265
-                                echo esc_attr( $bep  . $hn ) . '{'.esc_attr( $h_css ).'}';
1264
+                             if ($h_css) {
1265
+                                echo esc_attr($bep . $hn) . '{' . esc_attr($h_css) . '}';
1266 1266
                              }
1267 1267
                         }
1268 1268
                     }
1269 1269
 
1270 1270
                     // Pagination on Hello Elementor theme.
1271
-                    if ( function_exists( 'hello_elementor_setup' ) ) {
1271
+                    if (function_exists('hello_elementor_setup')) {
1272 1272
                         echo '.aui-nav-links .pagination{justify-content:inherit}';
1273 1273
                     }
1274 1274
                 ?>
@@ -1277,10 +1277,10 @@  discard block
 block discarded – undo
1277 1277
 			/*
1278 1278
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1279 1279
 			 */
1280
-			return str_replace( array(
1280
+			return str_replace(array(
1281 1281
 				'<style>',
1282 1282
 				'</style>'
1283
-			), '', self::minify_css( ob_get_clean() ) );
1283
+			), '', self::minify_css(ob_get_clean()));
1284 1284
 		}
1285 1285
 
1286 1286
 		/**
@@ -1288,34 +1288,34 @@  discard block
 block discarded – undo
1288 1288
 		 *
1289 1289
 		 * @return bool
1290 1290
 		 */
1291
-		public static function is_bs3_compat(){
1291
+		public static function is_bs3_compat() {
1292 1292
 			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1293 1293
 		}
1294 1294
 
1295
-		public static function hex_to_rgb( $hex ) {
1295
+		public static function hex_to_rgb($hex) {
1296 1296
 			// Remove '#' if present
1297
-			$hex = str_replace( '#', '', $hex );
1297
+			$hex = str_replace('#', '', $hex);
1298 1298
 
1299 1299
 			// Check if input is RGB
1300
-			if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) {
1301
-				$_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) );
1300
+			if (strpos($hex, 'rgba(') === 0 || strpos($hex, 'rgb(') === 0) {
1301
+				$_rgb = explode(',', str_replace(array('rgba(', 'rgb(', ')'), '', $hex));
1302 1302
 
1303
-				$rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ',';
1304
-				$rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ',';
1305
-				$rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' );
1303
+				$rgb = (isset($_rgb[0]) ? (int) trim($_rgb[0]) : '0') . ',';
1304
+				$rgb .= (isset($_rgb[1]) ? (int) trim($_rgb[1]) : '0') . ',';
1305
+				$rgb .= (isset($_rgb[2]) ? (int) trim($_rgb[2]) : '0');
1306 1306
 
1307 1307
 				return $rgb;
1308 1308
 			}
1309 1309
 
1310 1310
 			// Convert 3-digit hex to 6-digit hex
1311
-			if ( strlen( $hex ) == 3 ) {
1312
-				$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1311
+			if (strlen($hex) == 3) {
1312
+				$hex = str_repeat(substr($hex, 0, 1), 2) . str_repeat(substr($hex, 1, 1), 2) . str_repeat(substr($hex, 2, 1), 2);
1313 1313
 			}
1314 1314
 
1315 1315
 			// Convert hex to RGB
1316
-			$r = hexdec( substr( $hex, 0, 2 ) );
1317
-			$g = hexdec( substr( $hex, 2, 2 ) );
1318
-			$b = hexdec( substr( $hex, 4, 2 ) );
1316
+			$r = hexdec(substr($hex, 0, 2));
1317
+			$g = hexdec(substr($hex, 2, 2));
1318
+			$b = hexdec(substr($hex, 4, 2));
1319 1319
 
1320 1320
 			// Return RGB values as an array
1321 1321
 			return $r . ',' . $g . ',' . $b;
@@ -1330,13 +1330,13 @@  discard block
 block discarded – undo
1330 1330
 		 *
1331 1331
 		 * @return string
1332 1332
 		 */
1333
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1333
+		public static function css_overwrite_bs5($type, $color_code, $compatibility, $hex = '') {
1334 1334
 			global $aui_bs5;
1335 1335
 
1336 1336
 			$is_var = false;
1337 1337
 			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1338
-			if(!$color_code){return '';}
1339
-			if(strpos($color_code, 'var') !== false){
1338
+			if (!$color_code) {return ''; }
1339
+			if (strpos($color_code, 'var') !== false) {
1340 1340
 				//if(!sanitize_hex_color($color_code)){
1341 1341
 				$color_code = esc_attr($color_code);
1342 1342
 				$is_var = true;
@@ -1346,15 +1346,15 @@  discard block
 block discarded – undo
1346 1346
 
1347 1347
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1348 1348
 
1349
-			if(!$color_code){return '';}
1349
+			if (!$color_code) {return ''; }
1350 1350
 
1351 1351
 			$rgb = self::hex_to_rgb($hex);
1352 1352
 
1353
-			if($compatibility===true || $compatibility===1){
1353
+			if ($compatibility === true || $compatibility === 1) {
1354 1354
 				$compatibility = '.bsui';
1355
-			}elseif(!$compatibility){
1355
+			}elseif (!$compatibility) {
1356 1356
 				$compatibility = '';
1357
-			}else{
1357
+			} else {
1358 1358
 				$compatibility = esc_attr($compatibility);
1359 1359
 			}
1360 1360
 
@@ -1371,30 +1371,30 @@  discard block
 block discarded – undo
1371 1371
 			 * c = color, b = background color, o = border-color, f = fill
1372 1372
 			 */
1373 1373
 			$selectors = array(
1374
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1375
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1376
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1377
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1378
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1379
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1380
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1381
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1382
-				".badge-{$type}"                                            => array( 'b' ),
1383
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1384
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1385
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1386
-				".text-{$type}"                                     => array( 'c' ),
1374
+				".btn-{$type}"                                              => array('b', 'o'),
1375
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1376
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1377
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1378
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1379
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1380
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1381
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1382
+				".badge-{$type}"                                            => array('b'),
1383
+				".alert-{$type}"                                            => array('b', 'o'),
1384
+				".bg-{$type}"                                               => array('b', 'f'),
1385
+				".btn-link.btn-{$type}"                                     => array('c'),
1386
+				".text-{$type}"                                     => array('c'),
1387 1387
 			);
1388 1388
 
1389
-			if ( $aui_bs5 ) {
1390
-				unset($selectors[".alert-{$type}" ]);
1389
+			if ($aui_bs5) {
1390
+				unset($selectors[".alert-{$type}"]);
1391 1391
 			}
1392 1392
 
1393
-			if ( $type == 'primary' ) {
1393
+			if ($type == 'primary') {
1394 1394
 				$selectors = $selectors + array(
1395
-						'a'                                                                                                    => array( 'c' ),
1396
-						'.btn-link'                                                                                            => array( 'c' ),
1397
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1395
+						'a'                                                                                                    => array('c'),
1396
+						'.btn-link'                                                                                            => array('c'),
1397
+						'.dropdown-item.active'                                                                                => array('b'),
1398 1398
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1399 1399
 							'b',
1400 1400
 							'o'
@@ -1403,57 +1403,57 @@  discard block
 block discarded – undo
1403 1403
 							'b',
1404 1404
 							'o'
1405 1405
 						),
1406
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1407
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1408
-						'.page-link'                                                                                           => array( 'c' ),
1406
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1407
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1408
+						'.page-link'                                                                                           => array('c'),
1409 1409
 						'.page-item.active .page-link'                                                                         => array(
1410 1410
 							'b',
1411 1411
 							'o'
1412 1412
 						),
1413
-						'.progress-bar'                                                                                        => array( 'b' ),
1413
+						'.progress-bar'                                                                                        => array('b'),
1414 1414
 						'.list-group-item.active'                                                                              => array(
1415 1415
 							'b',
1416 1416
 							'o'
1417 1417
 						),
1418
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1418
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1419 1419
 					);
1420 1420
 			}
1421 1421
 
1422 1422
 
1423 1423
 
1424 1424
             // link
1425
-			if ( $type === 'primary' ) {
1426
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1427
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1428
-				$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).'; }';
1425
+			if ($type === 'primary') {
1426
+				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .75); --bs-link-color: var(--bs-' . esc_attr($type) . '); }';
1427
+				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: ' . esc_attr($color_code) . ';  }';
1428
+				$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) . '; }';
1429 1429
 
1430
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1431
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1430
+				$output .= $prefix . ' a{color: var(--bs-' . esc_attr($type) . ');}';
1431
+				$output .= $prefix . ' .text-primary{color: var(--bs-' . esc_attr($type) . ') !important;}';
1432 1432
 
1433 1433
                 // dropdown
1434
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1434
+				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-' . esc_attr($type) . '); --bs-dropdown-link-active-color: var(--bs-' . esc_attr($type) . ');}';
1435 1435
 
1436 1436
                 // pagination
1437
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1437
+				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-' . esc_attr($type) . '); --bs-pagination-active-bg: var(--bs-' . esc_attr($type) . ');}';
1438 1438
 
1439 1439
 			}
1440 1440
 
1441
-			$output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1442
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1441
+			$output .= $prefix . ' .link-' . esc_attr($type) . ' {color: var(--bs-' . esc_attr($type) . '-rgb) !important;}';
1442
+			$output .= $prefix . ' .link-' . esc_attr($type) . ':hover {color: rgba(var(--bs-' . esc_attr($type) . '-rgb), .8) !important;}';
1443 1443
 
1444 1444
 			//  buttons
1445
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1445
+			$output .= $prefix . ' .btn-' . esc_attr($type) . '{';
1446 1446
 			$output .= ' 
1447
-            --bs-btn-bg: '.esc_attr($color_code).';
1448
-            --bs-btn-border-color: '.esc_attr($color_code).';
1449
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1450
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1451
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1452
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1453
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1447
+            --bs-btn-bg: '.esc_attr($color_code) . ';
1448
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1449
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1450
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1451
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1452
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1453
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1454 1454
             --bs-btn-active-shadow: unset;
1455
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1456
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1455
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1456
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1457 1457
             ';
1458 1458
 //			$output .= '
1459 1459
 //		    --bs-btn-color: #fff;
@@ -1464,18 +1464,18 @@  discard block
 block discarded – undo
1464 1464
 			$output .= '}';
1465 1465
 
1466 1466
 			//  buttons outline
1467
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1467
+			$output .= $prefix . ' .btn-outline-' . esc_attr($type) . '{';
1468 1468
 			$output .= ' 
1469
-			--bs-btn-color: '.esc_attr($color_code).';
1470
-            --bs-btn-border-color: '.esc_attr($color_code).';
1471
-            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1472
-            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1473
-            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type).'-rgb;
1474
-            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1475
-            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
1469
+			--bs-btn-color: '.esc_attr($color_code) . ';
1470
+            --bs-btn-border-color: '.esc_attr($color_code) . ';
1471
+            --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1472
+            --bs-btn-hover-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1473
+            --bs-btn-focus-shadow-rgb: --bs-'.esc_attr($type) . '-rgb;
1474
+            --bs-btn-active-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1475
+            --bs-btn-active-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .9);
1476 1476
             --bs-btn-active-shadow: unset;
1477
-            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1478
-            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1477
+            --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type) . '-rgb), .5);
1478
+            --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type) . '-rgb), .1);
1479 1479
             ';
1480 1480
 //			$output .= '
1481 1481
 //		    --bs-btn-color: #fff;
@@ -1487,32 +1487,32 @@  discard block
 block discarded – undo
1487 1487
 
1488 1488
 
1489 1489
             // button hover
1490
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1490
+			$output .= $prefix . ' .btn-' . esc_attr($type) . ':hover{';
1491 1491
 			$output .= ' 
1492
-            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);
1492
+            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);
1493 1493
             }
1494 1494
             ';
1495 1495
 
1496 1496
 
1497
-			if ( $aui_bs5 ) {
1497
+			if ($aui_bs5) {
1498 1498
 //				$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).'; }';
1499
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1500
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1499
+				$output .= 'html body {--bs-' . esc_attr($type) . ': ' . esc_attr($color_code) . '; }';
1500
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1501 1501
 			}
1502 1502
 
1503 1503
 
1504
-			if ( $is_custom ) {
1504
+			if ($is_custom) {
1505 1505
 
1506 1506
 //				echo '###'.$type;exit;
1507 1507
 
1508 1508
 				// build rules into each type
1509
-				foreach($selectors as $selector => $types){
1510
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1511
-					$types = array_combine($types,$types);
1512
-					if(isset($types['c'])){$color[] = $selector;}
1513
-					if(isset($types['b'])){$background[] = $selector;}
1514
-					if(isset($types['o'])){$border[] = $selector;}
1515
-					if(isset($types['f'])){$fill[] = $selector;}
1509
+				foreach ($selectors as $selector => $types) {
1510
+					$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1511
+					$types = array_combine($types, $types);
1512
+					if (isset($types['c'])) {$color[] = $selector; }
1513
+					if (isset($types['b'])) {$background[] = $selector; }
1514
+					if (isset($types['o'])) {$border[] = $selector; }
1515
+					if (isset($types['f'])) {$fill[] = $selector; }
1516 1516
 				}
1517 1517
 
1518 1518
 //				// build rules into each type
@@ -1526,36 +1526,36 @@  discard block
 block discarded – undo
1526 1526
 //				}
1527 1527
 
1528 1528
 				// add any color rules
1529
-				if(!empty($color)){
1530
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1529
+				if (!empty($color)) {
1530
+					$output .= implode(",", $color) . "{color: $color_code;} ";
1531 1531
 				}
1532
-				if(!empty($color_i)){
1533
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1532
+				if (!empty($color_i)) {
1533
+					$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1534 1534
 				}
1535 1535
 
1536 1536
 				// add any background color rules
1537
-				if(!empty($background)){
1538
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1537
+				if (!empty($background)) {
1538
+					$output .= implode(",", $background) . "{background-color: $color_code;} ";
1539 1539
 				}
1540
-				if(!empty($background_i)){
1541
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1540
+				if (!empty($background_i)) {
1541
+					$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1542 1542
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1543 1543
 				}
1544 1544
 
1545 1545
 				// add any border color rules
1546
-				if(!empty($border)){
1547
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1546
+				if (!empty($border)) {
1547
+					$output .= implode(",", $border) . "{border-color: $color_code;} ";
1548 1548
 				}
1549
-				if(!empty($border_i)){
1550
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1549
+				if (!empty($border_i)) {
1550
+					$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1551 1551
 				}
1552 1552
 
1553 1553
 				// add any fill color rules
1554
-				if(!empty($fill)){
1555
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1554
+				if (!empty($fill)) {
1555
+					$output .= implode(",", $fill) . "{fill: $color_code;} ";
1556 1556
 				}
1557
-				if(!empty($fill_i)){
1558
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1557
+				if (!empty($fill_i)) {
1558
+					$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1559 1559
 				}
1560 1560
 
1561 1561
 			}
@@ -1565,26 +1565,26 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
 			$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;' : '';
1567 1567
 			// darken
1568
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1569
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1570
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1571
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1568
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1569
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1570
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1571
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1572 1572
 
1573 1573
 			// lighten
1574
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1574
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1575 1575
 
1576 1576
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1577
-			$op_25 = $color_code."40"; // 25% opacity
1577
+			$op_25 = $color_code . "40"; // 25% opacity
1578 1578
 
1579 1579
 
1580 1580
 			// button states
1581
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1582
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1581
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1582
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1583 1583
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1584
-			$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;} ";
1585
-			$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.";} ";
1586
-            $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;} ";
1587
-            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} ";
1584
+			$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;} ";
1585
+			$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 . ";} ";
1586
+            $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;} ";
1587
+            $output .= $prefix . " .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} ";
1588 1588
 
1589 1589
 			// text
1590 1590
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 //			}
1603 1603
 
1604 1604
 			// alerts
1605
-			if ( $aui_bs5 ) {
1605
+			if ($aui_bs5) {
1606 1606
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1607
-				$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;} ";
1607
+				$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;} ";
1608 1608
 			}
1609 1609
 
1610 1610
 			return $output;
@@ -1619,12 +1619,12 @@  discard block
 block discarded – undo
1619 1619
 		 *
1620 1620
 		 * @return string
1621 1621
 		 */
1622
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1622
+		public static function css_overwrite($type, $color_code, $compatibility, $hex = '') {
1623 1623
             global $aui_bs5;
1624 1624
 
1625 1625
 			$is_var = false;
1626
-			if(!$color_code){return '';}
1627
-			if(strpos($color_code, 'var') !== false){
1626
+			if (!$color_code) {return ''; }
1627
+			if (strpos($color_code, 'var') !== false) {
1628 1628
 				//if(!sanitize_hex_color($color_code)){
1629 1629
 				$color_code = esc_attr($color_code);
1630 1630
 				$is_var = true;
@@ -1634,15 +1634,15 @@  discard block
 block discarded – undo
1634 1634
 
1635 1635
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1636 1636
 
1637
-			if(!$color_code){return '';}
1637
+			if (!$color_code) {return ''; }
1638 1638
 
1639 1639
             $rgb = self::hex_to_rgb($hex);
1640 1640
 
1641
-			if($compatibility===true || $compatibility===1){
1641
+			if ($compatibility === true || $compatibility === 1) {
1642 1642
 				$compatibility = '.bsui';
1643
-			}elseif(!$compatibility){
1643
+			}elseif (!$compatibility) {
1644 1644
 				$compatibility = '';
1645
-			}else{
1645
+			} else {
1646 1646
 				$compatibility = esc_attr($compatibility);
1647 1647
 			}
1648 1648
 
@@ -1656,29 +1656,29 @@  discard block
 block discarded – undo
1656 1656
 			 * c = color, b = background color, o = border-color, f = fill
1657 1657
 			 */
1658 1658
 			$selectors = array(
1659
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1660
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1661
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1662
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1663
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1664
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1665
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1666
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1667
-				".badge-{$type}"                                            => array( 'b' ),
1668
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1669
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1670
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1659
+				".btn-{$type}"                                              => array('b', 'o'),
1660
+				".btn-{$type}.disabled"                                     => array('b', 'o'),
1661
+				".btn-{$type}:disabled"                                     => array('b', 'o'),
1662
+				".btn-outline-{$type}"                                      => array('c', 'o'),
1663
+				".btn-outline-{$type}:hover"                                => array('b', 'o'),
1664
+				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array('b', 'o'),
1665
+				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array('b', 'o'),
1666
+				".show>.btn-outline-{$type}.dropdown-toggle"                => array('b', 'o'),
1667
+				".badge-{$type}"                                            => array('b'),
1668
+				".alert-{$type}"                                            => array('b', 'o'),
1669
+				".bg-{$type}"                                               => array('b', 'f'),
1670
+				".btn-link.btn-{$type}"                                     => array('c'),
1671 1671
 			);
1672 1672
 
1673
-			if ( $aui_bs5 ) {
1674
-                unset($selectors[".alert-{$type}" ]);
1673
+			if ($aui_bs5) {
1674
+                unset($selectors[".alert-{$type}"]);
1675 1675
 			}
1676 1676
 
1677
-			if ( $type == 'primary' ) {
1677
+			if ($type == 'primary') {
1678 1678
 				$selectors = $selectors + array(
1679
-						'a'                                                                                                    => array( 'c' ),
1680
-						'.btn-link'                                                                                            => array( 'c' ),
1681
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1679
+						'a'                                                                                                    => array('c'),
1680
+						'.btn-link'                                                                                            => array('c'),
1681
+						'.dropdown-item.active'                                                                                => array('b'),
1682 1682
 						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1683 1683
 							'b',
1684 1684
 							'o'
@@ -1687,19 +1687,19 @@  discard block
 block discarded – undo
1687 1687
 							'b',
1688 1688
 							'o'
1689 1689
 						),
1690
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1691
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1692
-						'.page-link'                                                                                           => array( 'c' ),
1690
+						'.nav-pills .nav-link.active'                                                                          => array('b'),
1691
+						'.nav-pills .show>.nav-link'                                                                           => array('b'),
1692
+						'.page-link'                                                                                           => array('c'),
1693 1693
 						'.page-item.active .page-link'                                                                         => array(
1694 1694
 							'b',
1695 1695
 							'o'
1696 1696
 						),
1697
-						'.progress-bar'                                                                                        => array( 'b' ),
1697
+						'.progress-bar'                                                                                        => array('b'),
1698 1698
 						'.list-group-item.active'                                                                              => array(
1699 1699
 							'b',
1700 1700
 							'o'
1701 1701
 						),
1702
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1702
+						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1703 1703
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1704 1704
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1705 1705
 //				    '.custom-range::-ms-thumb' => array('b'),
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
 			}
1708 1708
 
1709 1709
 			$important_selectors = array(
1710
-				".bg-{$type}" => array('b','f'),
1710
+				".bg-{$type}" => array('b', 'f'),
1711 1711
 				".border-{$type}" => array('o'),
1712 1712
 				".text-{$type}" => array('c'),
1713 1713
 			);
@@ -1723,62 +1723,62 @@  discard block
 block discarded – undo
1723 1723
 
1724 1724
 			$output = '';
1725 1725
 
1726
-			if ( $aui_bs5 ) {
1726
+			if ($aui_bs5) {
1727 1727
 //				$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).'; }';
1728
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1728
+				$output .= 'html body {--bs-' . esc_attr($type) . '-rgb: ' . $rgb . '; }';
1729 1729
 			}
1730 1730
 
1731 1731
 			// build rules into each type
1732
-			foreach($selectors as $selector => $types){
1733
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1734
-				$types = array_combine($types,$types);
1735
-				if(isset($types['c'])){$color[] = $selector;}
1736
-				if(isset($types['b'])){$background[] = $selector;}
1737
-				if(isset($types['o'])){$border[] = $selector;}
1738
-				if(isset($types['f'])){$fill[] = $selector;}
1732
+			foreach ($selectors as $selector => $types) {
1733
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1734
+				$types = array_combine($types, $types);
1735
+				if (isset($types['c'])) {$color[] = $selector; }
1736
+				if (isset($types['b'])) {$background[] = $selector; }
1737
+				if (isset($types['o'])) {$border[] = $selector; }
1738
+				if (isset($types['f'])) {$fill[] = $selector; }
1739 1739
 			}
1740 1740
 
1741 1741
 			// build rules into each type
1742
-			foreach($important_selectors as $selector => $types){
1743
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1744
-				$types = array_combine($types,$types);
1745
-				if(isset($types['c'])){$color_i[] = $selector;}
1746
-				if(isset($types['b'])){$background_i[] = $selector;}
1747
-				if(isset($types['o'])){$border_i[] = $selector;}
1748
-				if(isset($types['f'])){$fill_i[] = $selector;}
1742
+			foreach ($important_selectors as $selector => $types) {
1743
+				$selector = $compatibility ? $compatibility . " " . $selector : $selector;
1744
+				$types = array_combine($types, $types);
1745
+				if (isset($types['c'])) {$color_i[] = $selector; }
1746
+				if (isset($types['b'])) {$background_i[] = $selector; }
1747
+				if (isset($types['o'])) {$border_i[] = $selector; }
1748
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1749 1749
 			}
1750 1750
 
1751 1751
 			// add any color rules
1752
-			if(!empty($color)){
1753
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1752
+			if (!empty($color)) {
1753
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1754 1754
 			}
1755
-			if(!empty($color_i)){
1756
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1755
+			if (!empty($color_i)) {
1756
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1757 1757
 			}
1758 1758
 
1759 1759
 			// add any background color rules
1760
-			if(!empty($background)){
1761
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1760
+			if (!empty($background)) {
1761
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1762 1762
 			}
1763
-			if(!empty($background_i)){
1764
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1763
+			if (!empty($background_i)) {
1764
+				$output .= $aui_bs5 ? '' : implode(",", $background_i) . "{background-color: $color_code !important;} ";
1765 1765
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1766 1766
 			}
1767 1767
 
1768 1768
 			// add any border color rules
1769
-			if(!empty($border)){
1770
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1769
+			if (!empty($border)) {
1770
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1771 1771
 			}
1772
-			if(!empty($border_i)){
1773
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1772
+			if (!empty($border_i)) {
1773
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1774 1774
 			}
1775 1775
 
1776 1776
 			// add any fill color rules
1777
-			if(!empty($fill)){
1778
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1777
+			if (!empty($fill)) {
1778
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1779 1779
 			}
1780
-			if(!empty($fill_i)){
1781
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1780
+			if (!empty($fill_i)) {
1781
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1782 1782
 			}
1783 1783
 
1784 1784
 
@@ -1786,27 +1786,27 @@  discard block
 block discarded – undo
1786 1786
 
1787 1787
 			$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;' : '';
1788 1788
 			// darken
1789
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1790
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1791
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1792
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1789
+			$darker_075 = $is_var ? $color_code . ';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code, "-0.075");
1790
+			$darker_10 = $is_var ? $color_code . ';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code, "-0.10");
1791
+			$darker_125 = $is_var ? $color_code . ';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code, "-0.125");
1792
+			$darker_40 = $is_var ? $color_code . ';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code, "-0.4");
1793 1793
 
1794 1794
 			// lighten
1795
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1795
+			$lighten_25 = $is_var ? $color_code . ';filter:brightness(1.25)' : self::css_hex_lighten_darken($color_code, "0.25");
1796 1796
 
1797 1797
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1798
-			$op_25 = $color_code."40"; // 25% opacity
1798
+			$op_25 = $color_code . "40"; // 25% opacity
1799 1799
 
1800 1800
 
1801 1801
 			// button states
1802
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1803
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1802
+			$output .= $is_var ? $prefix . " .btn-{$type}{{$transition }} " : '';
1803
+			$output .= $prefix . " .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1804 1804
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1805
-			$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;} ";
1806
-			$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.";} ";
1807
-			$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;} ";
1805
+			$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;} ";
1806
+			$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 . ";} ";
1807
+			$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;} ";
1808 1808
 
1809
-			if ( $type == 'primary' ) {
1809
+			if ($type == 'primary') {
1810 1810
 				// dropdown's
1811 1811
 				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1812 1812
 
@@ -1818,9 +1818,9 @@  discard block
 block discarded – undo
1818 1818
 			}
1819 1819
 
1820 1820
             // alerts
1821
-			if ( $aui_bs5 ) {
1821
+			if ($aui_bs5) {
1822 1822
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1823
-				$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;} ";
1823
+				$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;} ";
1824 1824
 			}
1825 1825
 
1826 1826
 			return $output;
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 		 *
1837 1837
 		 * @return string
1838 1838
 		 */
1839
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1839
+		public static function css_primary($color_code, $compatibility, $use_variable = false) {
1840 1840
 
1841
-			if(!$use_variable){
1841
+			if (!$use_variable) {
1842 1842
 				$color_code = sanitize_hex_color($color_code);
1843
-				if(!$color_code){return '';}
1843
+				if (!$color_code) {return ''; }
1844 1844
 			}
1845 1845
 
1846 1846
 			/**
@@ -1848,36 +1848,36 @@  discard block
 block discarded – undo
1848 1848
 			 */
1849 1849
 			$selectors = array(
1850 1850
 				'a' => array('c'),
1851
-				'.btn-primary' => array('b','o'),
1852
-				'.btn-primary.disabled' => array('b','o'),
1853
-				'.btn-primary:disabled' => array('b','o'),
1854
-				'.btn-outline-primary' => array('c','o'),
1855
-				'.btn-outline-primary:hover' => array('b','o'),
1856
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1857
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1858
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1851
+				'.btn-primary' => array('b', 'o'),
1852
+				'.btn-primary.disabled' => array('b', 'o'),
1853
+				'.btn-primary:disabled' => array('b', 'o'),
1854
+				'.btn-outline-primary' => array('c', 'o'),
1855
+				'.btn-outline-primary:hover' => array('b', 'o'),
1856
+				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'),
1857
+				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'),
1858
+				'.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'),
1859 1859
 				'.btn-link' => array('c'),
1860 1860
 				'.dropdown-item.active' => array('b'),
1861
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1862
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1861
+				'.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'),
1862
+				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'),
1863 1863
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1864 1864
 //				'.custom-range::-moz-range-thumb' => array('b'),
1865 1865
 //				'.custom-range::-ms-thumb' => array('b'),
1866 1866
 				'.nav-pills .nav-link.active' => array('b'),
1867 1867
 				'.nav-pills .show>.nav-link' => array('b'),
1868 1868
 				'.page-link' => array('c'),
1869
-				'.page-item.active .page-link' => array('b','o'),
1869
+				'.page-item.active .page-link' => array('b', 'o'),
1870 1870
 				'.badge-primary' => array('b'),
1871
-				'.alert-primary' => array('b','o'),
1871
+				'.alert-primary' => array('b', 'o'),
1872 1872
 				'.progress-bar' => array('b'),
1873
-				'.list-group-item.active' => array('b','o'),
1874
-				'.bg-primary' => array('b','f'),
1873
+				'.list-group-item.active' => array('b', 'o'),
1874
+				'.bg-primary' => array('b', 'f'),
1875 1875
 				'.btn-link.btn-primary' => array('c'),
1876 1876
 				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1877 1877
 			);
1878 1878
 
1879 1879
 			$important_selectors = array(
1880
-				'.bg-primary' => array('b','f'),
1880
+				'.bg-primary' => array('b', 'f'),
1881 1881
 				'.border-primary' => array('o'),
1882 1882
 				'.text-primary' => array('c'),
1883 1883
 			);
@@ -1894,88 +1894,88 @@  discard block
 block discarded – undo
1894 1894
 			$output = '';
1895 1895
 
1896 1896
 			// build rules into each type
1897
-			foreach($selectors as $selector => $types){
1898
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1899
-				$types = array_combine($types,$types);
1900
-				if(isset($types['c'])){$color[] = $selector;}
1901
-				if(isset($types['b'])){$background[] = $selector;}
1902
-				if(isset($types['o'])){$border[] = $selector;}
1903
-				if(isset($types['f'])){$fill[] = $selector;}
1897
+			foreach ($selectors as $selector => $types) {
1898
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1899
+				$types = array_combine($types, $types);
1900
+				if (isset($types['c'])) {$color[] = $selector; }
1901
+				if (isset($types['b'])) {$background[] = $selector; }
1902
+				if (isset($types['o'])) {$border[] = $selector; }
1903
+				if (isset($types['f'])) {$fill[] = $selector; }
1904 1904
 			}
1905 1905
 
1906 1906
 			// build rules into each type
1907
-			foreach($important_selectors as $selector => $types){
1908
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1909
-				$types = array_combine($types,$types);
1910
-				if(isset($types['c'])){$color_i[] = $selector;}
1911
-				if(isset($types['b'])){$background_i[] = $selector;}
1912
-				if(isset($types['o'])){$border_i[] = $selector;}
1913
-				if(isset($types['f'])){$fill_i[] = $selector;}
1907
+			foreach ($important_selectors as $selector => $types) {
1908
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1909
+				$types = array_combine($types, $types);
1910
+				if (isset($types['c'])) {$color_i[] = $selector; }
1911
+				if (isset($types['b'])) {$background_i[] = $selector; }
1912
+				if (isset($types['o'])) {$border_i[] = $selector; }
1913
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1914 1914
 			}
1915 1915
 
1916 1916
 			// add any color rules
1917
-			if(!empty($color)){
1918
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1917
+			if (!empty($color)) {
1918
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1919 1919
 			}
1920
-			if(!empty($color_i)){
1921
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1920
+			if (!empty($color_i)) {
1921
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1922 1922
 			}
1923 1923
 
1924 1924
 			// add any background color rules
1925
-			if(!empty($background)){
1926
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1925
+			if (!empty($background)) {
1926
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1927 1927
 			}
1928
-			if(!empty($background_i)){
1929
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1928
+			if (!empty($background_i)) {
1929
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
1930 1930
 			}
1931 1931
 
1932 1932
 			// add any border color rules
1933
-			if(!empty($border)){
1934
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1933
+			if (!empty($border)) {
1934
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1935 1935
 			}
1936
-			if(!empty($border_i)){
1937
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1936
+			if (!empty($border_i)) {
1937
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1938 1938
 			}
1939 1939
 
1940 1940
 			// add any fill color rules
1941
-			if(!empty($fill)){
1942
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1941
+			if (!empty($fill)) {
1942
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1943 1943
 			}
1944
-			if(!empty($fill_i)){
1945
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1944
+			if (!empty($fill_i)) {
1945
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1946 1946
 			}
1947 1947
 
1948 1948
 
1949 1949
 			$prefix = $compatibility ? ".bsui " : "";
1950 1950
 
1951 1951
 			// darken
1952
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1953
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1954
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1952
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
1953
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
1954
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
1955 1955
 
1956 1956
 			// lighten
1957
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1957
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
1958 1958
 
1959 1959
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1960
-			$op_25 = $color_code."40"; // 25% opacity
1960
+			$op_25 = $color_code . "40"; // 25% opacity
1961 1961
 
1962 1962
 
1963 1963
 			// button states
1964
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1965
-			$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;} ";
1966
-			$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.";} ";
1967
-			$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;} ";
1964
+			$output .= $prefix . " .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1965
+			$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;} ";
1966
+			$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 . ";} ";
1967
+			$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;} ";
1968 1968
 
1969 1969
 
1970 1970
 			// dropdown's
1971
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1971
+			$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1972 1972
 
1973 1973
 
1974 1974
 			// input states
1975
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1975
+			$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1976 1976
 
1977 1977
 			// page link
1978
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1978
+			$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1979 1979
 
1980 1980
 			return $output;
1981 1981
 		}
@@ -1989,30 +1989,30 @@  discard block
 block discarded – undo
1989 1989
 		 *
1990 1990
 		 * @return string
1991 1991
 		 */
1992
-		public static function css_secondary($color_code,$compatibility){;
1992
+		public static function css_secondary($color_code, $compatibility) {;
1993 1993
 			$color_code = sanitize_hex_color($color_code);
1994
-			if(!$color_code){return '';}
1994
+			if (!$color_code) {return ''; }
1995 1995
 			/**
1996 1996
 			 * c = color, b = background color, o = border-color, f = fill
1997 1997
 			 */
1998 1998
 			$selectors = array(
1999
-				'.btn-secondary' => array('b','o'),
2000
-				'.btn-secondary.disabled' => array('b','o'),
2001
-				'.btn-secondary:disabled' => array('b','o'),
2002
-				'.btn-outline-secondary' => array('c','o'),
2003
-				'.btn-outline-secondary:hover' => array('b','o'),
1999
+				'.btn-secondary' => array('b', 'o'),
2000
+				'.btn-secondary.disabled' => array('b', 'o'),
2001
+				'.btn-secondary:disabled' => array('b', 'o'),
2002
+				'.btn-outline-secondary' => array('c', 'o'),
2003
+				'.btn-outline-secondary:hover' => array('b', 'o'),
2004 2004
 				'.btn-outline-secondary.disabled' => array('c'),
2005 2005
 				'.btn-outline-secondary:disabled' => array('c'),
2006
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2007
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2008
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2006
+				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'),
2007
+				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'),
2008
+				'.btn-outline-secondary.dropdown-toggle' => array('b', 'o'),
2009 2009
 				'.badge-secondary' => array('b'),
2010
-				'.alert-secondary' => array('b','o'),
2010
+				'.alert-secondary' => array('b', 'o'),
2011 2011
 				'.btn-link.btn-secondary' => array('c'),
2012 2012
 			);
2013 2013
 
2014 2014
 			$important_selectors = array(
2015
-				'.bg-secondary' => array('b','f'),
2015
+				'.bg-secondary' => array('b', 'f'),
2016 2016
 				'.border-secondary' => array('o'),
2017 2017
 				'.text-secondary' => array('c'),
2018 2018
 			);
@@ -2029,77 +2029,77 @@  discard block
 block discarded – undo
2029 2029
 			$output = '';
2030 2030
 
2031 2031
 			// build rules into each type
2032
-			foreach($selectors as $selector => $types){
2033
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2034
-				$types = array_combine($types,$types);
2035
-				if(isset($types['c'])){$color[] = $selector;}
2036
-				if(isset($types['b'])){$background[] = $selector;}
2037
-				if(isset($types['o'])){$border[] = $selector;}
2038
-				if(isset($types['f'])){$fill[] = $selector;}
2032
+			foreach ($selectors as $selector => $types) {
2033
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2034
+				$types = array_combine($types, $types);
2035
+				if (isset($types['c'])) {$color[] = $selector; }
2036
+				if (isset($types['b'])) {$background[] = $selector; }
2037
+				if (isset($types['o'])) {$border[] = $selector; }
2038
+				if (isset($types['f'])) {$fill[] = $selector; }
2039 2039
 			}
2040 2040
 
2041 2041
 			// build rules into each type
2042
-			foreach($important_selectors as $selector => $types){
2043
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2044
-				$types = array_combine($types,$types);
2045
-				if(isset($types['c'])){$color_i[] = $selector;}
2046
-				if(isset($types['b'])){$background_i[] = $selector;}
2047
-				if(isset($types['o'])){$border_i[] = $selector;}
2048
-				if(isset($types['f'])){$fill_i[] = $selector;}
2042
+			foreach ($important_selectors as $selector => $types) {
2043
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
2044
+				$types = array_combine($types, $types);
2045
+				if (isset($types['c'])) {$color_i[] = $selector; }
2046
+				if (isset($types['b'])) {$background_i[] = $selector; }
2047
+				if (isset($types['o'])) {$border_i[] = $selector; }
2048
+				if (isset($types['f'])) {$fill_i[] = $selector; }
2049 2049
 			}
2050 2050
 
2051 2051
 			// add any color rules
2052
-			if(!empty($color)){
2053
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2052
+			if (!empty($color)) {
2053
+				$output .= implode(",", $color) . "{color: $color_code;} ";
2054 2054
 			}
2055
-			if(!empty($color_i)){
2056
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2055
+			if (!empty($color_i)) {
2056
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
2057 2057
 			}
2058 2058
 
2059 2059
 			// add any background color rules
2060
-			if(!empty($background)){
2061
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2060
+			if (!empty($background)) {
2061
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
2062 2062
 			}
2063
-			if(!empty($background_i)){
2064
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2063
+			if (!empty($background_i)) {
2064
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
2065 2065
 			}
2066 2066
 
2067 2067
 			// add any border color rules
2068
-			if(!empty($border)){
2069
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2068
+			if (!empty($border)) {
2069
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
2070 2070
 			}
2071
-			if(!empty($border_i)){
2072
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2071
+			if (!empty($border_i)) {
2072
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
2073 2073
 			}
2074 2074
 
2075 2075
 			// add any fill color rules
2076
-			if(!empty($fill)){
2077
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2076
+			if (!empty($fill)) {
2077
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
2078 2078
 			}
2079
-			if(!empty($fill_i)){
2080
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2079
+			if (!empty($fill_i)) {
2080
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
2081 2081
 			}
2082 2082
 
2083 2083
 
2084 2084
 			$prefix = $compatibility ? ".bsui " : "";
2085 2085
 
2086 2086
 			// darken
2087
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2088
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2089
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2087
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
2088
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
2089
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
2090 2090
 
2091 2091
 			// lighten
2092
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2092
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
2093 2093
 
2094 2094
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
2095
-			$op_25 = $color_code."40"; // 25% opacity
2095
+			$op_25 = $color_code . "40"; // 25% opacity
2096 2096
 
2097 2097
 
2098 2098
 			// button states
2099
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2100
-			$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;} ";
2101
-			$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.";} ";
2102
-			$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;} ";
2099
+			$output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
2100
+			$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;} ";
2101
+			$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 . ";} ";
2102
+			$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;} ";
2103 2103
 
2104 2104
 
2105 2105
 			return $output;
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
 		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2117 2117
 			$hexCode = ltrim($hexCode, '#');
2118 2118
 
2119
-			if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) {
2119
+			if (strpos($hexCode, 'rgba(') !== false || strpos($hexCode, 'rgb(') !== false) {
2120 2120
 				return $hexCode;
2121 2121
 			}
2122 2122
 
@@ -2139,8 +2139,8 @@  discard block
 block discarded – undo
2139 2139
 		/**
2140 2140
 		 * Check if we should display examples.
2141 2141
 		 */
2142
-		public function maybe_show_examples(){
2143
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2142
+		public function maybe_show_examples() {
2143
+			if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
2144 2144
 				echo "<head>";
2145 2145
 				wp_head();
2146 2146
 				echo "</head>";
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
 		 *
2157 2157
 		 * @return string
2158 2158
 		 */
2159
-		public function get_examples(){
2159
+		public function get_examples() {
2160 2160
 			$output = '';
2161 2161
 
2162 2162
 
@@ -2262,74 +2262,74 @@  discard block
 block discarded – undo
2262 2262
 		 */
2263 2263
 		public static function calendar_params() {
2264 2264
 			$params = array(
2265
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2266
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2267
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2268
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2269
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2270
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2271
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2272
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2273
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2274
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2275
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2276
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2277
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2278
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2279
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2280
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2281
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2282
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2283
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2284
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2285
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2286
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2287
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2288
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2289
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2290
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2291
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2292
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2293
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2294
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2295
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2296
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2297
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2298
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2299
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2300
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2301
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2302
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2303
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2304
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2305
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2306
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2307
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2308
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2309
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2310
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2311
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2312
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2313
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2314
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2315
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2316
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2317
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2318
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2319
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2320
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2321
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2265
+				'month_long_1' => __('January', 'ayecode-connect'),
2266
+				'month_long_2' => __('February', 'ayecode-connect'),
2267
+				'month_long_3' => __('March', 'ayecode-connect'),
2268
+				'month_long_4' => __('April', 'ayecode-connect'),
2269
+				'month_long_5' => __('May', 'ayecode-connect'),
2270
+				'month_long_6' => __('June', 'ayecode-connect'),
2271
+				'month_long_7' => __('July', 'ayecode-connect'),
2272
+				'month_long_8' => __('August', 'ayecode-connect'),
2273
+				'month_long_9' => __('September', 'ayecode-connect'),
2274
+				'month_long_10' => __('October', 'ayecode-connect'),
2275
+				'month_long_11' => __('November', 'ayecode-connect'),
2276
+				'month_long_12' => __('December', 'ayecode-connect'),
2277
+				'month_s_1' => _x('Jan', 'January abbreviation', 'ayecode-connect'),
2278
+				'month_s_2' => _x('Feb', 'February abbreviation', 'ayecode-connect'),
2279
+				'month_s_3' => _x('Mar', 'March abbreviation', 'ayecode-connect'),
2280
+				'month_s_4' => _x('Apr', 'April abbreviation', 'ayecode-connect'),
2281
+				'month_s_5' => _x('May', 'May abbreviation', 'ayecode-connect'),
2282
+				'month_s_6' => _x('Jun', 'June abbreviation', 'ayecode-connect'),
2283
+				'month_s_7' => _x('Jul', 'July abbreviation', 'ayecode-connect'),
2284
+				'month_s_8' => _x('Aug', 'August abbreviation', 'ayecode-connect'),
2285
+				'month_s_9' => _x('Sep', 'September abbreviation', 'ayecode-connect'),
2286
+				'month_s_10' => _x('Oct', 'October abbreviation', 'ayecode-connect'),
2287
+				'month_s_11' => _x('Nov', 'November abbreviation', 'ayecode-connect'),
2288
+				'month_s_12' => _x('Dec', 'December abbreviation', 'ayecode-connect'),
2289
+				'day_s1_1' => _x('S', 'Sunday initial', 'ayecode-connect'),
2290
+				'day_s1_2' => _x('M', 'Monday initial', 'ayecode-connect'),
2291
+				'day_s1_3' => _x('T', 'Tuesday initial', 'ayecode-connect'),
2292
+				'day_s1_4' => _x('W', 'Wednesday initial', 'ayecode-connect'),
2293
+				'day_s1_5' => _x('T', 'Friday initial', 'ayecode-connect'),
2294
+				'day_s1_6' => _x('F', 'Thursday initial', 'ayecode-connect'),
2295
+				'day_s1_7' => _x('S', 'Saturday initial', 'ayecode-connect'),
2296
+				'day_s2_1' => __('Su', 'ayecode-connect'),
2297
+				'day_s2_2' => __('Mo', 'ayecode-connect'),
2298
+				'day_s2_3' => __('Tu', 'ayecode-connect'),
2299
+				'day_s2_4' => __('We', 'ayecode-connect'),
2300
+				'day_s2_5' => __('Th', 'ayecode-connect'),
2301
+				'day_s2_6' => __('Fr', 'ayecode-connect'),
2302
+				'day_s2_7' => __('Sa', 'ayecode-connect'),
2303
+				'day_s3_1' => __('Sun', 'ayecode-connect'),
2304
+				'day_s3_2' => __('Mon', 'ayecode-connect'),
2305
+				'day_s3_3' => __('Tue', 'ayecode-connect'),
2306
+				'day_s3_4' => __('Wed', 'ayecode-connect'),
2307
+				'day_s3_5' => __('Thu', 'ayecode-connect'),
2308
+				'day_s3_6' => __('Fri', 'ayecode-connect'),
2309
+				'day_s3_7' => __('Sat', 'ayecode-connect'),
2310
+				'day_s5_1' => __('Sunday', 'ayecode-connect'),
2311
+				'day_s5_2' => __('Monday', 'ayecode-connect'),
2312
+				'day_s5_3' => __('Tuesday', 'ayecode-connect'),
2313
+				'day_s5_4' => __('Wednesday', 'ayecode-connect'),
2314
+				'day_s5_5' => __('Thursday', 'ayecode-connect'),
2315
+				'day_s5_6' => __('Friday', 'ayecode-connect'),
2316
+				'day_s5_7' => __('Saturday', 'ayecode-connect'),
2317
+				'am_lower' => __('am', 'ayecode-connect'),
2318
+				'pm_lower' => __('pm', 'ayecode-connect'),
2319
+				'am_upper' => __('AM', 'ayecode-connect'),
2320
+				'pm_upper' => __('PM', 'ayecode-connect'),
2321
+				'firstDayOfWeek' => (int) get_option('start_of_week'),
2322 2322
 				'time_24hr' => false,
2323
-				'year' => __( 'Year', 'ayecode-connect' ),
2324
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2325
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2326
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2327
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2328
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2329
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2323
+				'year' => __('Year', 'ayecode-connect'),
2324
+				'hour' => __('Hour', 'ayecode-connect'),
2325
+				'minute' => __('Minute', 'ayecode-connect'),
2326
+				'weekAbbreviation' => __('Wk', 'ayecode-connect'),
2327
+				'rangeSeparator' => __(' to ', 'ayecode-connect'),
2328
+				'scrollTitle' => __('Scroll to increment', 'ayecode-connect'),
2329
+				'toggleTitle' => __('Click to toggle', 'ayecode-connect')
2330 2330
 			);
2331 2331
 
2332
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2332
+			return apply_filters('ayecode_ui_calendar_params', $params);
2333 2333
 		}
2334 2334
 
2335 2335
 		/**
@@ -2342,47 +2342,47 @@  discard block
 block discarded – undo
2342 2342
 		public static function flatpickr_locale() {
2343 2343
 			$params = self::calendar_params();
2344 2344
 
2345
-			if ( is_string( $params ) ) {
2346
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2345
+			if (is_string($params)) {
2346
+				$params = html_entity_decode($params, ENT_QUOTES, 'UTF-8');
2347 2347
 			} else {
2348
-				foreach ( (array) $params as $key => $value ) {
2349
-					if ( ! is_scalar( $value ) ) {
2348
+				foreach ((array) $params as $key => $value) {
2349
+					if (!is_scalar($value)) {
2350 2350
 						continue;
2351 2351
 					}
2352 2352
 
2353
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2353
+					$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2354 2354
 				}
2355 2355
 			}
2356 2356
 
2357 2357
 			$day_s3 = array();
2358 2358
 			$day_s5 = array();
2359 2359
 
2360
-			for ( $i = 1; $i <= 7; $i ++ ) {
2361
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2360
+			for ($i = 1; $i <= 7; $i++) {
2361
+				$day_s3[] = addslashes($params['day_s3_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
+				$day_s5[] = addslashes($params['day_s3_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2363 2363
 			}
2364 2364
 
2365 2365
 			$month_s = array();
2366 2366
 			$month_long = array();
2367 2367
 
2368
-			for ( $i = 1; $i <= 12; $i ++ ) {
2369
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2368
+			for ($i = 1; $i <= 12; $i++) {
2369
+				$month_s[] = addslashes($params['month_s_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
+				$month_long[] = addslashes($params['month_long_' . $i]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2371 2371
 			}
2372 2372
 
2373 2373
 			ob_start();
2374
-		if ( 0 ) { ?><script><?php } ?>
2374
+		if (0) { ?><script><?php } ?>
2375 2375
                 {
2376 2376
                     weekdays: {
2377
-                        shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2378
-                            longhand: ['<?php echo implode( "','", $day_s5 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2377
+                        shorthand: ['<?php echo implode("','", $day_s3); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2378
+                            longhand: ['<?php echo implode("','", $day_s5); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2379 2379
                     },
2380 2380
                     months: {
2381
-                        shorthand: ['<?php echo implode( "','", $month_s ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2382
-                            longhand: ['<?php echo implode( "','", $month_long ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2381
+                        shorthand: ['<?php echo implode("','", $month_s); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2382
+                            longhand: ['<?php echo implode("','", $month_long); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
2383 2383
                     },
2384 2384
                     daysInMonth: [31,28,31,30,31,30,31,31,30,31,30,31],
2385
-                        firstDayOfWeek: <?php echo (int) $params[ 'firstDayOfWeek' ]; ?>,
2385
+                        firstDayOfWeek: <?php echo (int) $params['firstDayOfWeek']; ?>,
2386 2386
                     ordinal: function (nth) {
2387 2387
                         var s = nth % 100;
2388 2388
                         if (s > 3 && s < 21)
@@ -2398,21 +2398,21 @@  discard block
 block discarded – undo
2398 2398
                                 return "th";
2399 2399
                         }
2400 2400
                     },
2401
-                    rangeSeparator: '<?php echo esc_attr( $params[ 'rangeSeparator' ] ); ?>',
2402
-                        weekAbbreviation: '<?php echo esc_attr( $params[ 'weekAbbreviation' ] ); ?>',
2403
-                    scrollTitle: '<?php echo esc_attr( $params[ 'scrollTitle' ] ); ?>',
2404
-                    toggleTitle: '<?php echo esc_attr( $params[ 'toggleTitle' ] ); ?>',
2405
-                    amPM: ['<?php echo esc_attr( $params[ 'am_upper' ] ); ?>','<?php echo esc_attr( $params[ 'pm_upper' ] ); ?>'],
2406
-                    yearAriaLabel: '<?php echo esc_attr( $params[ 'year' ] ); ?>',
2407
-                    hourAriaLabel: '<?php echo esc_attr( $params[ 'hour' ] ); ?>',
2408
-                    minuteAriaLabel: '<?php echo esc_attr( $params[ 'minute' ] ); ?>',
2409
-                    time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?>
2401
+                    rangeSeparator: '<?php echo esc_attr($params['rangeSeparator']); ?>',
2402
+                        weekAbbreviation: '<?php echo esc_attr($params['weekAbbreviation']); ?>',
2403
+                    scrollTitle: '<?php echo esc_attr($params['scrollTitle']); ?>',
2404
+                    toggleTitle: '<?php echo esc_attr($params['toggleTitle']); ?>',
2405
+                    amPM: ['<?php echo esc_attr($params['am_upper']); ?>','<?php echo esc_attr($params['pm_upper']); ?>'],
2406
+                    yearAriaLabel: '<?php echo esc_attr($params['year']); ?>',
2407
+                    hourAriaLabel: '<?php echo esc_attr($params['hour']); ?>',
2408
+                    minuteAriaLabel: '<?php echo esc_attr($params['minute']); ?>',
2409
+                    time_24hr: <?php echo ($params['time_24hr'] ? 'true' : 'false'); ?>
2410 2410
                 }
2411
-				<?php if ( 0 ) { ?></script><?php } ?>
2411
+				<?php if (0) { ?></script><?php } ?>
2412 2412
 			<?php
2413 2413
 			$locale = ob_get_clean();
2414 2414
 
2415
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2415
+			return apply_filters('ayecode_ui_flatpickr_locale', trim($locale));
2416 2416
 		}
2417 2417
 
2418 2418
 		/**
@@ -2424,20 +2424,20 @@  discard block
 block discarded – undo
2424 2424
 		 */
2425 2425
 		public static function select2_params() {
2426 2426
 			$params = array(
2427
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2428
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2429
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2430
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2431
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2432
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2433
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2434
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2435
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2436
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2437
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2427
+				'i18n_select_state_text'    => esc_attr__('Select an option&hellip;', 'ayecode-connect'),
2428
+				'i18n_no_matches'           => _x('No matches found', 'enhanced select', 'ayecode-connect'),
2429
+				'i18n_ajax_error'           => _x('Loading failed', 'enhanced select', 'ayecode-connect'),
2430
+				'i18n_input_too_short_1'    => _x('Please enter 1 or more characters', 'enhanced select', 'ayecode-connect'),
2431
+				'i18n_input_too_short_n'    => _x('Please enter %item% or more characters', 'enhanced select', 'ayecode-connect'),
2432
+				'i18n_input_too_long_1'     => _x('Please delete 1 character', 'enhanced select', 'ayecode-connect'),
2433
+				'i18n_input_too_long_n'     => _x('Please delete %item% characters', 'enhanced select', 'ayecode-connect'),
2434
+				'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'ayecode-connect'),
2435
+				'i18n_selection_too_long_n' => _x('You can only select %item% items', 'enhanced select', 'ayecode-connect'),
2436
+				'i18n_load_more'            => _x('Loading more results&hellip;', 'enhanced select', 'ayecode-connect'),
2437
+				'i18n_searching'            => _x('Searching&hellip;', 'enhanced select', 'ayecode-connect')
2438 2438
 			);
2439 2439
 
2440
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2440
+			return apply_filters('ayecode_ui_select2_params', $params);
2441 2441
 		}
2442 2442
 
2443 2443
 		/**
@@ -2450,17 +2450,17 @@  discard block
 block discarded – undo
2450 2450
 		public static function select2_locale() {
2451 2451
 			$params = self::select2_params();
2452 2452
 
2453
-			foreach ( (array) $params as $key => $value ) {
2454
-				if ( ! is_scalar( $value ) ) {
2453
+			foreach ((array) $params as $key => $value) {
2454
+				if (!is_scalar($value)) {
2455 2455
 					continue;
2456 2456
 				}
2457 2457
 
2458
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2458
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2459 2459
 			}
2460 2460
 
2461
-			$locale = json_encode( $params );
2461
+			$locale = json_encode($params);
2462 2462
 
2463
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2463
+			return apply_filters('ayecode_ui_select2_locale', trim($locale));
2464 2464
 		}
2465 2465
 
2466 2466
 		/**
@@ -2473,35 +2473,35 @@  discard block
 block discarded – undo
2473 2473
 		public static function timeago_locale() {
2474 2474
 			$params = array(
2475 2475
 				'prefix_ago' => '',
2476
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2477
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2476
+				'suffix_ago' => ' ' . _x('ago', 'time ago', 'ayecode-connect'),
2477
+				'prefix_after' => _x('after', 'time ago', 'ayecode-connect') . ' ',
2478 2478
 				'suffix_after' => '',
2479
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2480
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2481
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2482
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2483
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2484
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2485
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2486
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2487
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2488
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2489
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2479
+				'seconds' => _x('less than a minute', 'time ago', 'ayecode-connect'),
2480
+				'minute' => _x('about a minute', 'time ago', 'ayecode-connect'),
2481
+				'minutes' => _x('%d minutes', 'time ago', 'ayecode-connect'),
2482
+				'hour' => _x('about an hour', 'time ago', 'ayecode-connect'),
2483
+				'hours' => _x('about %d hours', 'time ago', 'ayecode-connect'),
2484
+				'day' => _x('a day', 'time ago', 'ayecode-connect'),
2485
+				'days' => _x('%d days', 'time ago', 'ayecode-connect'),
2486
+				'month' => _x('about a month', 'time ago', 'ayecode-connect'),
2487
+				'months' => _x('%d months', 'time ago', 'ayecode-connect'),
2488
+				'year' => _x('about a year', 'time ago', 'ayecode-connect'),
2489
+				'years' => _x('%d years', 'time ago', 'ayecode-connect'),
2490 2490
 			);
2491 2491
 
2492
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2492
+			$params = apply_filters('ayecode_ui_timeago_params', $params);
2493 2493
 
2494
-			foreach ( (array) $params as $key => $value ) {
2495
-				if ( ! is_scalar( $value ) ) {
2494
+			foreach ((array) $params as $key => $value) {
2495
+				if (!is_scalar($value)) {
2496 2496
 					continue;
2497 2497
 				}
2498 2498
 
2499
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2499
+				$params[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
2500 2500
 			}
2501 2501
 
2502
-			$locale = json_encode( $params );
2502
+			$locale = json_encode($params);
2503 2503
 
2504
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2504
+			return apply_filters('ayecode_ui_timeago_locale', trim($locale));
2505 2505
 		}
2506 2506
 
2507 2507
 		/**
@@ -2512,7 +2512,7 @@  discard block
 block discarded – undo
2512 2512
 		 * @return mixed
2513 2513
 		 */
2514 2514
 		public static function minify_js($input) {
2515
-			if(trim($input) === "") return $input;
2515
+			if (trim($input) === "") return $input;
2516 2516
 			return preg_replace(
2517 2517
 				array(
2518 2518
 					// Remove comment(s)
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 		 * @return mixed
2545 2545
 		 */
2546 2546
 		public static function minify_css($input) {
2547
-			if(trim($input) === "") return $input;
2547
+			if (trim($input) === "") return $input;
2548 2548
 			return preg_replace(
2549 2549
 				array(
2550 2550
 					// Remove comment(s)
@@ -3110,12 +3110,12 @@  discard block
 block discarded – undo
3110 3110
                         });
3111 3111
                     }
3112 3112
                 }
3113
-				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3113
+				<?php do_action('aui_conditional_fields_js', $this); ?>
3114 3114
             </script>
3115 3115
 			<?php
3116 3116
 			$output = ob_get_clean();
3117 3117
 
3118
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3118
+			return str_replace(array('<script>', '</script>'), '', self::minify_js($output));
3119 3119
 		}
3120 3120
 	}
3121 3121
 
Please login to merge, or discard this patch.
Indentation   +1975 added lines, -1975 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,480 +21,480 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '0.2.26';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "5.2.2";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-
92
-		/**
93
-		 * Main AyeCode_UI_Settings Instance.
94
-		 *
95
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
-		 *
97
-		 * @since 1.0.0
98
-		 * @static
99
-		 * @return AyeCode_UI_Settings - Main instance.
100
-		 */
101
-		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
-
104
-				self::$instance = new AyeCode_UI_Settings;
105
-
106
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
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' ) );
111
-
112
-					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
-
115
-					if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
-						add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
-					}
118
-				}
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '0.2.26';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
119 46
 
120
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "5.2.2";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
121 60
 
122
-				do_action( 'ayecode_ui_settings_loaded' );
123
-			}
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
124 67
 
125
-			return self::$instance;
126
-		}
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
127 74
 
128
-		/**
129
-		 * Add custom colors to the color selector.
130
-		 *
131
-		 * @param $theme_colors
132
-		 * @param $include_outlines
133
-		 * @param $include_branding
134
-		 *
135
-		 * @return mixed
136
-		 */
137
-		public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
138 81
 
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
139 90
 
140
-			$setting = wp_get_global_settings();
141 91
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
144
-					$theme_colors[$color['slug']] = esc_attr($color['name']);
145
-				}
146
-			}
147
-
148
-			return $theme_colors;
149
-		}
150
-
151
-		/**
152
-		 * Setup some constants.
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' );
171
-
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
-			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
-			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
-			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
-			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
-			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
-			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
-			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
-			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
-			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
-			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
-			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
-			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
-			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
-			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
-			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
-			}
220
-
221
-		}
222
-
223
-		public static function get_colors( $original = false){
224
-
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
-				return array();
227
-			}
228
-			if ( $original ) {
229
-				return array(
230
-					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
-					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
-					'info'      => AUI_INFO_COLOR_ORIGINAL,
233
-					'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
-					'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
-					'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
-					'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
-					'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
-					'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
-					'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
-					'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
-					'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
-					'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
-					'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
-					'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
-					'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
-				);
247
-			}
248
-
249
-			return array(
250
-				'primary'   => AUI_PRIMARY_COLOR,
251
-				'secondary' => AUI_SECONDARY_COLOR,
252
-				'info'      => AUI_INFO_COLOR,
253
-				'warning'   => AUI_WARNING_COLOR,
254
-				'danger'    => AUI_DANGER_COLOR,
255
-				'success'   => AUI_SUCCESS_COLOR,
256
-				'light'     => AUI_LIGHT_COLOR,
257
-				'dark'      => AUI_DARK_COLOR,
258
-				'white'     => AUI_WHITE_COLOR,
259
-				'purple'    => AUI_PURPLE_COLOR,
260
-				'salmon'    => AUI_SALMON_COLOR,
261
-				'cyan'      => AUI_CYAN_COLOR,
262
-				'gray'      => AUI_GRAY_COLOR,
263
-				'indigo'    => AUI_INDIGO_COLOR,
264
-				'orange'    => AUI_ORANGE_COLOR,
265
-				'black'     => AUI_BLACK_COLOR,
266
-			);
267
-		}
268
-
269
-		/**
270
-		 * Add admin body class to show when BS5 is active.
271
-		 *
272
-		 * @param $classes
273
-		 *
274
-		 * @return mixed
275
-		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
277
-			$classes .= ' aui_bs5';
278
-
279
-			return $classes;
280
-		}
281
-
282
-		/**
283
-		 * Add a body class to show when BS5 is active.
284
-		 *
285
-		 * @param $classes
286
-		 *
287
-		 * @return mixed
288
-		 */
289
-		public function add_bs5_body_class( $classes ) {
290
-			$classes[] = 'aui_bs5';
291
-
292
-			return $classes;
293
-		}
294
-
295
-		/**
296
-		 * Initiate the settings and add the required action hooks.
297
-		 */
298
-		public function init() {
92
+        /**
93
+         * Main AyeCode_UI_Settings Instance.
94
+         *
95
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
96
+         *
97
+         * @since 1.0.0
98
+         * @static
99
+         * @return AyeCode_UI_Settings - Main instance.
100
+         */
101
+        public static function instance() {
102
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103
+
104
+                self::$instance = new AyeCode_UI_Settings;
105
+
106
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
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' ) );
111
+
112
+                    // Maybe show example page
113
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
114
+
115
+                    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
+                        add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
+                    }
118
+                }
119
+
120
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
121
+
122
+                do_action( 'ayecode_ui_settings_loaded' );
123
+            }
124
+
125
+            return self::$instance;
126
+        }
127
+
128
+        /**
129
+         * Add custom colors to the color selector.
130
+         *
131
+         * @param $theme_colors
132
+         * @param $include_outlines
133
+         * @param $include_branding
134
+         *
135
+         * @return mixed
136
+         */
137
+        public function sd_aui_colors( $theme_colors, $include_outlines, $include_branding ){
138
+
139
+
140
+            $setting = wp_get_global_settings();
141
+
142
+            if(!empty($setting['color']['palette']['custom'])){
143
+                foreach($setting['color']['palette']['custom'] as $color){
144
+                    $theme_colors[$color['slug']] = esc_attr($color['name']);
145
+                }
146
+            }
147
+
148
+            return $theme_colors;
149
+        }
150
+
151
+        /**
152
+         * Setup some constants.
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' );
171
+
172
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
+                define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
+            }
175
+            if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
+                define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
+            }
178
+            if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
+                define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
+            }
181
+            if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
+                define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
+            }
184
+            if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
+                define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
+            }
187
+            if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
+                define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
+            }
190
+            if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
+                define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
+            }
193
+            if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
+                define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
+            }
196
+            if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
+                define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
+            }
199
+            if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
+                define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
+            }
202
+            if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
+                define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
+            }
205
+            if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
+                define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
+            }
208
+            if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
+                define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
+            }
211
+            if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
+                define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
+            }
214
+            if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
+                define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
+            }
217
+            if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
+                define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
+            }
220
+
221
+        }
222
+
223
+        public static function get_colors( $original = false){
224
+
225
+            if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
+                return array();
227
+            }
228
+            if ( $original ) {
229
+                return array(
230
+                    'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
+                    'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
+                    'info'      => AUI_INFO_COLOR_ORIGINAL,
233
+                    'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
+                    'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
+                    'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
+                    'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
+                    'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
+                    'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
+                    'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
+                    'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
+                    'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
+                    'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
+                    'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
+                    'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
+                    'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
+                );
247
+            }
248
+
249
+            return array(
250
+                'primary'   => AUI_PRIMARY_COLOR,
251
+                'secondary' => AUI_SECONDARY_COLOR,
252
+                'info'      => AUI_INFO_COLOR,
253
+                'warning'   => AUI_WARNING_COLOR,
254
+                'danger'    => AUI_DANGER_COLOR,
255
+                'success'   => AUI_SUCCESS_COLOR,
256
+                'light'     => AUI_LIGHT_COLOR,
257
+                'dark'      => AUI_DARK_COLOR,
258
+                'white'     => AUI_WHITE_COLOR,
259
+                'purple'    => AUI_PURPLE_COLOR,
260
+                'salmon'    => AUI_SALMON_COLOR,
261
+                'cyan'      => AUI_CYAN_COLOR,
262
+                'gray'      => AUI_GRAY_COLOR,
263
+                'indigo'    => AUI_INDIGO_COLOR,
264
+                'orange'    => AUI_ORANGE_COLOR,
265
+                'black'     => AUI_BLACK_COLOR,
266
+            );
267
+        }
268
+
269
+        /**
270
+         * Add admin body class to show when BS5 is active.
271
+         *
272
+         * @param $classes
273
+         *
274
+         * @return mixed
275
+         */
276
+        public function add_bs5_admin_body_class( $classes = '' ) {
277
+            $classes .= ' aui_bs5';
278
+
279
+            return $classes;
280
+        }
281
+
282
+        /**
283
+         * Add a body class to show when BS5 is active.
284
+         *
285
+         * @param $classes
286
+         *
287
+         * @return mixed
288
+         */
289
+        public function add_bs5_body_class( $classes ) {
290
+            $classes[] = 'aui_bs5';
291
+
292
+            return $classes;
293
+        }
294
+
295
+        /**
296
+         * Initiate the settings and add the required action hooks.
297
+         */
298
+        public function init() {
299 299
             global $aui_bs5;
300 300
 
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 ) ) {
305
-					$db_settings['css_backend'] = 'compatibility';
306
-					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
308
-					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
-				}
310
-			}
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 ) ) {
305
+                    $db_settings['css_backend'] = 'compatibility';
306
+                    $db_settings['js_backend'] = 'core-popper';
307
+                    update_option( 'ayecode-ui-settings', $db_settings );
308
+                    wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
+                }
310
+            }
311 311
 
312
-			$this->constants();
313
-			$this->settings = $this->get_settings();
314
-			$this->url = $this->get_url();
312
+            $this->constants();
313
+            $this->settings = $this->get_settings();
314
+            $this->url = $this->get_url();
315 315
 
316 316
             // define the version
317
-			$aui_bs5 = $this->settings['bs_ver'] === '5';
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' ) );
323
-			}
324
-
325
-			/**
326
-			 * Maybe load CSS
327
-			 *
328
-			 * We load super early in case there is a theme version that might change the colors
329
-			 */
330
-			if ( $this->settings['css'] ) {
331
-				$priority = $this->is_bs3_compat() ? 100 : 1;
317
+            $aui_bs5 = $this->settings['bs_ver'] === '5';
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' ) );
323
+            }
324
+
325
+            /**
326
+             * Maybe load CSS
327
+             *
328
+             * We load super early in case there is a theme version that might change the colors
329
+             */
330
+            if ( $this->settings['css'] ) {
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 );
334
-			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
-			}
338
-
339
-			// maybe load JS
340
-			if ( $this->settings['js'] ) {
341
-				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
-			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
-			}
347
-
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 );
351
-			}
352
-
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' ) );
356
-			}
357
-
358
-		}
359
-
360
-		/**
361
-		 * Show admin notice if backend scripts not loaded.
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>'. wp_kses_post( $message ).'</p></div>';
368
-		}
369
-
370
-		/**
371
-		 * Check if we should load the admin scripts or not.
372
-		 *
373
-		 * @return bool
374
-		 */
375
-		public function load_admin_scripts(){
376
-			$result = true;
377
-
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 ){
383
-						return false; // return early, no point checking further
384
-					}
385
-				}
386
-			}
387
-
388
-			return $result;
389
-		}
390
-
391
-		/**
392
-		 * Add a html font size to the footer.
393
-		 */
394
-		public function html_font_size(){
395
-			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
-		}
398
-
399
-		/**
400
-		 * Check if the current admin screen should load scripts.
401
-		 *
402
-		 * @return bool
403
-		 */
404
-		public function is_aui_screen(){
333
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
+            }
335
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
+            }
338
+
339
+            // maybe load JS
340
+            if ( $this->settings['js'] ) {
341
+                $priority = $this->is_bs3_compat() ? 100 : 1;
342
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
+            }
344
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
+            }
347
+
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 );
351
+            }
352
+
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' ) );
356
+            }
357
+
358
+        }
359
+
360
+        /**
361
+         * Show admin notice if backend scripts not loaded.
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>'. wp_kses_post( $message ).'</p></div>';
368
+        }
369
+
370
+        /**
371
+         * Check if we should load the admin scripts or not.
372
+         *
373
+         * @return bool
374
+         */
375
+        public function load_admin_scripts(){
376
+            $result = true;
377
+
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 ){
383
+                        return false; // return early, no point checking further
384
+                    }
385
+                }
386
+            }
387
+
388
+            return $result;
389
+        }
390
+
391
+        /**
392
+         * Add a html font size to the footer.
393
+         */
394
+        public function html_font_size(){
395
+            $this->settings = $this->get_settings();
396
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
+        }
398
+
399
+        /**
400
+         * Check if the current admin screen should load scripts.
401
+         *
402
+         * @return bool
403
+         */
404
+        public function is_aui_screen(){
405 405
 //			echo '###';exit;
406
-			$load = false;
407
-			// check if we should load or not
408
-			if ( is_admin() ) {
409
-				// Only enable on set pages
410
-				$aui_screens = array(
411
-					'page',
406
+            $load = false;
407
+            // check if we should load or not
408
+            if ( is_admin() ) {
409
+                // Only enable on set pages
410
+                $aui_screens = array(
411
+                    'page',
412 412
                     //'docs',
413
-					'post',
414
-					'settings_page_ayecode-ui-settings',
415
-					'appearance_page_gutenberg-widgets',
416
-					'widgets',
417
-					'ayecode-ui-settings',
418
-					'site-editor'
419
-				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
413
+                    'post',
414
+                    'settings_page_ayecode-ui-settings',
415
+                    'appearance_page_gutenberg-widgets',
416
+                    'widgets',
417
+                    'ayecode-ui-settings',
418
+                    'site-editor'
419
+                );
420
+                $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
421 421
 
422
-				$screen = get_current_screen();
422
+                $screen = get_current_screen();
423 423
 
424 424
 //				echo '###'.$screen->id;
425 425
 
426
-				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
-					$load = true;
429
-				}
426
+                // check if we are on a AUI screen
427
+                if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
+                    $load = true;
429
+                }
430 430
 
431
-				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
433
-					$load = true;
434
-				}
435
-			}
431
+                //load for widget previews in WP 5.8
432
+                if( !empty($_REQUEST['legacy-widget-preview'])){
433
+                    $load = true;
434
+                }
435
+            }
436 436
 
437 437
 
438 438
 
439
-			return apply_filters( 'aui_load_on_admin' , $load );
440
-		}
439
+            return apply_filters( 'aui_load_on_admin' , $load );
440
+        }
441 441
 
442
-		/**
443
-		 * Check if the current theme is a block theme.
444
-		 *
445
-		 * @return bool
446
-		 */
447
-		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
-				return true;
450
-			}
442
+        /**
443
+         * Check if the current theme is a block theme.
444
+         *
445
+         * @return bool
446
+         */
447
+        public static function is_block_theme() {
448
+            if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
+                return true;
450
+            }
451 451
 
452
-			return false;
453
-		}
452
+            return false;
453
+        }
454 454
 
455
-		/**
456
-		 * Adds the styles.
457
-		 */
458
-		public function enqueue_style() {
455
+        /**
456
+         * Adds the styles.
457
+         */
458
+        public function enqueue_style() {
459 459
             global $aui_bs5;
460 460
 
461 461
             $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
464
-				// don't add wp-admin scripts if not requested to
465
-			}else{
466
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
463
+            if( is_admin() && !$this->is_aui_screen()){
464
+                // don't add wp-admin scripts if not requested to
465
+            }else{
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' );
488
-						$load_fse = true;
489
-					}
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
+                        $load_fse = true;
489
+                    }
490 490
 
491 491
 
492
-					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
492
+                    // flatpickr
493
+                    wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
494 494
 
495
-					// fix some wp-admin issues
496
-					if(is_admin()){
497
-						$custom_css = "
495
+                    // fix some wp-admin issues
496
+                    if(is_admin()){
497
+                        $custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
500 500
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -535,67 +535,67 @@  discard block
 block discarded – undo
535 535
 				}
536 536
                 ";
537 537
 
538
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
-						$custom_css .= "
538
+                        // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
+                        $custom_css .= "
540 540
 						.edit-post-sidebar input[type=color].components-text-control__input{
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
545
-					}
544
+                        wp_add_inline_style( 'ayecode-ui', $custom_css );
545
+                    }
546 546
 
547
-					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
547
+                    // custom changes
548
+                    if ( $load_fse ) {
549
+                        wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
+                    }else{
551
+                        wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
552 552
 
553
-					}
553
+                    }
554 554
 
555
-				}
556
-			}
555
+                }
556
+            }
557 557
 
558 558
 
559
-		}
559
+        }
560 560
 
561
-		/**
562
-		 * Get inline script used if bootstrap enqueued
563
-		 *
564
-		 * If this remains small then its best to use this than to add another JS file.
565
-		 */
566
-		public function inline_script() {
561
+        /**
562
+         * Get inline script used if bootstrap enqueued
563
+         *
564
+         * If this remains small then its best to use this than to add another JS file.
565
+         */
566
+        public function inline_script() {
567 567
             global $aui_bs5;
568
-			// Flatpickr calendar locale
569
-			$flatpickr_locale = self::flatpickr_locale();
570
-
571
-			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
568
+            // Flatpickr calendar locale
569
+            $flatpickr_locale = self::flatpickr_locale();
570
+
571
+            ob_start();
572
+            if ( $aui_bs5 ) {
573
+                include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
+            }else{
575
+                include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
576 576
             }
577 577
 
578
-			$output = ob_get_clean();
578
+            $output = ob_get_clean();
579 579
 
580
-			/*
580
+            /*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
584
-				'<script>',
585
-				'</script>'
586
-			), '', self::minify_js($output) );
587
-		}
588
-
589
-
590
-		/**
591
-		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
-		 *
593
-		 * @TODO we may need this when other conflicts arrise.
594
-		 * @return mixed
595
-		 */
596
-		public static function bs3_compat_js() {
597
-			ob_start();
598
-			?>
583
+            return str_replace( array(
584
+                '<script>',
585
+                '</script>'
586
+            ), '', self::minify_js($output) );
587
+        }
588
+
589
+
590
+        /**
591
+         * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592
+         *
593
+         * @TODO we may need this when other conflicts arrise.
594
+         * @return mixed
595
+         */
596
+        public static function bs3_compat_js() {
597
+            ob_start();
598
+            ?>
599 599
             <script>
600 600
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
601 601
                 /* With Avada builder */
@@ -603,20 +603,20 @@  discard block
 block discarded – undo
603 603
 				<?php } ?>
604 604
             </script>
605 605
 			<?php
606
-			return str_replace( array(
607
-				'<script>',
608
-				'</script>'
609
-			), '', ob_get_clean());
610
-		}
611
-
612
-		/**
613
-		 * Get inline script used if bootstrap file browser enqueued.
614
-		 *
615
-		 * If this remains small then its best to use this than to add another JS file.
616
-		 */
617
-		public function inline_script_file_browser(){
618
-			ob_start();
619
-			?>
606
+            return str_replace( array(
607
+                '<script>',
608
+                '</script>'
609
+            ), '', ob_get_clean());
610
+        }
611
+
612
+        /**
613
+         * Get inline script used if bootstrap file browser enqueued.
614
+         *
615
+         * If this remains small then its best to use this than to add another JS file.
616
+         */
617
+        public function inline_script_file_browser(){
618
+            ob_start();
619
+            ?>
620 620
             <script>
621 621
                 // run on doc ready
622 622
                 jQuery(document).ready(function () {
@@ -624,282 +624,282 @@  discard block
 block discarded – undo
624 624
                 });
625 625
             </script>
626 626
 			<?php
627
-			$output = ob_get_clean();
627
+            $output = ob_get_clean();
628 628
 
629
-			/*
629
+            /*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
633
-				'<script>',
634
-				'</script>'
635
-			), '', $output );
636
-		}
632
+            return str_replace( array(
633
+                '<script>',
634
+                '</script>'
635
+            ), '', $output );
636
+        }
637 637
 
638
-		/**
639
-		 * Adds the Font Awesome JS.
640
-		 */
641
-		public function enqueue_scripts() {
638
+        /**
639
+         * Adds the Font Awesome JS.
640
+         */
641
+        public function enqueue_scripts() {
642 642
 
643
-			if( is_admin() && !$this->is_aui_screen()){
644
-				// don't add wp-admin scripts if not requested to
645
-			}else {
643
+            if( is_admin() && !$this->is_aui_screen()){
644
+                // don't add wp-admin scripts if not requested to
645
+            }else {
646 646
 
647
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
647
+                $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648 648
 
649
-				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
649
+                $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650 650
 
651
-				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
651
+                // select2
652
+                wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
653 653
 
654
-				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
654
+                // flatpickr
655
+                wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
656 656
 
657
-				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
-				}
657
+                // iconpicker
658
+                if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
+                    wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
+                }else{
661
+                    wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
+                }
663 663
 
664
-				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
-
668
-				$load_inline = false;
669
-
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
-					// Bootstrap bundle
672
-					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
674
-						'select2',
675
-						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
677
-					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
-					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
-					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
685
-					$load_inline = true;
686
-				} else {
687
-					$load_inline = true;
688
-				}
664
+                // Bootstrap file browser
665
+                wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
+                wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
+
668
+                $load_inline = false;
669
+
670
+                if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
+                    // Bootstrap bundle
672
+                    $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
+                    wp_register_script( 'bootstrap-js-bundle', $url, array(
674
+                        'select2',
675
+                        'jquery'
676
+                    ), $this->version, $this->is_bs3_compat() );
677
+                    // if in admin then add to footer for compatibility.
678
+                    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
+                    $script = $this->inline_script();
680
+                    wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
+                } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
+                    $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
+                    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
+                    wp_enqueue_script( 'bootstrap-js-popper' );
685
+                    $load_inline = true;
686
+                } else {
687
+                    $load_inline = true;
688
+                }
689 689
 
690
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
694
-					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
696
-				}
697
-			}
698
-
699
-		}
700
-
701
-		/**
702
-		 * Enqueue flatpickr if called.
703
-		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
707
-		}
708
-
709
-		/**
710
-		 * Enqueue iconpicker if called.
711
-		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
715
-		}
716
-
717
-		/**
718
-		 * Get the url path to the current folder.
719
-		 *
720
-		 * @return string
721
-		 */
722
-		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
725
-
726
-			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
729
-			}
730
-
731
-			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
734
-
735
-			return trailingslashit( $url );
736
-		}
737
-
738
-		/**
739
-		 * Get the url path to the current folder.
740
-		 *
741
-		 * @return string
742
-		 */
743
-		public function get_url_old() {
744
-
745
-			$url = '';
746
-			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
-
749
-			// add check in-case user has changed wp-content dir name.
750
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
-
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
-			}
757
-
758
-			return $url;
759
-		}
760
-
761
-		/**
762
-		 * Register the database settings with WordPress.
763
-		 */
764
-		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
-		}
767
-
768
-		/**
769
-		 * Add the WordPress settings menu item.
770
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
-		 */
772
-		public function menu_item() {
773
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
-				$this,
776
-				'settings_page'
777
-			) );
778
-		}
779
-
780
-		/**
781
-		 * Get a list of themes and their default JS settings.
782
-		 *
783
-		 * @return array
784
-		 */
785
-		public function theme_js_settings(){
786
-			return array(
787
-				'ayetheme' => 'popper',
788
-				'listimia' => 'required',
789
-				'listimia_backend' => 'core-popper',
790
-				//'avada'    => 'required', // removed as we now add compatibility
791
-			);
792
-		}
793
-
794
-		/**
690
+                // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
+                if ( $load_inline ) {
692
+                    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
+                    wp_enqueue_script( 'bootstrap-dummy' );
694
+                    $script = $this->inline_script();
695
+                    wp_add_inline_script( 'bootstrap-dummy', $script );
696
+                }
697
+            }
698
+
699
+        }
700
+
701
+        /**
702
+         * Enqueue flatpickr if called.
703
+         */
704
+        public function enqueue_flatpickr(){
705
+            wp_enqueue_style( 'flatpickr' );
706
+            wp_enqueue_script( 'flatpickr' );
707
+        }
708
+
709
+        /**
710
+         * Enqueue iconpicker if called.
711
+         */
712
+        public function enqueue_iconpicker(){
713
+            wp_enqueue_style( 'iconpicker' );
714
+            wp_enqueue_script( 'iconpicker' );
715
+        }
716
+
717
+        /**
718
+         * Get the url path to the current folder.
719
+         *
720
+         * @return string
721
+         */
722
+        public function get_url() {
723
+            $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
+            $content_url = untrailingslashit( WP_CONTENT_URL );
725
+
726
+            // Replace http:// to https://.
727
+            if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
+                $content_url = str_replace( 'http://', 'https://', $content_url );
729
+            }
730
+
731
+            // Check if we are inside a plugin
732
+            $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
+            $url = str_replace( $content_dir, $content_url, $file_dir );
734
+
735
+            return trailingslashit( $url );
736
+        }
737
+
738
+        /**
739
+         * Get the url path to the current folder.
740
+         *
741
+         * @return string
742
+         */
743
+        public function get_url_old() {
744
+
745
+            $url = '';
746
+            // check if we are inside a plugin
747
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748
+
749
+            // add check in-case user has changed wp-content dir name.
750
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
751
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
753
+
754
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
+            }
757
+
758
+            return $url;
759
+        }
760
+
761
+        /**
762
+         * Register the database settings with WordPress.
763
+         */
764
+        public function register_settings() {
765
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
+        }
767
+
768
+        /**
769
+         * Add the WordPress settings menu item.
770
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771
+         */
772
+        public function menu_item() {
773
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
+                $this,
776
+                'settings_page'
777
+            ) );
778
+        }
779
+
780
+        /**
781
+         * Get a list of themes and their default JS settings.
782
+         *
783
+         * @return array
784
+         */
785
+        public function theme_js_settings(){
786
+            return array(
787
+                'ayetheme' => 'popper',
788
+                'listimia' => 'required',
789
+                'listimia_backend' => 'core-popper',
790
+                //'avada'    => 'required', // removed as we now add compatibility
791
+            );
792
+        }
793
+
794
+        /**
795 795
          * Get the date the site was installed.
796 796
          *
797
-		 * @return false|string
798
-		 */
797
+         * @return false|string
798
+         */
799 799
         public function get_site_install_date() {
800
-	        global $wpdb; // This gives you access to the WordPress database object
800
+            global $wpdb; // This gives you access to the WordPress database object
801 801
 
802
-	        // Prepare the SQL query to get the oldest registration date
803
-	        $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
802
+            // Prepare the SQL query to get the oldest registration date
803
+            $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
804 804
 
805
-	        // Execute the query
806
-	        $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
805
+            // Execute the query
806
+            $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
807 807
 
808
-	        return $date ? $date : false;
808
+            return $date ? $date : false;
809 809
         }
810 810
 
811
-		/**
812
-		 * Show admin notice if backend scripts not loaded.
813
-		 */
814
-		public function show_admin_version_notice(){
815
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
-			$message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>';
819
-		}
820
-
821
-		/**
822
-		 * Get the current Font Awesome output settings.
823
-		 *
824
-		 * @return array The array of settings.
825
-		 */
826
-		public function get_settings() {
827
-
828
-			$db_settings = get_option( 'ayecode-ui-settings' );
811
+        /**
812
+         * Show admin notice if backend scripts not loaded.
813
+         */
814
+        public function show_admin_version_notice(){
815
+            $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
+            $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
+            $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
+            echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>';
819
+        }
820
+
821
+        /**
822
+         * Get the current Font Awesome output settings.
823
+         *
824
+         * @return array The array of settings.
825
+         */
826
+        public function get_settings() {
827
+
828
+            $db_settings = get_option( 'ayecode-ui-settings' );
829 829
 
830 830
             // Maybe show default version notice
831
-			$site_install_date = new DateTime( self::get_site_install_date() );
832
-			$switch_over_date = new DateTime("2024-02-01");
833
-			if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
-				add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
-			}
836
-
837
-			$js_default = 'core-popper';
838
-			$js_default_backend = $js_default;
839
-
840
-			// maybe set defaults (if no settings set)
841
-			if(empty($db_settings)){
842
-				$active_theme = strtolower( get_template() ); // active parent theme.
843
-				$theme_js_settings = self::theme_js_settings();
844
-				if(isset($theme_js_settings[$active_theme])){
845
-					$js_default = $theme_js_settings[$active_theme];
846
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
-				}
848
-			}
831
+            $site_install_date = new DateTime( self::get_site_install_date() );
832
+            $switch_over_date = new DateTime("2024-02-01");
833
+            if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
+                add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
+            }
849 836
 
850
-			/**
851
-			 * Filter the default settings.
852
-			 */
853
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
-				'css'            => 'compatibility', // core, compatibility
855
-				'js'             => $js_default, // js to load, core-popper, popper
856
-				'html_font_size' => '16', // js to load, core-popper, popper
857
-				'css_backend'    => 'compatibility', // core, compatibility
858
-				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
-				'disable_admin'  => '', // URL snippets to disable loading on admin
837
+            $js_default = 'core-popper';
838
+            $js_default_backend = $js_default;
839
+
840
+            // maybe set defaults (if no settings set)
841
+            if(empty($db_settings)){
842
+                $active_theme = strtolower( get_template() ); // active parent theme.
843
+                $theme_js_settings = self::theme_js_settings();
844
+                if(isset($theme_js_settings[$active_theme])){
845
+                    $js_default = $theme_js_settings[$active_theme];
846
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
+                }
848
+            }
849
+
850
+            /**
851
+             * Filter the default settings.
852
+             */
853
+            $defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
+                'css'            => 'compatibility', // core, compatibility
855
+                'js'             => $js_default, // js to load, core-popper, popper
856
+                'html_font_size' => '16', // js to load, core-popper, popper
857
+                'css_backend'    => 'compatibility', // core, compatibility
858
+                'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
+                'disable_admin'  => '', // URL snippets to disable loading on admin
860 860
                 'bs_ver'         => '5', // The default bootstrap version to sue by default
861
-			), $db_settings );
861
+            ), $db_settings );
862 862
 
863
-			$settings = wp_parse_args( $db_settings, $defaults );
863
+            $settings = wp_parse_args( $db_settings, $defaults );
864 864
 
865
-			/**
866
-			 * Filter the Bootstrap settings.
867
-			 *
868
-			 * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869
-			 */
870
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
-		}
865
+            /**
866
+             * Filter the Bootstrap settings.
867
+             *
868
+             * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869
+             */
870
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
+        }
872 872
 
873 873
 
874
-		/**
875
-		 * The settings page html output.
876
-		 */
877
-		public function settings_page() {
878
-			if ( ! current_user_can( 'manage_options' ) ) {
879
-				wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
-			}
874
+        /**
875
+         * The settings page html output.
876
+         */
877
+        public function settings_page() {
878
+            if ( ! current_user_can( 'manage_options' ) ) {
879
+                wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
+            }
881 881
             $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
882 882
 
883
-			?>
883
+            ?>
884 884
             <div class="wrap">
885 885
                 <h1><?php echo esc_attr( $this->name ); ?></h1>
886 886
                 <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p>
887 887
                 <form method="post" action="options.php">
888 888
 					<?php
889
-					settings_fields( 'ayecode-ui-settings' );
890
-					do_settings_sections( 'ayecode-ui-settings' );
891
-					?>
889
+                    settings_fields( 'ayecode-ui-settings' );
890
+                    do_settings_sections( 'ayecode-ui-settings' );
891
+                    ?>
892 892
 
893 893
                     <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
894 894
                     <p><?php echo esc_html( 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.", 'ayecode-connect' ) ) );?></p>
895 895
 	                <div class="bsui"><?php
896
-	                if ( ! empty( $overrides ) ) {
897
-		                echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898
-			                'type'=> 'info',
899
-			                'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
-		                ));
901
-	                }
902
-	                ?>
896
+                    if ( ! empty( $overrides ) ) {
897
+                        echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898
+                            'type'=> 'info',
899
+                            'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
+                        ));
901
+                    }
902
+                    ?>
903 903
                     </div>
904 904
                     <table class="form-table wpbs-table-version-settings">
905 905
                         <tr valign="top">
@@ -983,77 +983,77 @@  discard block
 block discarded – undo
983 983
                     </table>
984 984
 
985 985
 					<?php
986
-					submit_button();
987
-					?>
986
+                    submit_button();
987
+                    ?>
988 988
                 </form>
989 989
                 <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div>
990 990
             </div>
991 991
 			<?php
992
-		}
992
+        }
993 993
 
994 994
         public function get_load_source(){
995
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
-
998
-	        // Find source plugin/theme of SD
999
-	        $source = array();
1000
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
1001
-		        $source = explode( "/", plugin_basename( $file ) );
1002
-	        } else if ( function_exists( 'get_theme_root' ) ) {
1003
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
-
1005
-		        if ( strpos( $file, $themes_dir ) !== false ) {
1006
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
-		        }
1008
-	        }
995
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
+
998
+            // Find source plugin/theme of SD
999
+            $source = array();
1000
+            if ( strpos( $file, $plugins_dir ) !== false ) {
1001
+                $source = explode( "/", plugin_basename( $file ) );
1002
+            } else if ( function_exists( 'get_theme_root' ) ) {
1003
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
+
1005
+                if ( strpos( $file, $themes_dir ) !== false ) {
1006
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
+                }
1008
+            }
1009 1009
 
1010 1010
             return isset($source[0]) ? esc_attr($source[0]) : '';
1011 1011
         }
1012 1012
 
1013
-		public function customizer_settings($wp_customize){
1014
-			$wp_customize->add_section('aui_settings', array(
1015
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
-				'priority' => 120,
1017
-			));
1018
-
1019
-			//  =============================
1020
-			//  = Color Picker              =
1021
-			//  =============================
1022
-			$wp_customize->add_setting('aui_options[color_primary]', array(
1023
-				'default'           => AUI_PRIMARY_COLOR,
1024
-				'sanitize_callback' => 'sanitize_hex_color',
1025
-				'capability'        => 'edit_theme_options',
1026
-				'type'              => 'option',
1027
-				'transport'         => 'refresh',
1028
-			));
1029
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
-				'label'    => __('Primary Color', 'ayecode-connect' ),
1031
-				'section'  => 'aui_settings',
1032
-				'settings' => 'aui_options[color_primary]',
1033
-			)));
1034
-
1035
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1036
-				'default'           => '#6c757d',
1037
-				'sanitize_callback' => 'sanitize_hex_color',
1038
-				'capability'        => 'edit_theme_options',
1039
-				'type'              => 'option',
1040
-				'transport'         => 'refresh',
1041
-			));
1042
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
-				'section'  => 'aui_settings',
1045
-				'settings' => 'aui_options[color_secondary]',
1046
-			)));
1047
-		}
1048
-
1049
-		/**
1050
-		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1051
-		 *
1052
-		 * @return mixed
1053
-		 */
1054
-		public static function bs3_compat_css() {
1055
-			ob_start();
1056
-			?>
1013
+        public function customizer_settings($wp_customize){
1014
+            $wp_customize->add_section('aui_settings', array(
1015
+                'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
+                'priority' => 120,
1017
+            ));
1018
+
1019
+            //  =============================
1020
+            //  = Color Picker              =
1021
+            //  =============================
1022
+            $wp_customize->add_setting('aui_options[color_primary]', array(
1023
+                'default'           => AUI_PRIMARY_COLOR,
1024
+                'sanitize_callback' => 'sanitize_hex_color',
1025
+                'capability'        => 'edit_theme_options',
1026
+                'type'              => 'option',
1027
+                'transport'         => 'refresh',
1028
+            ));
1029
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
+                'label'    => __('Primary Color', 'ayecode-connect' ),
1031
+                'section'  => 'aui_settings',
1032
+                'settings' => 'aui_options[color_primary]',
1033
+            )));
1034
+
1035
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
1036
+                'default'           => '#6c757d',
1037
+                'sanitize_callback' => 'sanitize_hex_color',
1038
+                'capability'        => 'edit_theme_options',
1039
+                'type'              => 'option',
1040
+                'transport'         => 'refresh',
1041
+            ));
1042
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
+                'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
+                'section'  => 'aui_settings',
1045
+                'settings' => 'aui_options[color_secondary]',
1046
+            )));
1047
+        }
1048
+
1049
+        /**
1050
+         * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1051
+         *
1052
+         * @return mixed
1053
+         */
1054
+        public static function bs3_compat_css() {
1055
+            ob_start();
1056
+            ?>
1057 1057
             <style>
1058 1058
                 /* Bootstrap 3 compatibility */
1059 1059
                 body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1082,55 +1082,55 @@  discard block
 block discarded – undo
1082 1082
                 <?php } ?>
1083 1083
             </style>
1084 1084
 			<?php
1085
-			return str_replace( array(
1086
-				'<style>',
1087
-				'</style>'
1088
-			), '', self::minify_css( ob_get_clean() ) );
1089
-		}
1085
+            return str_replace( array(
1086
+                '<style>',
1087
+                '</style>'
1088
+            ), '', self::minify_css( ob_get_clean() ) );
1089
+        }
1090 1090
 
1091 1091
 
1092
-		public static function custom_css($compatibility = true) {
1092
+        public static function custom_css($compatibility = true) {
1093 1093
             global $aui_bs5;
1094 1094
 
1095
-			$colors = array();
1096
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1095
+            $colors = array();
1096
+            if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1097 1097
 
1098 1098
 
1099
-				$setting = wp_get_global_settings();
1099
+                $setting = wp_get_global_settings();
1100 1100
 
1101 1101
 //                print_r(wp_get_global_styles());//exit;
1102 1102
 //                print_r(get_default_block_editor_settings());exit;
1103 1103
 
1104 1104
 //                print_r($setting);echo  '###';exit;
1105
-				if(!empty($setting['color']['palette']['theme'])){
1106
-					foreach($setting['color']['palette']['theme'] as $color){
1107
-						$colors[$color['slug']] = esc_attr($color['color']);
1108
-					}
1109
-				}
1105
+                if(!empty($setting['color']['palette']['theme'])){
1106
+                    foreach($setting['color']['palette']['theme'] as $color){
1107
+                        $colors[$color['slug']] = esc_attr($color['color']);
1108
+                    }
1109
+                }
1110 1110
 
1111
-				if(!empty($setting['color']['palette']['custom'])){
1112
-					foreach($setting['color']['palette']['custom'] as $color){
1113
-						$colors[$color['slug']] = esc_attr($color['color']);
1114
-					}
1115
-				}
1116
-			}else{
1117
-				$settings = get_option('aui_options');
1118
-				$colors = array(
1119
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
-				);
1122
-			}
1111
+                if(!empty($setting['color']['palette']['custom'])){
1112
+                    foreach($setting['color']['palette']['custom'] as $color){
1113
+                        $colors[$color['slug']] = esc_attr($color['color']);
1114
+                    }
1115
+                }
1116
+            }else{
1117
+                $settings = get_option('aui_options');
1118
+                $colors = array(
1119
+                    'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
+                    'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
+                );
1122
+            }
1123 1123
 
1124
-			ob_start();
1124
+            ob_start();
1125 1125
 
1126
-			?>
1126
+            ?>
1127 1127
             <style>
1128 1128
                 <?php
1129 1129
 
1130
-					// BS v3 compat
1131
-					if( self::is_bs3_compat() ){
1132
-						echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1133
-					}
1130
+                    // BS v3 compat
1131
+                    if( self::is_bs3_compat() ){
1132
+                        echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1133
+                    }
1134 1134
 
1135 1135
                     $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1136 1136
                     $is_fse = false;
@@ -1138,26 +1138,26 @@  discard block
 block discarded – undo
1138 1138
                         $is_fse = true;
1139 1139
                     }
1140 1140
 
1141
-					if(!empty($colors)){
1142
-						$d_colors = self::get_colors(true);
1141
+                    if(!empty($colors)){
1142
+                        $d_colors = self::get_colors(true);
1143 1143
 
1144 1144
 //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
-						foreach($colors as $key => $color ){
1146
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
-								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
-								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1150
-							}
1151
-						}
1152
-					   // exit;
1153
-					}
1145
+                        foreach($colors as $key => $color ){
1146
+                            if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
+                                $var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
+                                $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
+                                echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1150
+                            }
1151
+                        }
1152
+                        // exit;
1153
+                    }
1154 1154
 
1155
-					// Set admin bar z-index lower when modal is open.
1156
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1155
+                    // Set admin bar z-index lower when modal is open.
1156
+                    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1157 1157
 
1158
-					if(is_admin()){
1159
-						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
-					}
1158
+                    if(is_admin()){
1159
+                        echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
+                    }
1161 1161
 
1162 1162
                     if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1163 1163
                         $css = '';
@@ -1177,28 +1177,28 @@  discard block
 block discarded – undo
1177 1177
                         }
1178 1178
 
1179 1179
                         // line height
1180
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1180
+                            if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181 1181
                             $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1182 1182
                         }
1183 1183
 
1184 1184
 
1185
-                           // font weight
1186
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1185
+                            // font weight
1186
+                            if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187 1187
                             $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1188 1188
                         }
1189 1189
 
1190 1190
                         // Background
1191
-                         if( !empty( $theme_settings['color']['background'] ) ){
1191
+                            if( !empty( $theme_settings['color']['background'] ) ){
1192 1192
                             $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1193 1193
                         }
1194 1194
 
1195
-                         // Background Gradient
1196
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1195
+                            // Background Gradient
1196
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1197 1197
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1198 1198
                         }
1199 1199
 
1200
-                           // Background Gradient
1201
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1200
+                            // Background Gradient
1201
+                            if( !empty( $theme_settings['color']['gradient'] ) ){
1202 1202
                             $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1203 1203
                         }
1204 1204
 
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
                             $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1237 1237
                         }
1238 1238
 
1239
-                         // heading font family
1239
+                            // heading font family
1240 1240
                         if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241 1241
                             $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1242 1242
                         }
@@ -1249,21 +1249,21 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
                         foreach($hs as $hn){
1251 1251
                             $h_css = '';
1252
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1252
+                                if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253 1253
                                 $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1254
-                             }
1254
+                                }
1255 1255
 
1256
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1256
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257 1257
                                 $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1258
-                             }
1258
+                                }
1259 1259
 
1260
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1260
+                                if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261 1261
                                 $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1262
-                             }
1262
+                                }
1263 1263
 
1264
-                             if($h_css){
1264
+                                if($h_css){
1265 1265
                                 echo esc_attr( $bep  . $hn ) . '{'.esc_attr( $h_css ).'}';
1266
-                             }
1266
+                                }
1267 1267
                         }
1268 1268
                     }
1269 1269
 
@@ -1274,176 +1274,176 @@  discard block
 block discarded – undo
1274 1274
                 ?>
1275 1275
             </style>
1276 1276
 			<?php
1277
-			/*
1277
+            /*
1278 1278
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1279 1279
 			 */
1280
-			return str_replace( array(
1281
-				'<style>',
1282
-				'</style>'
1283
-			), '', self::minify_css( ob_get_clean() ) );
1284
-		}
1285
-
1286
-		/**
1287
-		 * Check if we should add booststrap 3 compatibility changes.
1288
-		 *
1289
-		 * @return bool
1290
-		 */
1291
-		public static function is_bs3_compat(){
1292
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1293
-		}
1294
-
1295
-		public static function hex_to_rgb( $hex ) {
1296
-			// Remove '#' if present
1297
-			$hex = str_replace( '#', '', $hex );
1298
-
1299
-			// Check if input is RGB
1300
-			if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) {
1301
-				$_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) );
1302
-
1303
-				$rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ',';
1304
-				$rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ',';
1305
-				$rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' );
1306
-
1307
-				return $rgb;
1308
-			}
1309
-
1310
-			// Convert 3-digit hex to 6-digit hex
1311
-			if ( strlen( $hex ) == 3 ) {
1312
-				$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1313
-			}
1314
-
1315
-			// Convert hex to RGB
1316
-			$r = hexdec( substr( $hex, 0, 2 ) );
1317
-			$g = hexdec( substr( $hex, 2, 2 ) );
1318
-			$b = hexdec( substr( $hex, 4, 2 ) );
1319
-
1320
-			// Return RGB values as an array
1321
-			return $r . ',' . $g . ',' . $b;
1322
-		}
1323
-
1324
-		/**
1325
-		 * Build the CSS to overwrite a bootstrap color variable.
1326
-		 *
1327
-		 * @param $type
1328
-		 * @param $color_code
1329
-		 * @param $compatibility
1330
-		 *
1331
-		 * @return string
1332
-		 */
1333
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1334
-			global $aui_bs5;
1335
-
1336
-			$is_var = false;
1337
-			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1338
-			if(!$color_code){return '';}
1339
-			if(strpos($color_code, 'var') !== false){
1340
-				//if(!sanitize_hex_color($color_code)){
1341
-				$color_code = esc_attr($color_code);
1342
-				$is_var = true;
1280
+            return str_replace( array(
1281
+                '<style>',
1282
+                '</style>'
1283
+            ), '', self::minify_css( ob_get_clean() ) );
1284
+        }
1285
+
1286
+        /**
1287
+         * Check if we should add booststrap 3 compatibility changes.
1288
+         *
1289
+         * @return bool
1290
+         */
1291
+        public static function is_bs3_compat(){
1292
+            return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1293
+        }
1294
+
1295
+        public static function hex_to_rgb( $hex ) {
1296
+            // Remove '#' if present
1297
+            $hex = str_replace( '#', '', $hex );
1298
+
1299
+            // Check if input is RGB
1300
+            if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) {
1301
+                $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) );
1302
+
1303
+                $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ',';
1304
+                $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ',';
1305
+                $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' );
1306
+
1307
+                return $rgb;
1308
+            }
1309
+
1310
+            // Convert 3-digit hex to 6-digit hex
1311
+            if ( strlen( $hex ) == 3 ) {
1312
+                $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1313
+            }
1314
+
1315
+            // Convert hex to RGB
1316
+            $r = hexdec( substr( $hex, 0, 2 ) );
1317
+            $g = hexdec( substr( $hex, 2, 2 ) );
1318
+            $b = hexdec( substr( $hex, 4, 2 ) );
1319
+
1320
+            // Return RGB values as an array
1321
+            return $r . ',' . $g . ',' . $b;
1322
+        }
1323
+
1324
+        /**
1325
+         * Build the CSS to overwrite a bootstrap color variable.
1326
+         *
1327
+         * @param $type
1328
+         * @param $color_code
1329
+         * @param $compatibility
1330
+         *
1331
+         * @return string
1332
+         */
1333
+        public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1334
+            global $aui_bs5;
1335
+
1336
+            $is_var = false;
1337
+            $is_custom = strpos($type, 'custom-') !== false ? true : false;
1338
+            if(!$color_code){return '';}
1339
+            if(strpos($color_code, 'var') !== false){
1340
+                //if(!sanitize_hex_color($color_code)){
1341
+                $color_code = esc_attr($color_code);
1342
+                $is_var = true;
1343 1343
 //				$color_code = "rgba($color_code, 0.5)";
1344 1344
 //                echo '###1'.$color_code.'###';//exit;
1345
-			}
1345
+            }
1346 1346
 
1347 1347
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1348 1348
 
1349
-			if(!$color_code){return '';}
1349
+            if(!$color_code){return '';}
1350 1350
 
1351
-			$rgb = self::hex_to_rgb($hex);
1351
+            $rgb = self::hex_to_rgb($hex);
1352 1352
 
1353
-			if($compatibility===true || $compatibility===1){
1354
-				$compatibility = '.bsui';
1355
-			}elseif(!$compatibility){
1356
-				$compatibility = '';
1357
-			}else{
1358
-				$compatibility = esc_attr($compatibility);
1359
-			}
1353
+            if($compatibility===true || $compatibility===1){
1354
+                $compatibility = '.bsui';
1355
+            }elseif(!$compatibility){
1356
+                $compatibility = '';
1357
+            }else{
1358
+                $compatibility = esc_attr($compatibility);
1359
+            }
1360 1360
 
1361
-			$prefix = $compatibility ? $compatibility . " " : "";
1361
+            $prefix = $compatibility ? $compatibility . " " : "";
1362 1362
 
1363 1363
 
1364 1364
             $output = '';
1365 1365
 
1366 1366
 //            echo '####'.$color_code;exit;
1367 1367
 
1368
-			$type = sanitize_html_class($type);
1368
+            $type = sanitize_html_class($type);
1369
+
1370
+            /**
1371
+             * c = color, b = background color, o = border-color, f = fill
1372
+             */
1373
+            $selectors = array(
1374
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1375
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1376
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1377
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1378
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1379
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1380
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1381
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1382
+                ".badge-{$type}"                                            => array( 'b' ),
1383
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1384
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1385
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1386
+                ".text-{$type}"                                     => array( 'c' ),
1387
+            );
1388
+
1389
+            if ( $aui_bs5 ) {
1390
+                unset($selectors[".alert-{$type}" ]);
1391
+            }
1369 1392
 
1370
-			/**
1371
-			 * c = color, b = background color, o = border-color, f = fill
1372
-			 */
1373
-			$selectors = array(
1374
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1375
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1376
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1377
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1378
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1379
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1380
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1381
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1382
-				".badge-{$type}"                                            => array( 'b' ),
1383
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1384
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1385
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1386
-				".text-{$type}"                                     => array( 'c' ),
1387
-			);
1388
-
1389
-			if ( $aui_bs5 ) {
1390
-				unset($selectors[".alert-{$type}" ]);
1391
-			}
1392
-
1393
-			if ( $type == 'primary' ) {
1394
-				$selectors = $selectors + array(
1395
-						'a'                                                                                                    => array( 'c' ),
1396
-						'.btn-link'                                                                                            => array( 'c' ),
1397
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1398
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1399
-							'b',
1400
-							'o'
1401
-						),
1402
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1403
-							'b',
1404
-							'o'
1405
-						),
1406
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1407
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1408
-						'.page-link'                                                                                           => array( 'c' ),
1409
-						'.page-item.active .page-link'                                                                         => array(
1410
-							'b',
1411
-							'o'
1412
-						),
1413
-						'.progress-bar'                                                                                        => array( 'b' ),
1414
-						'.list-group-item.active'                                                                              => array(
1415
-							'b',
1416
-							'o'
1417
-						),
1418
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1419
-					);
1420
-			}
1393
+            if ( $type == 'primary' ) {
1394
+                $selectors = $selectors + array(
1395
+                        'a'                                                                                                    => array( 'c' ),
1396
+                        '.btn-link'                                                                                            => array( 'c' ),
1397
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1398
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1399
+                            'b',
1400
+                            'o'
1401
+                        ),
1402
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1403
+                            'b',
1404
+                            'o'
1405
+                        ),
1406
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1407
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1408
+                        '.page-link'                                                                                           => array( 'c' ),
1409
+                        '.page-item.active .page-link'                                                                         => array(
1410
+                            'b',
1411
+                            'o'
1412
+                        ),
1413
+                        '.progress-bar'                                                                                        => array( 'b' ),
1414
+                        '.list-group-item.active'                                                                              => array(
1415
+                            'b',
1416
+                            'o'
1417
+                        ),
1418
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1419
+                    );
1420
+            }
1421 1421
 
1422 1422
 
1423 1423
 
1424 1424
             // link
1425
-			if ( $type === 'primary' ) {
1426
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1427
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1428
-				$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).'; }';
1425
+            if ( $type === 'primary' ) {
1426
+                $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1427
+                $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1428
+                $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).'; }';
1429 1429
 
1430
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1431
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1430
+                $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1431
+                $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1432 1432
 
1433 1433
                 // dropdown
1434
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1434
+                $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1435 1435
 
1436 1436
                 // pagination
1437
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1437
+                $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1438 1438
 
1439
-			}
1439
+            }
1440 1440
 
1441
-			$output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1442
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1441
+            $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1442
+            $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1443 1443
 
1444
-			//  buttons
1445
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1446
-			$output .= ' 
1444
+            //  buttons
1445
+            $output .= $prefix . ' .btn-'.esc_attr($type).'{';
1446
+            $output .= ' 
1447 1447
             --bs-btn-bg: '.esc_attr($color_code).';
1448 1448
             --bs-btn-border-color: '.esc_attr($color_code).';
1449 1449
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1461,11 +1461,11 @@  discard block
 block discarded – undo
1461 1461
 //			--bs-btn-active-color: #fff;
1462 1462
 //			--bs-btn-disabled-color: #fff;
1463 1463
 //            ';
1464
-			$output .= '}';
1464
+            $output .= '}';
1465 1465
 
1466
-			//  buttons outline
1467
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1468
-			$output .= ' 
1466
+            //  buttons outline
1467
+            $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1468
+            $output .= ' 
1469 1469
 			--bs-btn-color: '.esc_attr($color_code).';
1470 1470
             --bs-btn-border-color: '.esc_attr($color_code).';
1471 1471
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1483,37 +1483,37 @@  discard block
 block discarded – undo
1483 1483
 //			--bs-btn-active-color: #fff;
1484 1484
 //			--bs-btn-disabled-color: #fff;
1485 1485
 //            ';
1486
-			$output .= '}';
1486
+            $output .= '}';
1487 1487
 
1488 1488
 
1489 1489
             // button hover
1490
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1491
-			$output .= ' 
1490
+            $output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1491
+            $output .= ' 
1492 1492
             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);
1493 1493
             }
1494 1494
             ';
1495 1495
 
1496 1496
 
1497
-			if ( $aui_bs5 ) {
1497
+            if ( $aui_bs5 ) {
1498 1498
 //				$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).'; }';
1499
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1500
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1501
-			}
1499
+                $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1500
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1501
+            }
1502 1502
 
1503 1503
 
1504
-			if ( $is_custom ) {
1504
+            if ( $is_custom ) {
1505 1505
 
1506 1506
 //				echo '###'.$type;exit;
1507 1507
 
1508
-				// build rules into each type
1509
-				foreach($selectors as $selector => $types){
1510
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1511
-					$types = array_combine($types,$types);
1512
-					if(isset($types['c'])){$color[] = $selector;}
1513
-					if(isset($types['b'])){$background[] = $selector;}
1514
-					if(isset($types['o'])){$border[] = $selector;}
1515
-					if(isset($types['f'])){$fill[] = $selector;}
1516
-				}
1508
+                // build rules into each type
1509
+                foreach($selectors as $selector => $types){
1510
+                    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1511
+                    $types = array_combine($types,$types);
1512
+                    if(isset($types['c'])){$color[] = $selector;}
1513
+                    if(isset($types['b'])){$background[] = $selector;}
1514
+                    if(isset($types['o'])){$border[] = $selector;}
1515
+                    if(isset($types['f'])){$fill[] = $selector;}
1516
+                }
1517 1517
 
1518 1518
 //				// build rules into each type
1519 1519
 //				foreach($important_selectors as $selector => $types){
@@ -1525,68 +1525,68 @@  discard block
 block discarded – undo
1525 1525
 //					if(isset($types['f'])){$fill_i[] = $selector;}
1526 1526
 //				}
1527 1527
 
1528
-				// add any color rules
1529
-				if(!empty($color)){
1530
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1531
-				}
1532
-				if(!empty($color_i)){
1533
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1534
-				}
1528
+                // add any color rules
1529
+                if(!empty($color)){
1530
+                    $output .= implode(",",$color) . "{color: $color_code;} ";
1531
+                }
1532
+                if(!empty($color_i)){
1533
+                    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1534
+                }
1535 1535
 
1536
-				// add any background color rules
1537
-				if(!empty($background)){
1538
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1539
-				}
1540
-				if(!empty($background_i)){
1541
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1536
+                // add any background color rules
1537
+                if(!empty($background)){
1538
+                    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1539
+                }
1540
+                if(!empty($background_i)){
1541
+                    $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1542 1542
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1543
-				}
1543
+                }
1544 1544
 
1545
-				// add any border color rules
1546
-				if(!empty($border)){
1547
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1548
-				}
1549
-				if(!empty($border_i)){
1550
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1551
-				}
1545
+                // add any border color rules
1546
+                if(!empty($border)){
1547
+                    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1548
+                }
1549
+                if(!empty($border_i)){
1550
+                    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1551
+                }
1552 1552
 
1553
-				// add any fill color rules
1554
-				if(!empty($fill)){
1555
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1556
-				}
1557
-				if(!empty($fill_i)){
1558
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1559
-				}
1553
+                // add any fill color rules
1554
+                if(!empty($fill)){
1555
+                    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1556
+                }
1557
+                if(!empty($fill_i)){
1558
+                    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1559
+                }
1560 1560
 
1561
-			}
1561
+            }
1562 1562
 
1563 1563
 
1564 1564
 
1565 1565
 
1566
-			$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;' : '';
1567
-			// darken
1568
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1569
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1570
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1571
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1566
+            $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;' : '';
1567
+            // darken
1568
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1569
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1570
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1571
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1572 1572
 
1573
-			// lighten
1574
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1573
+            // lighten
1574
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1575 1575
 
1576
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1577
-			$op_25 = $color_code."40"; // 25% opacity
1576
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1577
+            $op_25 = $color_code."40"; // 25% opacity
1578 1578
 
1579 1579
 
1580
-			// button states
1581
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1582
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1580
+            // button states
1581
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1582
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1583 1583
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1584
-			$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;} ";
1585
-			$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.";} ";
1584
+            $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;} ";
1585
+            $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.";} ";
1586 1586
             $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;} ";
1587 1587
             $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} ";
1588 1588
 
1589
-			// text
1589
+            // text
1590 1590
 //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
1591 1591
 
1592 1592
 
@@ -1601,777 +1601,777 @@  discard block
 block discarded – undo
1601 1601
 //				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1602 1602
 //			}
1603 1603
 
1604
-			// alerts
1605
-			if ( $aui_bs5 ) {
1604
+            // alerts
1605
+            if ( $aui_bs5 ) {
1606 1606
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1607
-				$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;} ";
1608
-			}
1609
-
1610
-			return $output;
1611
-		}
1612
-
1613
-		/**
1614
-		 * Build the CSS to overwrite a bootstrap color variable.
1615
-		 *
1616
-		 * @param $type
1617
-		 * @param $color_code
1618
-		 * @param $compatibility
1619
-		 *
1620
-		 * @return string
1621
-		 */
1622
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1607
+                $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;} ";
1608
+            }
1609
+
1610
+            return $output;
1611
+        }
1612
+
1613
+        /**
1614
+         * Build the CSS to overwrite a bootstrap color variable.
1615
+         *
1616
+         * @param $type
1617
+         * @param $color_code
1618
+         * @param $compatibility
1619
+         *
1620
+         * @return string
1621
+         */
1622
+        public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1623 1623
             global $aui_bs5;
1624 1624
 
1625
-			$is_var = false;
1626
-			if(!$color_code){return '';}
1627
-			if(strpos($color_code, 'var') !== false){
1628
-				//if(!sanitize_hex_color($color_code)){
1629
-				$color_code = esc_attr($color_code);
1630
-				$is_var = true;
1625
+            $is_var = false;
1626
+            if(!$color_code){return '';}
1627
+            if(strpos($color_code, 'var') !== false){
1628
+                //if(!sanitize_hex_color($color_code)){
1629
+                $color_code = esc_attr($color_code);
1630
+                $is_var = true;
1631 1631
 //				$color_code = "rgba($color_code, 0.5)";
1632 1632
 //                echo '###1'.$color_code.'###';//exit;
1633
-			}
1633
+            }
1634 1634
 
1635 1635
 //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1636 1636
 
1637
-			if(!$color_code){return '';}
1637
+            if(!$color_code){return '';}
1638 1638
 
1639 1639
             $rgb = self::hex_to_rgb($hex);
1640 1640
 
1641
-			if($compatibility===true || $compatibility===1){
1642
-				$compatibility = '.bsui';
1643
-			}elseif(!$compatibility){
1644
-				$compatibility = '';
1645
-			}else{
1646
-				$compatibility = esc_attr($compatibility);
1647
-			}
1641
+            if($compatibility===true || $compatibility===1){
1642
+                $compatibility = '.bsui';
1643
+            }elseif(!$compatibility){
1644
+                $compatibility = '';
1645
+            }else{
1646
+                $compatibility = esc_attr($compatibility);
1647
+            }
1648 1648
 
1649 1649
 
1650 1650
 
1651 1651
 //            echo '####'.$color_code;exit;
1652 1652
 
1653
-			$type = sanitize_html_class($type);
1654
-
1655
-			/**
1656
-			 * c = color, b = background color, o = border-color, f = fill
1657
-			 */
1658
-			$selectors = array(
1659
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1660
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1661
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1662
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1663
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1664
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1665
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1666
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1667
-				".badge-{$type}"                                            => array( 'b' ),
1668
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1669
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1670
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1671
-			);
1672
-
1673
-			if ( $aui_bs5 ) {
1653
+            $type = sanitize_html_class($type);
1654
+
1655
+            /**
1656
+             * c = color, b = background color, o = border-color, f = fill
1657
+             */
1658
+            $selectors = array(
1659
+                ".btn-{$type}"                                              => array( 'b', 'o' ),
1660
+                ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1661
+                ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1662
+                ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1663
+                ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1664
+                ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1665
+                ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1666
+                ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1667
+                ".badge-{$type}"                                            => array( 'b' ),
1668
+                ".alert-{$type}"                                            => array( 'b', 'o' ),
1669
+                ".bg-{$type}"                                               => array( 'b', 'f' ),
1670
+                ".btn-link.btn-{$type}"                                     => array( 'c' ),
1671
+            );
1672
+
1673
+            if ( $aui_bs5 ) {
1674 1674
                 unset($selectors[".alert-{$type}" ]);
1675
-			}
1676
-
1677
-			if ( $type == 'primary' ) {
1678
-				$selectors = $selectors + array(
1679
-						'a'                                                                                                    => array( 'c' ),
1680
-						'.btn-link'                                                                                            => array( 'c' ),
1681
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1682
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1683
-							'b',
1684
-							'o'
1685
-						),
1686
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1687
-							'b',
1688
-							'o'
1689
-						),
1690
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1691
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1692
-						'.page-link'                                                                                           => array( 'c' ),
1693
-						'.page-item.active .page-link'                                                                         => array(
1694
-							'b',
1695
-							'o'
1696
-						),
1697
-						'.progress-bar'                                                                                        => array( 'b' ),
1698
-						'.list-group-item.active'                                                                              => array(
1699
-							'b',
1700
-							'o'
1701
-						),
1702
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1675
+            }
1676
+
1677
+            if ( $type == 'primary' ) {
1678
+                $selectors = $selectors + array(
1679
+                        'a'                                                                                                    => array( 'c' ),
1680
+                        '.btn-link'                                                                                            => array( 'c' ),
1681
+                        '.dropdown-item.active'                                                                                => array( 'b' ),
1682
+                        '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1683
+                            'b',
1684
+                            'o'
1685
+                        ),
1686
+                        '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1687
+                            'b',
1688
+                            'o'
1689
+                        ),
1690
+                        '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1691
+                        '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1692
+                        '.page-link'                                                                                           => array( 'c' ),
1693
+                        '.page-item.active .page-link'                                                                         => array(
1694
+                            'b',
1695
+                            'o'
1696
+                        ),
1697
+                        '.progress-bar'                                                                                        => array( 'b' ),
1698
+                        '.list-group-item.active'                                                                              => array(
1699
+                            'b',
1700
+                            'o'
1701
+                        ),
1702
+                        '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1703 1703
 //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1704 1704
 //				    '.custom-range::-moz-range-thumb' => array('b'),
1705 1705
 //				    '.custom-range::-ms-thumb' => array('b'),
1706
-					);
1707
-			}
1708
-
1709
-			$important_selectors = array(
1710
-				".bg-{$type}" => array('b','f'),
1711
-				".border-{$type}" => array('o'),
1712
-				".text-{$type}" => array('c'),
1713
-			);
1714
-
1715
-			$color = array();
1716
-			$color_i = array();
1717
-			$background = array();
1718
-			$background_i = array();
1719
-			$border = array();
1720
-			$border_i = array();
1721
-			$fill = array();
1722
-			$fill_i = array();
1723
-
1724
-			$output = '';
1725
-
1726
-			if ( $aui_bs5 ) {
1706
+                    );
1707
+            }
1708
+
1709
+            $important_selectors = array(
1710
+                ".bg-{$type}" => array('b','f'),
1711
+                ".border-{$type}" => array('o'),
1712
+                ".text-{$type}" => array('c'),
1713
+            );
1714
+
1715
+            $color = array();
1716
+            $color_i = array();
1717
+            $background = array();
1718
+            $background_i = array();
1719
+            $border = array();
1720
+            $border_i = array();
1721
+            $fill = array();
1722
+            $fill_i = array();
1723
+
1724
+            $output = '';
1725
+
1726
+            if ( $aui_bs5 ) {
1727 1727
 //				$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).'; }';
1728
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1729
-			}
1730
-
1731
-			// build rules into each type
1732
-			foreach($selectors as $selector => $types){
1733
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1734
-				$types = array_combine($types,$types);
1735
-				if(isset($types['c'])){$color[] = $selector;}
1736
-				if(isset($types['b'])){$background[] = $selector;}
1737
-				if(isset($types['o'])){$border[] = $selector;}
1738
-				if(isset($types['f'])){$fill[] = $selector;}
1739
-			}
1740
-
1741
-			// build rules into each type
1742
-			foreach($important_selectors as $selector => $types){
1743
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1744
-				$types = array_combine($types,$types);
1745
-				if(isset($types['c'])){$color_i[] = $selector;}
1746
-				if(isset($types['b'])){$background_i[] = $selector;}
1747
-				if(isset($types['o'])){$border_i[] = $selector;}
1748
-				if(isset($types['f'])){$fill_i[] = $selector;}
1749
-			}
1750
-
1751
-			// add any color rules
1752
-			if(!empty($color)){
1753
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1754
-			}
1755
-			if(!empty($color_i)){
1756
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1757
-			}
1758
-
1759
-			// add any background color rules
1760
-			if(!empty($background)){
1761
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1762
-			}
1763
-			if(!empty($background_i)){
1764
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1728
+                $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1729
+            }
1730
+
1731
+            // build rules into each type
1732
+            foreach($selectors as $selector => $types){
1733
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1734
+                $types = array_combine($types,$types);
1735
+                if(isset($types['c'])){$color[] = $selector;}
1736
+                if(isset($types['b'])){$background[] = $selector;}
1737
+                if(isset($types['o'])){$border[] = $selector;}
1738
+                if(isset($types['f'])){$fill[] = $selector;}
1739
+            }
1740
+
1741
+            // build rules into each type
1742
+            foreach($important_selectors as $selector => $types){
1743
+                $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1744
+                $types = array_combine($types,$types);
1745
+                if(isset($types['c'])){$color_i[] = $selector;}
1746
+                if(isset($types['b'])){$background_i[] = $selector;}
1747
+                if(isset($types['o'])){$border_i[] = $selector;}
1748
+                if(isset($types['f'])){$fill_i[] = $selector;}
1749
+            }
1750
+
1751
+            // add any color rules
1752
+            if(!empty($color)){
1753
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1754
+            }
1755
+            if(!empty($color_i)){
1756
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1757
+            }
1758
+
1759
+            // add any background color rules
1760
+            if(!empty($background)){
1761
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1762
+            }
1763
+            if(!empty($background_i)){
1764
+                $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1765 1765
 //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1766
-			}
1766
+            }
1767 1767
 
1768
-			// add any border color rules
1769
-			if(!empty($border)){
1770
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1771
-			}
1772
-			if(!empty($border_i)){
1773
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1774
-			}
1768
+            // add any border color rules
1769
+            if(!empty($border)){
1770
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1771
+            }
1772
+            if(!empty($border_i)){
1773
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1774
+            }
1775 1775
 
1776
-			// add any fill color rules
1777
-			if(!empty($fill)){
1778
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1779
-			}
1780
-			if(!empty($fill_i)){
1781
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1782
-			}
1776
+            // add any fill color rules
1777
+            if(!empty($fill)){
1778
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1779
+            }
1780
+            if(!empty($fill_i)){
1781
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1782
+            }
1783 1783
 
1784 1784
 
1785
-			$prefix = $compatibility ? $compatibility . " " : "";
1785
+            $prefix = $compatibility ? $compatibility . " " : "";
1786 1786
 
1787
-			$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;' : '';
1788
-			// darken
1789
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1790
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1791
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1792
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1787
+            $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;' : '';
1788
+            // darken
1789
+            $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1790
+            $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1791
+            $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1792
+            $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1793 1793
 
1794
-			// lighten
1795
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1794
+            // lighten
1795
+            $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1796 1796
 
1797
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1798
-			$op_25 = $color_code."40"; // 25% opacity
1797
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1798
+            $op_25 = $color_code."40"; // 25% opacity
1799 1799
 
1800 1800
 
1801
-			// button states
1802
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1803
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1801
+            // button states
1802
+            $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1803
+            $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1804 1804
 //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1805
-			$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;} ";
1806
-			$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.";} ";
1807
-			$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;} ";
1805
+            $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;} ";
1806
+            $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.";} ";
1807
+            $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;} ";
1808 1808
 
1809
-			if ( $type == 'primary' ) {
1810
-				// dropdown's
1811
-				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1809
+            if ( $type == 'primary' ) {
1810
+                // dropdown's
1811
+                $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1812 1812
 
1813
-				// input states
1814
-				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1813
+                // input states
1814
+                $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1815 1815
 
1816
-				// page link
1817
-				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1818
-			}
1816
+                // page link
1817
+                $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1818
+            }
1819 1819
 
1820 1820
             // alerts
1821
-			if ( $aui_bs5 ) {
1821
+            if ( $aui_bs5 ) {
1822 1822
 //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1823
-				$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;} ";
1824
-			}
1825
-
1826
-			return $output;
1827
-		}
1828
-
1829
-		/**
1830
-		 *
1831
-		 * @deprecated 0.1.76 Use css_overwrite()
1832
-		 *
1833
-		 * @param $color_code
1834
-		 * @param $compatibility
1835
-		 * @param $use_variable
1836
-		 *
1837
-		 * @return string
1838
-		 */
1839
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1840
-
1841
-			if(!$use_variable){
1842
-				$color_code = sanitize_hex_color($color_code);
1843
-				if(!$color_code){return '';}
1844
-			}
1845
-
1846
-			/**
1847
-			 * c = color, b = background color, o = border-color, f = fill
1848
-			 */
1849
-			$selectors = array(
1850
-				'a' => array('c'),
1851
-				'.btn-primary' => array('b','o'),
1852
-				'.btn-primary.disabled' => array('b','o'),
1853
-				'.btn-primary:disabled' => array('b','o'),
1854
-				'.btn-outline-primary' => array('c','o'),
1855
-				'.btn-outline-primary:hover' => array('b','o'),
1856
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1857
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1858
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1859
-				'.btn-link' => array('c'),
1860
-				'.dropdown-item.active' => array('b'),
1861
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1862
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1823
+                $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;} ";
1824
+            }
1825
+
1826
+            return $output;
1827
+        }
1828
+
1829
+        /**
1830
+         *
1831
+         * @deprecated 0.1.76 Use css_overwrite()
1832
+         *
1833
+         * @param $color_code
1834
+         * @param $compatibility
1835
+         * @param $use_variable
1836
+         *
1837
+         * @return string
1838
+         */
1839
+        public static function css_primary($color_code,$compatibility, $use_variable = false){
1840
+
1841
+            if(!$use_variable){
1842
+                $color_code = sanitize_hex_color($color_code);
1843
+                if(!$color_code){return '';}
1844
+            }
1845
+
1846
+            /**
1847
+             * c = color, b = background color, o = border-color, f = fill
1848
+             */
1849
+            $selectors = array(
1850
+                'a' => array('c'),
1851
+                '.btn-primary' => array('b','o'),
1852
+                '.btn-primary.disabled' => array('b','o'),
1853
+                '.btn-primary:disabled' => array('b','o'),
1854
+                '.btn-outline-primary' => array('c','o'),
1855
+                '.btn-outline-primary:hover' => array('b','o'),
1856
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1857
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1858
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1859
+                '.btn-link' => array('c'),
1860
+                '.dropdown-item.active' => array('b'),
1861
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1862
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1863 1863
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1864 1864
 //				'.custom-range::-moz-range-thumb' => array('b'),
1865 1865
 //				'.custom-range::-ms-thumb' => array('b'),
1866
-				'.nav-pills .nav-link.active' => array('b'),
1867
-				'.nav-pills .show>.nav-link' => array('b'),
1868
-				'.page-link' => array('c'),
1869
-				'.page-item.active .page-link' => array('b','o'),
1870
-				'.badge-primary' => array('b'),
1871
-				'.alert-primary' => array('b','o'),
1872
-				'.progress-bar' => array('b'),
1873
-				'.list-group-item.active' => array('b','o'),
1874
-				'.bg-primary' => array('b','f'),
1875
-				'.btn-link.btn-primary' => array('c'),
1876
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1877
-			);
1878
-
1879
-			$important_selectors = array(
1880
-				'.bg-primary' => array('b','f'),
1881
-				'.border-primary' => array('o'),
1882
-				'.text-primary' => array('c'),
1883
-			);
1884
-
1885
-			$color = array();
1886
-			$color_i = array();
1887
-			$background = array();
1888
-			$background_i = array();
1889
-			$border = array();
1890
-			$border_i = array();
1891
-			$fill = array();
1892
-			$fill_i = array();
1893
-
1894
-			$output = '';
1895
-
1896
-			// build rules into each type
1897
-			foreach($selectors as $selector => $types){
1898
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1899
-				$types = array_combine($types,$types);
1900
-				if(isset($types['c'])){$color[] = $selector;}
1901
-				if(isset($types['b'])){$background[] = $selector;}
1902
-				if(isset($types['o'])){$border[] = $selector;}
1903
-				if(isset($types['f'])){$fill[] = $selector;}
1904
-			}
1905
-
1906
-			// build rules into each type
1907
-			foreach($important_selectors as $selector => $types){
1908
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1909
-				$types = array_combine($types,$types);
1910
-				if(isset($types['c'])){$color_i[] = $selector;}
1911
-				if(isset($types['b'])){$background_i[] = $selector;}
1912
-				if(isset($types['o'])){$border_i[] = $selector;}
1913
-				if(isset($types['f'])){$fill_i[] = $selector;}
1914
-			}
1915
-
1916
-			// add any color rules
1917
-			if(!empty($color)){
1918
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1919
-			}
1920
-			if(!empty($color_i)){
1921
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1922
-			}
1923
-
1924
-			// add any background color rules
1925
-			if(!empty($background)){
1926
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1927
-			}
1928
-			if(!empty($background_i)){
1929
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1930
-			}
1931
-
1932
-			// add any border color rules
1933
-			if(!empty($border)){
1934
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1935
-			}
1936
-			if(!empty($border_i)){
1937
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1938
-			}
1939
-
1940
-			// add any fill color rules
1941
-			if(!empty($fill)){
1942
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1943
-			}
1944
-			if(!empty($fill_i)){
1945
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1946
-			}
1947
-
1948
-
1949
-			$prefix = $compatibility ? ".bsui " : "";
1950
-
1951
-			// darken
1952
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1953
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1954
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1955
-
1956
-			// lighten
1957
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1958
-
1959
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1960
-			$op_25 = $color_code."40"; // 25% opacity
1961
-
1962
-
1963
-			// button states
1964
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1965
-			$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;} ";
1966
-			$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.";} ";
1967
-			$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;} ";
1968
-
1969
-
1970
-			// dropdown's
1971
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1972
-
1973
-
1974
-			// input states
1975
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1976
-
1977
-			// page link
1978
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1979
-
1980
-			return $output;
1981
-		}
1982
-
1983
-		/**
1984
-		 *
1985
-		 * @deprecated 0.1.76 Use css_overwrite()
1986
-		 *
1987
-		 * @param $color_code
1988
-		 * @param $compatibility
1989
-		 *
1990
-		 * @return string
1991
-		 */
1992
-		public static function css_secondary($color_code,$compatibility){;
1993
-			$color_code = sanitize_hex_color($color_code);
1994
-			if(!$color_code){return '';}
1995
-			/**
1996
-			 * c = color, b = background color, o = border-color, f = fill
1997
-			 */
1998
-			$selectors = array(
1999
-				'.btn-secondary' => array('b','o'),
2000
-				'.btn-secondary.disabled' => array('b','o'),
2001
-				'.btn-secondary:disabled' => array('b','o'),
2002
-				'.btn-outline-secondary' => array('c','o'),
2003
-				'.btn-outline-secondary:hover' => array('b','o'),
2004
-				'.btn-outline-secondary.disabled' => array('c'),
2005
-				'.btn-outline-secondary:disabled' => array('c'),
2006
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2007
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2008
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2009
-				'.badge-secondary' => array('b'),
2010
-				'.alert-secondary' => array('b','o'),
2011
-				'.btn-link.btn-secondary' => array('c'),
2012
-			);
2013
-
2014
-			$important_selectors = array(
2015
-				'.bg-secondary' => array('b','f'),
2016
-				'.border-secondary' => array('o'),
2017
-				'.text-secondary' => array('c'),
2018
-			);
2019
-
2020
-			$color = array();
2021
-			$color_i = array();
2022
-			$background = array();
2023
-			$background_i = array();
2024
-			$border = array();
2025
-			$border_i = array();
2026
-			$fill = array();
2027
-			$fill_i = array();
2028
-
2029
-			$output = '';
2030
-
2031
-			// build rules into each type
2032
-			foreach($selectors as $selector => $types){
2033
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2034
-				$types = array_combine($types,$types);
2035
-				if(isset($types['c'])){$color[] = $selector;}
2036
-				if(isset($types['b'])){$background[] = $selector;}
2037
-				if(isset($types['o'])){$border[] = $selector;}
2038
-				if(isset($types['f'])){$fill[] = $selector;}
2039
-			}
2040
-
2041
-			// build rules into each type
2042
-			foreach($important_selectors as $selector => $types){
2043
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2044
-				$types = array_combine($types,$types);
2045
-				if(isset($types['c'])){$color_i[] = $selector;}
2046
-				if(isset($types['b'])){$background_i[] = $selector;}
2047
-				if(isset($types['o'])){$border_i[] = $selector;}
2048
-				if(isset($types['f'])){$fill_i[] = $selector;}
2049
-			}
2050
-
2051
-			// add any color rules
2052
-			if(!empty($color)){
2053
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2054
-			}
2055
-			if(!empty($color_i)){
2056
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2057
-			}
2058
-
2059
-			// add any background color rules
2060
-			if(!empty($background)){
2061
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2062
-			}
2063
-			if(!empty($background_i)){
2064
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2065
-			}
2066
-
2067
-			// add any border color rules
2068
-			if(!empty($border)){
2069
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2070
-			}
2071
-			if(!empty($border_i)){
2072
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2073
-			}
2074
-
2075
-			// add any fill color rules
2076
-			if(!empty($fill)){
2077
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2078
-			}
2079
-			if(!empty($fill_i)){
2080
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2081
-			}
2082
-
2083
-
2084
-			$prefix = $compatibility ? ".bsui " : "";
2085
-
2086
-			// darken
2087
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2088
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2089
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2090
-
2091
-			// lighten
2092
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2093
-
2094
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2095
-			$op_25 = $color_code."40"; // 25% opacity
2096
-
2097
-
2098
-			// button states
2099
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2100
-			$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;} ";
2101
-			$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.";} ";
2102
-			$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;} ";
2103
-
2104
-
2105
-			return $output;
2106
-		}
2107
-
2108
-		/**
2109
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
2110
-		 *
2111
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2112
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2113
-		 *
2114
-		 * @return  string
2115
-		 */
2116
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2117
-			$hexCode = ltrim($hexCode, '#');
2118
-
2119
-			if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) {
2120
-				return $hexCode;
2121
-			}
2122
-
2123
-			if (strlen($hexCode) == 3) {
2124
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2125
-			}
2126
-
2127
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
2128
-
2129
-			foreach ($hexCode as & $color) {
2130
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2131
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
2132
-
2133
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2134
-			}
2135
-
2136
-			return '#' . implode($hexCode);
2137
-		}
2138
-
2139
-		/**
2140
-		 * Check if we should display examples.
2141
-		 */
2142
-		public function maybe_show_examples(){
2143
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2144
-				echo "<head>";
2145
-				wp_head();
2146
-				echo "</head>";
2147
-				echo "<body>";
2148
-				echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2149
-				echo "</body>";
2150
-				exit;
2151
-			}
2152
-		}
2153
-
2154
-		/**
2155
-		 * Get developer examples.
2156
-		 *
2157
-		 * @return string
2158
-		 */
2159
-		public function get_examples(){
2160
-			$output = '';
2161
-
2162
-
2163
-			// open form
2164
-			$output .= "<form class='p-5 m-5 border rounded'>";
2165
-
2166
-			// input example
2167
-			$output .= aui()->input(array(
2168
-				'type'  =>  'text',
2169
-				'id'    =>  'text-example',
2170
-				'name'    =>  'text-example',
2171
-				'placeholder'   => 'text placeholder',
2172
-				'title'   => 'Text input example',
2173
-				'value' =>  '',
2174
-				'required'  => false,
2175
-				'help_text' => 'help text',
2176
-				'label' => 'Text input example label'
2177
-			));
2178
-
2179
-			// input example
2180
-			$output .= aui()->input(array(
2181
-				'type'  =>  'url',
2182
-				'id'    =>  'text-example2',
2183
-				'name'    =>  'text-example',
2184
-				'placeholder'   => 'url placeholder',
2185
-				'title'   => 'Text input example',
2186
-				'value' =>  '',
2187
-				'required'  => false,
2188
-				'help_text' => 'help text',
2189
-				'label' => 'Text input example label'
2190
-			));
2191
-
2192
-			// checkbox example
2193
-			$output .= aui()->input(array(
2194
-				'type'  =>  'checkbox',
2195
-				'id'    =>  'checkbox-example',
2196
-				'name'    =>  'checkbox-example',
2197
-				'placeholder'   => 'checkbox-example',
2198
-				'title'   => 'Checkbox example',
2199
-				'value' =>  '1',
2200
-				'checked'   => true,
2201
-				'required'  => false,
2202
-				'help_text' => 'help text',
2203
-				'label' => 'Checkbox checked'
2204
-			));
2205
-
2206
-			// checkbox example
2207
-			$output .= aui()->input(array(
2208
-				'type'  =>  'checkbox',
2209
-				'id'    =>  'checkbox-example2',
2210
-				'name'    =>  'checkbox-example2',
2211
-				'placeholder'   => 'checkbox-example',
2212
-				'title'   => 'Checkbox example',
2213
-				'value' =>  '1',
2214
-				'checked'   => false,
2215
-				'required'  => false,
2216
-				'help_text' => 'help text',
2217
-				'label' => 'Checkbox un-checked'
2218
-			));
2219
-
2220
-			// switch example
2221
-			$output .= aui()->input(array(
2222
-				'type'  =>  'checkbox',
2223
-				'id'    =>  'switch-example',
2224
-				'name'    =>  'switch-example',
2225
-				'placeholder'   => 'checkbox-example',
2226
-				'title'   => 'Switch example',
2227
-				'value' =>  '1',
2228
-				'checked'   => true,
2229
-				'switch'    => true,
2230
-				'required'  => false,
2231
-				'help_text' => 'help text',
2232
-				'label' => 'Switch on'
2233
-			));
2234
-
2235
-			// switch example
2236
-			$output .= aui()->input(array(
2237
-				'type'  =>  'checkbox',
2238
-				'id'    =>  'switch-example2',
2239
-				'name'    =>  'switch-example2',
2240
-				'placeholder'   => 'checkbox-example',
2241
-				'title'   => 'Switch example',
2242
-				'value' =>  '1',
2243
-				'checked'   => false,
2244
-				'switch'    => true,
2245
-				'required'  => false,
2246
-				'help_text' => 'help text',
2247
-				'label' => 'Switch off'
2248
-			));
2249
-
2250
-			// close form
2251
-			$output .= "</form>";
2252
-
2253
-			return $output;
2254
-		}
2255
-
2256
-		/**
2257
-		 * Calendar params.
2258
-		 *
2259
-		 * @since 0.1.44
2260
-		 *
2261
-		 * @return array Calendar params.
2262
-		 */
2263
-		public static function calendar_params() {
2264
-			$params = array(
2265
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2266
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2267
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2268
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2269
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2270
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2271
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2272
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2273
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2274
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2275
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2276
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2277
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2278
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2279
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2280
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2281
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2282
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2283
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2284
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2285
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2286
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2287
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2288
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2289
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2290
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2291
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2292
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2293
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2294
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2295
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2296
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2297
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2298
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2299
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2300
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2301
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2302
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2303
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2304
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2305
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2306
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2307
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2308
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2309
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2310
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2311
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2312
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2313
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2314
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2315
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2316
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2317
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2318
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2319
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2320
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2321
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2322
-				'time_24hr' => false,
2323
-				'year' => __( 'Year', 'ayecode-connect' ),
2324
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2325
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2326
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2327
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2328
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2329
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2330
-			);
2331
-
2332
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2333
-		}
2334
-
2335
-		/**
2336
-		 * Flatpickr calendar localize.
2337
-		 *
2338
-		 * @since 0.1.44
2339
-		 *
2340
-		 * @return string Calendar locale.
2341
-		 */
2342
-		public static function flatpickr_locale() {
2343
-			$params = self::calendar_params();
2344
-
2345
-			if ( is_string( $params ) ) {
2346
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2347
-			} else {
2348
-				foreach ( (array) $params as $key => $value ) {
2349
-					if ( ! is_scalar( $value ) ) {
2350
-						continue;
2351
-					}
2352
-
2353
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2354
-				}
2355
-			}
1866
+                '.nav-pills .nav-link.active' => array('b'),
1867
+                '.nav-pills .show>.nav-link' => array('b'),
1868
+                '.page-link' => array('c'),
1869
+                '.page-item.active .page-link' => array('b','o'),
1870
+                '.badge-primary' => array('b'),
1871
+                '.alert-primary' => array('b','o'),
1872
+                '.progress-bar' => array('b'),
1873
+                '.list-group-item.active' => array('b','o'),
1874
+                '.bg-primary' => array('b','f'),
1875
+                '.btn-link.btn-primary' => array('c'),
1876
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1877
+            );
1878
+
1879
+            $important_selectors = array(
1880
+                '.bg-primary' => array('b','f'),
1881
+                '.border-primary' => array('o'),
1882
+                '.text-primary' => array('c'),
1883
+            );
1884
+
1885
+            $color = array();
1886
+            $color_i = array();
1887
+            $background = array();
1888
+            $background_i = array();
1889
+            $border = array();
1890
+            $border_i = array();
1891
+            $fill = array();
1892
+            $fill_i = array();
1893
+
1894
+            $output = '';
1895
+
1896
+            // build rules into each type
1897
+            foreach($selectors as $selector => $types){
1898
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1899
+                $types = array_combine($types,$types);
1900
+                if(isset($types['c'])){$color[] = $selector;}
1901
+                if(isset($types['b'])){$background[] = $selector;}
1902
+                if(isset($types['o'])){$border[] = $selector;}
1903
+                if(isset($types['f'])){$fill[] = $selector;}
1904
+            }
1905
+
1906
+            // build rules into each type
1907
+            foreach($important_selectors as $selector => $types){
1908
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1909
+                $types = array_combine($types,$types);
1910
+                if(isset($types['c'])){$color_i[] = $selector;}
1911
+                if(isset($types['b'])){$background_i[] = $selector;}
1912
+                if(isset($types['o'])){$border_i[] = $selector;}
1913
+                if(isset($types['f'])){$fill_i[] = $selector;}
1914
+            }
1915
+
1916
+            // add any color rules
1917
+            if(!empty($color)){
1918
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1919
+            }
1920
+            if(!empty($color_i)){
1921
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1922
+            }
1923
+
1924
+            // add any background color rules
1925
+            if(!empty($background)){
1926
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1927
+            }
1928
+            if(!empty($background_i)){
1929
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1930
+            }
1931
+
1932
+            // add any border color rules
1933
+            if(!empty($border)){
1934
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1935
+            }
1936
+            if(!empty($border_i)){
1937
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1938
+            }
1939
+
1940
+            // add any fill color rules
1941
+            if(!empty($fill)){
1942
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1943
+            }
1944
+            if(!empty($fill_i)){
1945
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1946
+            }
1947
+
1948
+
1949
+            $prefix = $compatibility ? ".bsui " : "";
1950
+
1951
+            // darken
1952
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1953
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1954
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1955
+
1956
+            // lighten
1957
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1958
+
1959
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1960
+            $op_25 = $color_code."40"; // 25% opacity
1961
+
1962
+
1963
+            // button states
1964
+            $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1965
+            $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;} ";
1966
+            $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.";} ";
1967
+            $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;} ";
2356 1968
 
2357
-			$day_s3 = array();
2358
-			$day_s5 = array();
2359 1969
 
2360
-			for ( $i = 1; $i <= 7; $i ++ ) {
2361
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2363
-			}
1970
+            // dropdown's
1971
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
2364 1972
 
2365
-			$month_s = array();
2366
-			$month_long = array();
2367 1973
 
2368
-			for ( $i = 1; $i <= 12; $i ++ ) {
2369
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2371
-			}
1974
+            // input states
1975
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
2372 1976
 
2373
-			ob_start();
2374
-		if ( 0 ) { ?><script><?php } ?>
1977
+            // page link
1978
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1979
+
1980
+            return $output;
1981
+        }
1982
+
1983
+        /**
1984
+         *
1985
+         * @deprecated 0.1.76 Use css_overwrite()
1986
+         *
1987
+         * @param $color_code
1988
+         * @param $compatibility
1989
+         *
1990
+         * @return string
1991
+         */
1992
+        public static function css_secondary($color_code,$compatibility){;
1993
+            $color_code = sanitize_hex_color($color_code);
1994
+            if(!$color_code){return '';}
1995
+            /**
1996
+             * c = color, b = background color, o = border-color, f = fill
1997
+             */
1998
+            $selectors = array(
1999
+                '.btn-secondary' => array('b','o'),
2000
+                '.btn-secondary.disabled' => array('b','o'),
2001
+                '.btn-secondary:disabled' => array('b','o'),
2002
+                '.btn-outline-secondary' => array('c','o'),
2003
+                '.btn-outline-secondary:hover' => array('b','o'),
2004
+                '.btn-outline-secondary.disabled' => array('c'),
2005
+                '.btn-outline-secondary:disabled' => array('c'),
2006
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2007
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2008
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2009
+                '.badge-secondary' => array('b'),
2010
+                '.alert-secondary' => array('b','o'),
2011
+                '.btn-link.btn-secondary' => array('c'),
2012
+            );
2013
+
2014
+            $important_selectors = array(
2015
+                '.bg-secondary' => array('b','f'),
2016
+                '.border-secondary' => array('o'),
2017
+                '.text-secondary' => array('c'),
2018
+            );
2019
+
2020
+            $color = array();
2021
+            $color_i = array();
2022
+            $background = array();
2023
+            $background_i = array();
2024
+            $border = array();
2025
+            $border_i = array();
2026
+            $fill = array();
2027
+            $fill_i = array();
2028
+
2029
+            $output = '';
2030
+
2031
+            // build rules into each type
2032
+            foreach($selectors as $selector => $types){
2033
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2034
+                $types = array_combine($types,$types);
2035
+                if(isset($types['c'])){$color[] = $selector;}
2036
+                if(isset($types['b'])){$background[] = $selector;}
2037
+                if(isset($types['o'])){$border[] = $selector;}
2038
+                if(isset($types['f'])){$fill[] = $selector;}
2039
+            }
2040
+
2041
+            // build rules into each type
2042
+            foreach($important_selectors as $selector => $types){
2043
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
2044
+                $types = array_combine($types,$types);
2045
+                if(isset($types['c'])){$color_i[] = $selector;}
2046
+                if(isset($types['b'])){$background_i[] = $selector;}
2047
+                if(isset($types['o'])){$border_i[] = $selector;}
2048
+                if(isset($types['f'])){$fill_i[] = $selector;}
2049
+            }
2050
+
2051
+            // add any color rules
2052
+            if(!empty($color)){
2053
+                $output .= implode(",",$color) . "{color: $color_code;} ";
2054
+            }
2055
+            if(!empty($color_i)){
2056
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2057
+            }
2058
+
2059
+            // add any background color rules
2060
+            if(!empty($background)){
2061
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
2062
+            }
2063
+            if(!empty($background_i)){
2064
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2065
+            }
2066
+
2067
+            // add any border color rules
2068
+            if(!empty($border)){
2069
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
2070
+            }
2071
+            if(!empty($border_i)){
2072
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2073
+            }
2074
+
2075
+            // add any fill color rules
2076
+            if(!empty($fill)){
2077
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
2078
+            }
2079
+            if(!empty($fill_i)){
2080
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2081
+            }
2082
+
2083
+
2084
+            $prefix = $compatibility ? ".bsui " : "";
2085
+
2086
+            // darken
2087
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2088
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2089
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2090
+
2091
+            // lighten
2092
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2093
+
2094
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
2095
+            $op_25 = $color_code."40"; // 25% opacity
2096
+
2097
+
2098
+            // button states
2099
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2100
+            $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;} ";
2101
+            $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.";} ";
2102
+            $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;} ";
2103
+
2104
+
2105
+            return $output;
2106
+        }
2107
+
2108
+        /**
2109
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
2110
+         *
2111
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
2112
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
2113
+         *
2114
+         * @return  string
2115
+         */
2116
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2117
+            $hexCode = ltrim($hexCode, '#');
2118
+
2119
+            if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) {
2120
+                return $hexCode;
2121
+            }
2122
+
2123
+            if (strlen($hexCode) == 3) {
2124
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2125
+            }
2126
+
2127
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
2128
+
2129
+            foreach ($hexCode as & $color) {
2130
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2131
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
2132
+
2133
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2134
+            }
2135
+
2136
+            return '#' . implode($hexCode);
2137
+        }
2138
+
2139
+        /**
2140
+         * Check if we should display examples.
2141
+         */
2142
+        public function maybe_show_examples(){
2143
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2144
+                echo "<head>";
2145
+                wp_head();
2146
+                echo "</head>";
2147
+                echo "<body>";
2148
+                echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2149
+                echo "</body>";
2150
+                exit;
2151
+            }
2152
+        }
2153
+
2154
+        /**
2155
+         * Get developer examples.
2156
+         *
2157
+         * @return string
2158
+         */
2159
+        public function get_examples(){
2160
+            $output = '';
2161
+
2162
+
2163
+            // open form
2164
+            $output .= "<form class='p-5 m-5 border rounded'>";
2165
+
2166
+            // input example
2167
+            $output .= aui()->input(array(
2168
+                'type'  =>  'text',
2169
+                'id'    =>  'text-example',
2170
+                'name'    =>  'text-example',
2171
+                'placeholder'   => 'text placeholder',
2172
+                'title'   => 'Text input example',
2173
+                'value' =>  '',
2174
+                'required'  => false,
2175
+                'help_text' => 'help text',
2176
+                'label' => 'Text input example label'
2177
+            ));
2178
+
2179
+            // input example
2180
+            $output .= aui()->input(array(
2181
+                'type'  =>  'url',
2182
+                'id'    =>  'text-example2',
2183
+                'name'    =>  'text-example',
2184
+                'placeholder'   => 'url placeholder',
2185
+                'title'   => 'Text input example',
2186
+                'value' =>  '',
2187
+                'required'  => false,
2188
+                'help_text' => 'help text',
2189
+                'label' => 'Text input example label'
2190
+            ));
2191
+
2192
+            // checkbox example
2193
+            $output .= aui()->input(array(
2194
+                'type'  =>  'checkbox',
2195
+                'id'    =>  'checkbox-example',
2196
+                'name'    =>  'checkbox-example',
2197
+                'placeholder'   => 'checkbox-example',
2198
+                'title'   => 'Checkbox example',
2199
+                'value' =>  '1',
2200
+                'checked'   => true,
2201
+                'required'  => false,
2202
+                'help_text' => 'help text',
2203
+                'label' => 'Checkbox checked'
2204
+            ));
2205
+
2206
+            // checkbox example
2207
+            $output .= aui()->input(array(
2208
+                'type'  =>  'checkbox',
2209
+                'id'    =>  'checkbox-example2',
2210
+                'name'    =>  'checkbox-example2',
2211
+                'placeholder'   => 'checkbox-example',
2212
+                'title'   => 'Checkbox example',
2213
+                'value' =>  '1',
2214
+                'checked'   => false,
2215
+                'required'  => false,
2216
+                'help_text' => 'help text',
2217
+                'label' => 'Checkbox un-checked'
2218
+            ));
2219
+
2220
+            // switch example
2221
+            $output .= aui()->input(array(
2222
+                'type'  =>  'checkbox',
2223
+                'id'    =>  'switch-example',
2224
+                'name'    =>  'switch-example',
2225
+                'placeholder'   => 'checkbox-example',
2226
+                'title'   => 'Switch example',
2227
+                'value' =>  '1',
2228
+                'checked'   => true,
2229
+                'switch'    => true,
2230
+                'required'  => false,
2231
+                'help_text' => 'help text',
2232
+                'label' => 'Switch on'
2233
+            ));
2234
+
2235
+            // switch example
2236
+            $output .= aui()->input(array(
2237
+                'type'  =>  'checkbox',
2238
+                'id'    =>  'switch-example2',
2239
+                'name'    =>  'switch-example2',
2240
+                'placeholder'   => 'checkbox-example',
2241
+                'title'   => 'Switch example',
2242
+                'value' =>  '1',
2243
+                'checked'   => false,
2244
+                'switch'    => true,
2245
+                'required'  => false,
2246
+                'help_text' => 'help text',
2247
+                'label' => 'Switch off'
2248
+            ));
2249
+
2250
+            // close form
2251
+            $output .= "</form>";
2252
+
2253
+            return $output;
2254
+        }
2255
+
2256
+        /**
2257
+         * Calendar params.
2258
+         *
2259
+         * @since 0.1.44
2260
+         *
2261
+         * @return array Calendar params.
2262
+         */
2263
+        public static function calendar_params() {
2264
+            $params = array(
2265
+                'month_long_1' => __( 'January', 'ayecode-connect' ),
2266
+                'month_long_2' => __( 'February', 'ayecode-connect' ),
2267
+                'month_long_3' => __( 'March', 'ayecode-connect' ),
2268
+                'month_long_4' => __( 'April', 'ayecode-connect' ),
2269
+                'month_long_5' => __( 'May', 'ayecode-connect' ),
2270
+                'month_long_6' => __( 'June', 'ayecode-connect' ),
2271
+                'month_long_7' => __( 'July', 'ayecode-connect' ),
2272
+                'month_long_8' => __( 'August', 'ayecode-connect' ),
2273
+                'month_long_9' => __( 'September', 'ayecode-connect' ),
2274
+                'month_long_10' => __( 'October', 'ayecode-connect' ),
2275
+                'month_long_11' => __( 'November', 'ayecode-connect' ),
2276
+                'month_long_12' => __( 'December', 'ayecode-connect' ),
2277
+                'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2278
+                'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2279
+                'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2280
+                'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2281
+                'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2282
+                'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2283
+                'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2284
+                'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2285
+                'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2286
+                'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2287
+                'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2288
+                'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2289
+                'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2290
+                'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2291
+                'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2292
+                'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2293
+                'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2294
+                'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2295
+                'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2296
+                'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2297
+                'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2298
+                'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2299
+                'day_s2_4' => __( 'We', 'ayecode-connect' ),
2300
+                'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2301
+                'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2302
+                'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2303
+                'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2304
+                'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2305
+                'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2306
+                'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2307
+                'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2308
+                'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2309
+                'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2310
+                'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2311
+                'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2312
+                'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2313
+                'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2314
+                'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2315
+                'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2316
+                'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2317
+                'am_lower' => __( 'am', 'ayecode-connect' ),
2318
+                'pm_lower' => __( 'pm', 'ayecode-connect' ),
2319
+                'am_upper' => __( 'AM', 'ayecode-connect' ),
2320
+                'pm_upper' => __( 'PM', 'ayecode-connect' ),
2321
+                'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2322
+                'time_24hr' => false,
2323
+                'year' => __( 'Year', 'ayecode-connect' ),
2324
+                'hour' => __( 'Hour', 'ayecode-connect' ),
2325
+                'minute' => __( 'Minute', 'ayecode-connect' ),
2326
+                'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2327
+                'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2328
+                'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2329
+                'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2330
+            );
2331
+
2332
+            return apply_filters( 'ayecode_ui_calendar_params', $params );
2333
+        }
2334
+
2335
+        /**
2336
+         * Flatpickr calendar localize.
2337
+         *
2338
+         * @since 0.1.44
2339
+         *
2340
+         * @return string Calendar locale.
2341
+         */
2342
+        public static function flatpickr_locale() {
2343
+            $params = self::calendar_params();
2344
+
2345
+            if ( is_string( $params ) ) {
2346
+                $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2347
+            } else {
2348
+                foreach ( (array) $params as $key => $value ) {
2349
+                    if ( ! is_scalar( $value ) ) {
2350
+                        continue;
2351
+                    }
2352
+
2353
+                    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2354
+                }
2355
+            }
2356
+
2357
+            $day_s3 = array();
2358
+            $day_s5 = array();
2359
+
2360
+            for ( $i = 1; $i <= 7; $i ++ ) {
2361
+                $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
+                $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2363
+            }
2364
+
2365
+            $month_s = array();
2366
+            $month_long = array();
2367
+
2368
+            for ( $i = 1; $i <= 12; $i ++ ) {
2369
+                $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
+                $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2371
+            }
2372
+
2373
+            ob_start();
2374
+        if ( 0 ) { ?><script><?php } ?>
2375 2375
                 {
2376 2376
                     weekdays: {
2377 2377
                         shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
@@ -2410,189 +2410,189 @@  discard block
 block discarded – undo
2410 2410
                 }
2411 2411
 				<?php if ( 0 ) { ?></script><?php } ?>
2412 2412
 			<?php
2413
-			$locale = ob_get_clean();
2414
-
2415
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2416
-		}
2417
-
2418
-		/**
2419
-		 * Select2 JS params.
2420
-		 *
2421
-		 * @since 0.1.44
2422
-		 *
2423
-		 * @return array Select2 JS params.
2424
-		 */
2425
-		public static function select2_params() {
2426
-			$params = array(
2427
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2428
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2429
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2430
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2431
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2432
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2433
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2434
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2435
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2436
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2437
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2438
-			);
2439
-
2440
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2441
-		}
2442
-
2443
-		/**
2444
-		 * Select2 JS localize.
2445
-		 *
2446
-		 * @since 0.1.44
2447
-		 *
2448
-		 * @return string Select2 JS locale.
2449
-		 */
2450
-		public static function select2_locale() {
2451
-			$params = self::select2_params();
2452
-
2453
-			foreach ( (array) $params as $key => $value ) {
2454
-				if ( ! is_scalar( $value ) ) {
2455
-					continue;
2456
-				}
2413
+            $locale = ob_get_clean();
2457 2414
 
2458
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2459
-			}
2460
-
2461
-			$locale = json_encode( $params );
2462
-
2463
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2464
-		}
2465
-
2466
-		/**
2467
-		 * Time ago JS localize.
2468
-		 *
2469
-		 * @since 0.1.47
2470
-		 *
2471
-		 * @return string Time ago JS locale.
2472
-		 */
2473
-		public static function timeago_locale() {
2474
-			$params = array(
2475
-				'prefix_ago' => '',
2476
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2477
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2478
-				'suffix_after' => '',
2479
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2480
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2481
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2482
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2483
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2484
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2485
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2486
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2487
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2488
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2489
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2490
-			);
2491
-
2492
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2493
-
2494
-			foreach ( (array) $params as $key => $value ) {
2495
-				if ( ! is_scalar( $value ) ) {
2496
-					continue;
2497
-				}
2415
+            return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2416
+        }
2417
+
2418
+        /**
2419
+         * Select2 JS params.
2420
+         *
2421
+         * @since 0.1.44
2422
+         *
2423
+         * @return array Select2 JS params.
2424
+         */
2425
+        public static function select2_params() {
2426
+            $params = array(
2427
+                'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2428
+                'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2429
+                'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2430
+                'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2431
+                'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2432
+                'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2433
+                'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2434
+                'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2435
+                'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2436
+                'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2437
+                'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2438
+            );
2439
+
2440
+            return apply_filters( 'ayecode_ui_select2_params', $params );
2441
+        }
2442
+
2443
+        /**
2444
+         * Select2 JS localize.
2445
+         *
2446
+         * @since 0.1.44
2447
+         *
2448
+         * @return string Select2 JS locale.
2449
+         */
2450
+        public static function select2_locale() {
2451
+            $params = self::select2_params();
2452
+
2453
+            foreach ( (array) $params as $key => $value ) {
2454
+                if ( ! is_scalar( $value ) ) {
2455
+                    continue;
2456
+                }
2457
+
2458
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2459
+            }
2460
+
2461
+            $locale = json_encode( $params );
2462
+
2463
+            return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2464
+        }
2465
+
2466
+        /**
2467
+         * Time ago JS localize.
2468
+         *
2469
+         * @since 0.1.47
2470
+         *
2471
+         * @return string Time ago JS locale.
2472
+         */
2473
+        public static function timeago_locale() {
2474
+            $params = array(
2475
+                'prefix_ago' => '',
2476
+                'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2477
+                'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2478
+                'suffix_after' => '',
2479
+                'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2480
+                'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2481
+                'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2482
+                'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2483
+                'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2484
+                'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2485
+                'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2486
+                'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2487
+                'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2488
+                'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2489
+                'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2490
+            );
2491
+
2492
+            $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2493
+
2494
+            foreach ( (array) $params as $key => $value ) {
2495
+                if ( ! is_scalar( $value ) ) {
2496
+                    continue;
2497
+                }
2498
+
2499
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2500
+            }
2498 2501
 
2499
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2500
-			}
2501
-
2502
-			$locale = json_encode( $params );
2503
-
2504
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2505
-		}
2506
-
2507
-		/**
2508
-		 * JavaScript Minifier
2509
-		 *
2510
-		 * @param $input
2511
-		 *
2512
-		 * @return mixed
2513
-		 */
2514
-		public static function minify_js($input) {
2515
-			if(trim($input) === "") return $input;
2516
-			return preg_replace(
2517
-				array(
2518
-					// Remove comment(s)
2519
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2520
-					// Remove white-space(s) outside the string and regex
2521
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2522
-					// Remove the last semicolon
2523
-					'#;+\}#',
2524
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2525
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2526
-					// --ibid. From `foo['bar']` to `foo.bar`
2527
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2528
-				),
2529
-				array(
2530
-					'$1',
2531
-					'$1$2',
2532
-					'}',
2533
-					'$1$3',
2534
-					'$1.$3'
2535
-				),
2536
-				$input);
2537
-		}
2538
-
2539
-		/**
2540
-		 * Minify CSS
2541
-		 *
2542
-		 * @param $input
2543
-		 *
2544
-		 * @return mixed
2545
-		 */
2546
-		public static function minify_css($input) {
2547
-			if(trim($input) === "") return $input;
2548
-			return preg_replace(
2549
-				array(
2550
-					// Remove comment(s)
2551
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2552
-					// Remove unused white-space(s)
2553
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2554
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2555
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2556
-					// Replace `:0 0 0 0` with `:0`
2557
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2558
-					// Replace `background-position:0` with `background-position:0 0`
2559
-					'#(background-position):0(?=[;\}])#si',
2560
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2561
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2562
-					// Minify string value
2563
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2564
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2565
-					// Minify HEX color code
2566
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2567
-					// Replace `(border|outline):none` with `(border|outline):0`
2568
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2569
-					// Remove empty selector(s)
2570
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2571
-				),
2572
-				array(
2573
-					'$1',
2574
-					'$1$2$3$4$5$6$7',
2575
-					'$1',
2576
-					':0',
2577
-					'$1:0 0',
2578
-					'.$1',
2579
-					'$1$3',
2580
-					'$1$2$4$5',
2581
-					'$1$2$3',
2582
-					'$1:0',
2583
-					'$1$2'
2584
-				),
2585
-				$input);
2586
-		}
2587
-
2588
-		/**
2589
-		 * Get the conditional fields JavaScript.
2590
-		 *
2591
-		 * @return mixed
2592
-		 */
2593
-		public function conditional_fields_js() {
2594
-			ob_start();
2595
-			?>
2502
+            $locale = json_encode( $params );
2503
+
2504
+            return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2505
+        }
2506
+
2507
+        /**
2508
+         * JavaScript Minifier
2509
+         *
2510
+         * @param $input
2511
+         *
2512
+         * @return mixed
2513
+         */
2514
+        public static function minify_js($input) {
2515
+            if(trim($input) === "") return $input;
2516
+            return preg_replace(
2517
+                array(
2518
+                    // Remove comment(s)
2519
+                    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2520
+                    // Remove white-space(s) outside the string and regex
2521
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2522
+                    // Remove the last semicolon
2523
+                    '#;+\}#',
2524
+                    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2525
+                    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2526
+                    // --ibid. From `foo['bar']` to `foo.bar`
2527
+                    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2528
+                ),
2529
+                array(
2530
+                    '$1',
2531
+                    '$1$2',
2532
+                    '}',
2533
+                    '$1$3',
2534
+                    '$1.$3'
2535
+                ),
2536
+                $input);
2537
+        }
2538
+
2539
+        /**
2540
+         * Minify CSS
2541
+         *
2542
+         * @param $input
2543
+         *
2544
+         * @return mixed
2545
+         */
2546
+        public static function minify_css($input) {
2547
+            if(trim($input) === "") return $input;
2548
+            return preg_replace(
2549
+                array(
2550
+                    // Remove comment(s)
2551
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2552
+                    // Remove unused white-space(s)
2553
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2554
+                    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2555
+                    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2556
+                    // Replace `:0 0 0 0` with `:0`
2557
+                    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2558
+                    // Replace `background-position:0` with `background-position:0 0`
2559
+                    '#(background-position):0(?=[;\}])#si',
2560
+                    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2561
+                    '#(?<=[\s:,\-])0+\.(\d+)#s',
2562
+                    // Minify string value
2563
+                    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2564
+                    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2565
+                    // Minify HEX color code
2566
+                    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2567
+                    // Replace `(border|outline):none` with `(border|outline):0`
2568
+                    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2569
+                    // Remove empty selector(s)
2570
+                    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2571
+                ),
2572
+                array(
2573
+                    '$1',
2574
+                    '$1$2$3$4$5$6$7',
2575
+                    '$1',
2576
+                    ':0',
2577
+                    '$1:0 0',
2578
+                    '.$1',
2579
+                    '$1$3',
2580
+                    '$1$2$4$5',
2581
+                    '$1$2$3',
2582
+                    '$1:0',
2583
+                    '$1$2'
2584
+                ),
2585
+                $input);
2586
+        }
2587
+
2588
+        /**
2589
+         * Get the conditional fields JavaScript.
2590
+         *
2591
+         * @return mixed
2592
+         */
2593
+        public function conditional_fields_js() {
2594
+            ob_start();
2595
+            ?>
2596 2596
             <script>
2597 2597
                 /**
2598 2598
                  * Conditional Fields
@@ -3124,14 +3124,14 @@  discard block
 block discarded – undo
3124 3124
 				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3125 3125
             </script>
3126 3126
 			<?php
3127
-			$output = ob_get_clean();
3127
+            $output = ob_get_clean();
3128 3128
 
3129
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3130
-		}
3131
-	}
3129
+            return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3130
+        }
3131
+    }
3132 3132
 
3133
-	/**
3134
-	 * Run the class if found.
3135
-	 */
3136
-	AyeCode_UI_Settings::instance();
3133
+    /**
3134
+     * Run the class if found.
3135
+     */
3136
+    AyeCode_UI_Settings::instance();
3137 3137
 }
3138 3138
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +1917 added lines, -1917 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php
1
+    <?php
2 2
 /**
3 3
  * A class for adjusting AyeCode UI settings on WordPress
4 4
  *
@@ -12,84 +12,84 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
15
+    if ( ! defined( 'ABSPATH' ) ) {
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.
26 26
 	 *
27 27
 	 * Class AyeCode_UI_Settings
28 28
 	 * @ver 1.0.0
29 29
 	 * @todo decide how to implement textdomain
30 30
 	 */
31
-	class AyeCode_UI_Settings {
31
+	    class AyeCode_UI_Settings {
32 32
 
33
-		/**
33
+		    /**
34 34
 		 * Class version version.
35 35
 		 *
36 36
 		 * @var string
37 37
 		 */
38
-		public $version = '0.2.26';
38
+		    public $version = '0.2.26';
39 39
 
40
-		/**
40
+		    /**
41 41
 		 * Class textdomain.
42 42
 		 *
43 43
 		 * @var string
44 44
 		 */
45
-		public $textdomain = 'aui';
45
+		    public $textdomain = 'aui';
46 46
 
47
-		/**
47
+		    /**
48 48
 		 * Latest version of Bootstrap at time of publish published.
49 49
 		 *
50 50
 		 * @var string
51 51
 		 */
52
-		public $latest = "5.2.2";
52
+		    public $latest = "5.2.2";
53 53
 
54
-		/**
54
+		    /**
55 55
 		 * Current version of select2 being used.
56 56
 		 *
57 57
 		 * @var string
58 58
 		 */
59
-		public $select2_version = "4.0.11";
59
+		    public $select2_version = "4.0.11";
60 60
 
61
-		/**
61
+		    /**
62 62
 		 * The title.
63 63
 		 *
64 64
 		 * @var string
65 65
 		 */
66
-		public $name = 'AyeCode UI';
66
+		    public $name = 'AyeCode UI';
67 67
 
68
-		/**
68
+		    /**
69 69
 		 * The relative url to the assets.
70 70
 		 *
71 71
 		 * @var string
72 72
 		 */
73
-		public $url = '';
73
+		    public $url = '';
74 74
 
75
-		/**
75
+		    /**
76 76
 		 * Holds the settings values.
77 77
 		 *
78 78
 		 * @var array
79 79
 		 */
80
-		private $settings;
80
+		    private $settings;
81 81
 
82
-		/**
82
+		    /**
83 83
 		 * AyeCode_UI_Settings instance.
84 84
 		 *
85 85
 		 * @access private
86 86
 		 * @since  1.0.0
87 87
 		 * @var    AyeCode_UI_Settings There can be only one!
88 88
 		 */
89
-		private static $instance = null;
89
+		    private static $instance = null;
90 90
 
91 91
 
92
-		/**
92
+		    /**
93 93
 		 * Main AyeCode_UI_Settings Instance.
94 94
 		 *
95 95
 		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
@@ -98,34 +98,34 @@  discard block
 block discarded – undo
98 98
 		 * @static
99 99
 		 * @return AyeCode_UI_Settings - Main instance.
100 100
 		 */
101
-		public static function instance() {
102
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
101
+		    public static function instance() {
102
+			    if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
103 103
 
104
-				self::$instance = new AyeCode_UI_Settings;
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
-					// Maybe show example page
113
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
112
+					    // Maybe show example page
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 );
117
-					}
118
-				}
115
+					    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
116
+						    add_filter( 'sd_aui_colors', array( self::$instance,'sd_aui_colors' ), 10, 3 );
117
+					    }
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' );
123
-			}
122
+				    do_action( 'ayecode_ui_settings_loaded' );
123
+			    }
124 124
 
125
-			return self::$instance;
126
-		}
125
+			    return self::$instance;
126
+		    }
127 127
 
128
-		/**
128
+		    /**
129 129
 		 * Add custom colors to the color selector.
130 130
 		 *
131 131
 		 * @param $theme_colors
@@ -134,367 +134,367 @@  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
-			$setting = wp_get_global_settings();
140
+			    $setting = wp_get_global_settings();
141 141
 
142
-			if(!empty($setting['color']['palette']['custom'])){
143
-				foreach($setting['color']['palette']['custom'] as $color){
144
-					$theme_colors[$color['slug']] = esc_attr($color['name']);
145
-				}
146
-			}
142
+			    if(!empty($setting['color']['palette']['custom'])){
143
+				    foreach($setting['color']['palette']['custom'] as $color){
144
+					    $theme_colors[$color['slug']] = esc_attr($color['name']);
145
+				    }
146
+			    }
147 147
 
148
-			return $theme_colors;
149
-		}
148
+			    return $theme_colors;
149
+		    }
150 150
 
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' );
171
-
172
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
-				define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
-			}
175
-			if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
-				define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
-			}
178
-			if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
-				define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
-			}
181
-			if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
-				define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
-			}
184
-			if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
-				define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
-			}
187
-			if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
-				define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
-			}
190
-			if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
-				define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
-			}
193
-			if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
-				define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
-			}
196
-			if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
-				define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
-			}
199
-			if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
-				define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
-			}
202
-			if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
-				define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
-			}
205
-			if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
-				define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
-			}
208
-			if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
-				define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
-			}
211
-			if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
-				define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
-			}
214
-			if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
-				define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
-			}
217
-			if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
-				define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
-			}
220
-
221
-		}
222
-
223
-		public static function get_colors( $original = false){
224
-
225
-			if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
-				return array();
227
-			}
228
-			if ( $original ) {
229
-				return array(
230
-					'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
-					'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
-					'info'      => AUI_INFO_COLOR_ORIGINAL,
233
-					'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
-					'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
-					'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
-					'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
-					'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
-					'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
-					'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
-					'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
-					'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
-					'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
-					'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
-					'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
-					'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
-				);
247
-			}
248
-
249
-			return array(
250
-				'primary'   => AUI_PRIMARY_COLOR,
251
-				'secondary' => AUI_SECONDARY_COLOR,
252
-				'info'      => AUI_INFO_COLOR,
253
-				'warning'   => AUI_WARNING_COLOR,
254
-				'danger'    => AUI_DANGER_COLOR,
255
-				'success'   => AUI_SUCCESS_COLOR,
256
-				'light'     => AUI_LIGHT_COLOR,
257
-				'dark'      => AUI_DARK_COLOR,
258
-				'white'     => AUI_WHITE_COLOR,
259
-				'purple'    => AUI_PURPLE_COLOR,
260
-				'salmon'    => AUI_SALMON_COLOR,
261
-				'cyan'      => AUI_CYAN_COLOR,
262
-				'gray'      => AUI_GRAY_COLOR,
263
-				'indigo'    => AUI_INDIGO_COLOR,
264
-				'orange'    => AUI_ORANGE_COLOR,
265
-				'black'     => AUI_BLACK_COLOR,
266
-			);
267
-		}
268
-
269
-		/**
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
+
172
+			    if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
173
+				    define( 'AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL );
174
+			    }
175
+			    if ( ! defined( 'AUI_SECONDARY_COLOR' ) ) {
176
+				    define( 'AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL );
177
+			    }
178
+			    if ( ! defined( 'AUI_INFO_COLOR' ) ) {
179
+				    define( 'AUI_INFO_COLOR', AUI_INFO_COLOR_ORIGINAL );
180
+			    }
181
+			    if ( ! defined( 'AUI_WARNING_COLOR' ) ) {
182
+				    define( 'AUI_WARNING_COLOR', AUI_WARNING_COLOR_ORIGINAL );
183
+			    }
184
+			    if ( ! defined( 'AUI_DANGER_COLOR' ) ) {
185
+				    define( 'AUI_DANGER_COLOR', AUI_DANGER_COLOR_ORIGINAL );
186
+			    }
187
+			    if ( ! defined( 'AUI_SUCCESS_COLOR' ) ) {
188
+				    define( 'AUI_SUCCESS_COLOR', AUI_SUCCESS_COLOR_ORIGINAL );
189
+			    }
190
+			    if ( ! defined( 'AUI_LIGHT_COLOR' ) ) {
191
+				    define( 'AUI_LIGHT_COLOR', AUI_LIGHT_COLOR_ORIGINAL );
192
+			    }
193
+			    if ( ! defined( 'AUI_DARK_COLOR' ) ) {
194
+				    define( 'AUI_DARK_COLOR', AUI_DARK_COLOR_ORIGINAL );
195
+			    }
196
+			    if ( ! defined( 'AUI_WHITE_COLOR' ) ) {
197
+				    define( 'AUI_WHITE_COLOR', AUI_WHITE_COLOR_ORIGINAL );
198
+			    }
199
+			    if ( ! defined( 'AUI_PURPLE_COLOR' ) ) {
200
+				    define( 'AUI_PURPLE_COLOR', AUI_PURPLE_COLOR_ORIGINAL );
201
+			    }
202
+			    if ( ! defined( 'AUI_SALMON_COLOR' ) ) {
203
+				    define( 'AUI_SALMON_COLOR', AUI_SALMON_COLOR_ORIGINAL );
204
+			    }
205
+			    if ( ! defined( 'AUI_CYAN_COLOR' ) ) {
206
+				    define( 'AUI_CYAN_COLOR', AUI_CYAN_COLOR_ORIGINAL );
207
+			    }
208
+			    if ( ! defined( 'AUI_GRAY_COLOR' ) ) {
209
+				    define( 'AUI_GRAY_COLOR', AUI_GRAY_COLOR_ORIGINAL );
210
+			    }
211
+			    if ( ! defined( 'AUI_INDIGO_COLOR' ) ) {
212
+				    define( 'AUI_INDIGO_COLOR', AUI_INDIGO_COLOR_ORIGINAL );
213
+			    }
214
+			    if ( ! defined( 'AUI_ORANGE_COLOR' ) ) {
215
+				    define( 'AUI_ORANGE_COLOR', AUI_ORANGE_COLOR_ORIGINAL );
216
+			    }
217
+			    if ( ! defined( 'AUI_BLACK_COLOR' ) ) {
218
+				    define( 'AUI_BLACK_COLOR', AUI_BLACK_COLOR_ORIGINAL );
219
+			    }
220
+
221
+		    }
222
+
223
+		    public static function get_colors( $original = false){
224
+
225
+			    if ( ! defined( 'AUI_PRIMARY_COLOR' ) ) {
226
+				    return array();
227
+			    }
228
+			    if ( $original ) {
229
+				    return array(
230
+					    'primary'   => AUI_PRIMARY_COLOR_ORIGINAL,
231
+					    'secondary' => AUI_SECONDARY_COLOR_ORIGINAL,
232
+					    'info'      => AUI_INFO_COLOR_ORIGINAL,
233
+					    'warning'   => AUI_WARNING_COLOR_ORIGINAL,
234
+					    'danger'    => AUI_DANGER_COLOR_ORIGINAL,
235
+					    'success'   => AUI_SUCCESS_COLOR_ORIGINAL,
236
+					    'light'     => AUI_LIGHT_COLOR_ORIGINAL,
237
+					    'dark'      => AUI_DARK_COLOR_ORIGINAL,
238
+					    'white'     => AUI_WHITE_COLOR_ORIGINAL,
239
+					    'purple'    => AUI_PURPLE_COLOR_ORIGINAL,
240
+					    'salmon'    => AUI_SALMON_COLOR_ORIGINAL,
241
+					    'cyan'      => AUI_CYAN_COLOR_ORIGINAL,
242
+					    'gray'      => AUI_GRAY_COLOR_ORIGINAL,
243
+					    'indigo'    => AUI_INDIGO_COLOR_ORIGINAL,
244
+					    'orange'    => AUI_ORANGE_COLOR_ORIGINAL,
245
+					    'black'     => AUI_BLACK_COLOR_ORIGINAL,
246
+				    );
247
+			    }
248
+
249
+			    return array(
250
+				    'primary'   => AUI_PRIMARY_COLOR,
251
+				    'secondary' => AUI_SECONDARY_COLOR,
252
+				    'info'      => AUI_INFO_COLOR,
253
+				    'warning'   => AUI_WARNING_COLOR,
254
+				    'danger'    => AUI_DANGER_COLOR,
255
+				    'success'   => AUI_SUCCESS_COLOR,
256
+				    'light'     => AUI_LIGHT_COLOR,
257
+				    'dark'      => AUI_DARK_COLOR,
258
+				    'white'     => AUI_WHITE_COLOR,
259
+				    'purple'    => AUI_PURPLE_COLOR,
260
+				    'salmon'    => AUI_SALMON_COLOR,
261
+				    'cyan'      => AUI_CYAN_COLOR,
262
+				    'gray'      => AUI_GRAY_COLOR,
263
+				    'indigo'    => AUI_INDIGO_COLOR,
264
+				    'orange'    => AUI_ORANGE_COLOR,
265
+				    'black'     => AUI_BLACK_COLOR,
266
+			    );
267
+		    }
268
+
269
+		    /**
270 270
 		 * Add admin body class to show when BS5 is active.
271 271
 		 *
272 272
 		 * @param $classes
273 273
 		 *
274 274
 		 * @return mixed
275 275
 		 */
276
-		public function add_bs5_admin_body_class( $classes = '' ) {
277
-			$classes .= ' aui_bs5';
276
+		    public function add_bs5_admin_body_class( $classes = '' ) {
277
+			    $classes .= ' aui_bs5';
278 278
 
279
-			return $classes;
280
-		}
279
+			    return $classes;
280
+		    }
281 281
 
282
-		/**
282
+		    /**
283 283
 		 * Add a body class to show when BS5 is active.
284 284
 		 *
285 285
 		 * @param $classes
286 286
 		 *
287 287
 		 * @return mixed
288 288
 		 */
289
-		public function add_bs5_body_class( $classes ) {
290
-			$classes[] = 'aui_bs5';
289
+		    public function add_bs5_body_class( $classes ) {
290
+			    $classes[] = 'aui_bs5';
291 291
 
292
-			return $classes;
293
-		}
292
+			    return $classes;
293
+		    }
294 294
 
295
-		/**
295
+		    /**
296 296
 		 * Initiate the settings and add the required action hooks.
297 297
 		 */
298
-		public function init() {
299
-            global $aui_bs5;
300
-
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 ) ) {
305
-					$db_settings['css_backend'] = 'compatibility';
306
-					$db_settings['js_backend'] = 'core-popper';
307
-					update_option( 'ayecode-ui-settings', $db_settings );
308
-					wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
-				}
310
-			}
311
-
312
-			$this->constants();
313
-			$this->settings = $this->get_settings();
314
-			$this->url = $this->get_url();
315
-
316
-            // define the version
317
-			$aui_bs5 = $this->settings['bs_ver'] === '5';
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' ) );
323
-			}
324
-
325
-			/**
298
+		    public function init() {
299
+                global $aui_bs5;
300
+
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 ) ) {
305
+					    $db_settings['css_backend'] = 'compatibility';
306
+					    $db_settings['js_backend'] = 'core-popper';
307
+					    update_option( 'ayecode-ui-settings', $db_settings );
308
+					    wp_safe_redirect(admin_url("options-general.php?page=ayecode-ui-settings&updated=true"));
309
+				    }
310
+			    }
311
+
312
+			    $this->constants();
313
+			    $this->settings = $this->get_settings();
314
+			    $this->url = $this->get_url();
315
+
316
+                // define the version
317
+			    $aui_bs5 = $this->settings['bs_ver'] === '5';
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' ) );
323
+			    }
324
+
325
+			    /**
326 326
 			 * Maybe load CSS
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'] ) {
331
-				$priority = $this->is_bs3_compat() ? 100 : 1;
332
-                $priority = $aui_bs5 ? 10 : $priority;
333
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
-			}
335
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
-			}
338
-
339
-			// maybe load JS
340
-			if ( $this->settings['js'] ) {
341
-				$priority = $this->is_bs3_compat() ? 100 : 1;
342
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
-			}
344
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
-			}
347
-
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 );
351
-			}
352
-
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' ) );
356
-			}
357
-
358
-		}
359
-
360
-		/**
330
+			    if ( $this->settings['css'] ) {
331
+				    $priority = $this->is_bs3_compat() ? 100 : 1;
332
+                    $priority = $aui_bs5 ? 10 : $priority;
333
+				    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), $priority );
334
+			    }
335
+			    if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
336
+				    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
337
+			    }
338
+
339
+			    // maybe load JS
340
+			    if ( $this->settings['js'] ) {
341
+				    $priority = $this->is_bs3_compat() ? 100 : 1;
342
+				    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
343
+			    }
344
+			    if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
345
+				    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
346
+			    }
347
+
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 );
351
+			    }
352
+
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' ) );
356
+			    }
357
+
358
+		    }
359
+
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>'. wp_kses_post( $message ).'</p></div>';
368
-		}
369
-
370
-		/**
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>'. wp_kses_post( $message ).'</p></div>';
368
+		    }
369
+
370
+		    /**
371 371
 		 * Check if we should load the admin scripts or not.
372 372
 		 *
373 373
 		 * @return bool
374 374
 		 */
375
-		public function load_admin_scripts(){
376
-			$result = true;
377
-
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 ){
383
-						return false; // return early, no point checking further
384
-					}
385
-				}
386
-			}
387
-
388
-			return $result;
389
-		}
390
-
391
-		/**
375
+		    public function load_admin_scripts(){
376
+			    $result = true;
377
+
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 ){
383
+						    return false; // return early, no point checking further
384
+					    }
385
+				    }
386
+			    }
387
+
388
+			    return $result;
389
+		    }
390
+
391
+		    /**
392 392
 		 * Add a html font size to the footer.
393 393
 		 */
394
-		public function html_font_size(){
395
-			$this->settings = $this->get_settings();
396
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
-		}
394
+		    public function html_font_size(){
395
+			    $this->settings = $this->get_settings();
396
+			    echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
397
+		    }
398 398
 
399
-		/**
399
+		    /**
400 400
 		 * Check if the current admin screen should load scripts.
401 401
 		 *
402 402
 		 * @return bool
403 403
 		 */
404
-		public function is_aui_screen(){
405
-//			echo '###';exit;
406
-			$load = false;
407
-			// check if we should load or not
408
-			if ( is_admin() ) {
409
-				// Only enable on set pages
410
-				$aui_screens = array(
411
-					'page',
412
-                    //'docs',
413
-					'post',
414
-					'settings_page_ayecode-ui-settings',
415
-					'appearance_page_gutenberg-widgets',
416
-					'widgets',
417
-					'ayecode-ui-settings',
418
-					'site-editor'
419
-				);
420
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
421
-
422
-				$screen = get_current_screen();
423
-
424
-//				echo '###'.$screen->id;
425
-
426
-				// check if we are on a AUI screen
427
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
-					$load = true;
429
-				}
430
-
431
-				//load for widget previews in WP 5.8
432
-				if( !empty($_REQUEST['legacy-widget-preview'])){
433
-					$load = true;
434
-				}
435
-			}
436
-
437
-
438
-
439
-			return apply_filters( 'aui_load_on_admin' , $load );
440
-		}
441
-
442
-		/**
404
+		    public function is_aui_screen(){
405
+    //			echo '###';exit;
406
+			    $load = false;
407
+			    // check if we should load or not
408
+			    if ( is_admin() ) {
409
+				    // Only enable on set pages
410
+				    $aui_screens = array(
411
+					    'page',
412
+                        //'docs',
413
+					    'post',
414
+					    'settings_page_ayecode-ui-settings',
415
+					    'appearance_page_gutenberg-widgets',
416
+					    'widgets',
417
+					    'ayecode-ui-settings',
418
+					    'site-editor'
419
+				    );
420
+				    $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
421
+
422
+				    $screen = get_current_screen();
423
+
424
+    //				echo '###'.$screen->id;
425
+
426
+				    // check if we are on a AUI screen
427
+				    if ( $screen && in_array( $screen->id, $screen_ids ) ) {
428
+					    $load = true;
429
+				    }
430
+
431
+				    //load for widget previews in WP 5.8
432
+				    if( !empty($_REQUEST['legacy-widget-preview'])){
433
+					    $load = true;
434
+				    }
435
+			    }
436
+
437
+
438
+
439
+			    return apply_filters( 'aui_load_on_admin' , $load );
440
+		    }
441
+
442
+		    /**
443 443
 		 * Check if the current theme is a block theme.
444 444
 		 *
445 445
 		 * @return bool
446 446
 		 */
447
-		public static function is_block_theme() {
448
-			if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
-				return true;
450
-			}
447
+		    public static function is_block_theme() {
448
+			    if ( function_exists( 'wp_is_block_theme' && wp_is_block_theme() ) ) {
449
+				    return true;
450
+			    }
451 451
 
452
-			return false;
453
-		}
452
+			    return false;
453
+		    }
454 454
 
455
-		/**
455
+		    /**
456 456
 		 * Adds the styles.
457 457
 		 */
458
-		public function enqueue_style() {
459
-            global $aui_bs5;
458
+		    public function enqueue_style() {
459
+                global $aui_bs5;
460 460
 
461
-            $load_fse = false;
461
+                $load_fse = false;
462 462
 
463
-			if( is_admin() && !$this->is_aui_screen()){
464
-				// don't add wp-admin scripts if not requested to
465
-			}else{
466
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
463
+			    if( is_admin() && !$this->is_aui_screen()){
464
+				    // don't add wp-admin scripts if not requested to
465
+			    }else{
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
-                $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
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
-//					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' );
488
-						$load_fse = true;
489
-					}
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' );
488
+						    $load_fse = true;
489
+					    }
490 490
 
491 491
 
492
-					// flatpickr
493
-					wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
492
+					    // flatpickr
493
+					    wp_register_style( 'flatpickr', $this->url.'assets'.$bs_ver.'/css/flatpickr.min.css', array(), $this->version );
494 494
 
495
-					// fix some wp-admin issues
496
-					if(is_admin()){
497
-						$custom_css = "
495
+					    // fix some wp-admin issues
496
+					    if(is_admin()){
497
+						    $custom_css = "
498 498
                 body{
499 499
                     background-color: #f1f1f1;
500 500
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -535,88 +535,88 @@  discard block
 block discarded – undo
535 535
 				}
536 536
                 ";
537 537
 
538
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
-						$custom_css .= "
538
+						    // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
539
+						    $custom_css .= "
540 540
 						.edit-post-sidebar input[type=color].components-text-control__input{
541 541
 						    padding: 0;
542 542
 						}
543 543
 					";
544
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
545
-					}
544
+						    wp_add_inline_style( 'ayecode-ui', $custom_css );
545
+					    }
546 546
 
547
-					// custom changes
548
-					if ( $load_fse ) {
549
-						wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
-					}else{
551
-						wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
547
+					    // custom changes
548
+					    if ( $load_fse ) {
549
+						    wp_add_inline_style( 'ayecode-ui-fse', self::custom_css($compatibility) );
550
+					    }else{
551
+						    wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
552 552
 
553
-					}
553
+					    }
554 554
 
555
-				}
556
-			}
555
+				    }
556
+			    }
557 557
 
558 558
 
559
-		}
559
+		    }
560 560
 
561
-		/**
561
+		    /**
562 562
 		 * Get inline script used if bootstrap enqueued
563 563
 		 *
564 564
 		 * If this remains small then its best to use this than to add another JS file.
565 565
 		 */
566
-		public function inline_script() {
567
-            global $aui_bs5;
568
-			// Flatpickr calendar locale
569
-			$flatpickr_locale = self::flatpickr_locale();
570
-
571
-			ob_start();
572
-			if ( $aui_bs5 ) {
573
-				include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
-			}else{
575
-				include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
576
-            }
566
+		    public function inline_script() {
567
+                global $aui_bs5;
568
+			    // Flatpickr calendar locale
569
+			    $flatpickr_locale = self::flatpickr_locale();
570
+
571
+			    ob_start();
572
+			    if ( $aui_bs5 ) {
573
+				    include_once( dirname( __FILE__ ) . '/inc/bs5-js.php' );
574
+			    }else{
575
+				    include_once( dirname( __FILE__ ) . '/inc/bs4-js.php' );
576
+                }
577 577
 
578
-			$output = ob_get_clean();
578
+			    $output = ob_get_clean();
579 579
 
580
-			/*
580
+			    /*
581 581
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
582 582
 			 */
583
-			return str_replace( array(
584
-				'<script>',
585
-				'</script>'
586
-			), '', self::minify_js($output) );
587
-		}
583
+			    return str_replace( array(
584
+				    '<script>',
585
+				    '</script>'
586
+			    ), '', self::minify_js($output) );
587
+		    }
588 588
 
589 589
 
590
-		/**
590
+		    /**
591 591
 		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
592 592
 		 *
593 593
 		 * @TODO we may need this when other conflicts arrise.
594 594
 		 * @return mixed
595 595
 		 */
596
-		public static function bs3_compat_js() {
597
-			ob_start();
598
-			?>
599
-            <script>
596
+		    public static function bs3_compat_js() {
597
+			    ob_start();
598
+			    ?>
599
+                <script>
600 600
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
601
-                /* With Avada builder */
601
+                    /* With Avada builder */
602 602
 
603 603
 				<?php } ?>
604
-            </script>
604
+                </script>
605 605
 			<?php
606
-			return str_replace( array(
607
-				'<script>',
608
-				'</script>'
609
-			), '', ob_get_clean());
610
-		}
606
+			    return str_replace( array(
607
+				    '<script>',
608
+				    '</script>'
609
+			    ), '', ob_get_clean());
610
+		    }
611 611
 
612
-		/**
612
+		    /**
613 613
 		 * Get inline script used if bootstrap file browser enqueued.
614 614
 		 *
615 615
 		 * If this remains small then its best to use this than to add another JS file.
616 616
 		 */
617
-		public function inline_script_file_browser(){
618
-			ob_start();
619
-			?>
617
+		    public function inline_script_file_browser(){
618
+			    ob_start();
619
+			    ?>
620 620
             <script>
621 621
                 // run on doc ready
622 622
                 jQuery(document).ready(function () {
@@ -624,282 +624,282 @@  discard block
 block discarded – undo
624 624
                 });
625 625
             </script>
626 626
 			<?php
627
-			$output = ob_get_clean();
627
+			    $output = ob_get_clean();
628 628
 
629
-			/*
629
+			    /*
630 630
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
631 631
 			 */
632
-			return str_replace( array(
633
-				'<script>',
634
-				'</script>'
635
-			), '', $output );
636
-		}
632
+			    return str_replace( array(
633
+				    '<script>',
634
+				    '</script>'
635
+			    ), '', $output );
636
+		    }
637 637
 
638
-		/**
638
+		    /**
639 639
 		 * Adds the Font Awesome JS.
640 640
 		 */
641
-		public function enqueue_scripts() {
642
-
643
-			if( is_admin() && !$this->is_aui_screen()){
644
-				// don't add wp-admin scripts if not requested to
645
-			}else {
646
-
647
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648
-
649
-				$bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650
-
651
-				// select2
652
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
653
-
654
-				// flatpickr
655
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
656
-
657
-				// iconpicker
658
-				if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
-					wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
-				}else{
661
-					wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
-				}
663
-
664
-				// Bootstrap file browser
665
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
-
668
-				$load_inline = false;
669
-
670
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
-					// Bootstrap bundle
672
-					$url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
674
-						'select2',
675
-						'jquery'
676
-					), $this->version, $this->is_bs3_compat() );
677
-					// if in admin then add to footer for compatibility.
678
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
-					$script = $this->inline_script();
680
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
-					$url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
-					wp_enqueue_script( 'bootstrap-js-popper' );
685
-					$load_inline = true;
686
-				} else {
687
-					$load_inline = true;
688
-				}
689
-
690
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
-				if ( $load_inline ) {
692
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
-					wp_enqueue_script( 'bootstrap-dummy' );
694
-					$script = $this->inline_script();
695
-					wp_add_inline_script( 'bootstrap-dummy', $script );
696
-				}
697
-			}
698
-
699
-		}
700
-
701
-		/**
641
+		    public function enqueue_scripts() {
642
+
643
+			    if( is_admin() && !$this->is_aui_screen()){
644
+				    // don't add wp-admin scripts if not requested to
645
+			    }else {
646
+
647
+				    $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
648
+
649
+				    $bs_ver = $this->settings['bs_ver'] == '5' ? '-v5' : '';
650
+
651
+				    // select2
652
+				    wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
653
+
654
+				    // flatpickr
655
+				    wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->version );
656
+
657
+				    // iconpicker
658
+				    if ( defined( 'FAS_ICONPICKER_JS_URL' ) ) {
659
+					    wp_register_script( 'iconpicker', FAS_ICONPICKER_JS_URL, array(), $this->version );
660
+				    }else{
661
+					    wp_register_script( 'iconpicker', $this->url . 'assets/js/fa-iconpicker.min.js', array(), $this->version );
662
+				    }
663
+
664
+				    // Bootstrap file browser
665
+				    wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
666
+				    wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
667
+
668
+				    $load_inline = false;
669
+
670
+				    if ( $this->settings[ $js_setting ] == 'core-popper' ) {
671
+					    // Bootstrap bundle
672
+					    $url = $this->url . 'assets' . $bs_ver . '/js/bootstrap.bundle.min.js';
673
+					    wp_register_script( 'bootstrap-js-bundle', $url, array(
674
+						    'select2',
675
+						    'jquery'
676
+					    ), $this->version, $this->is_bs3_compat() );
677
+					    // if in admin then add to footer for compatibility.
678
+					    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
679
+					    $script = $this->inline_script();
680
+					    wp_add_inline_script( 'bootstrap-js-bundle', $script );
681
+				    } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
682
+					    $url = $this->url . 'assets/js/popper.min.js'; //@todo we need to update this to bs5
683
+					    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->version );
684
+					    wp_enqueue_script( 'bootstrap-js-popper' );
685
+					    $load_inline = true;
686
+				    } else {
687
+					    $load_inline = true;
688
+				    }
689
+
690
+				    // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
691
+				    if ( $load_inline ) {
692
+					    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
693
+					    wp_enqueue_script( 'bootstrap-dummy' );
694
+					    $script = $this->inline_script();
695
+					    wp_add_inline_script( 'bootstrap-dummy', $script );
696
+				    }
697
+			    }
698
+
699
+		    }
700
+
701
+		    /**
702 702
 		 * Enqueue flatpickr if called.
703 703
 		 */
704
-		public function enqueue_flatpickr(){
705
-			wp_enqueue_style( 'flatpickr' );
706
-			wp_enqueue_script( 'flatpickr' );
707
-		}
704
+		    public function enqueue_flatpickr(){
705
+			    wp_enqueue_style( 'flatpickr' );
706
+			    wp_enqueue_script( 'flatpickr' );
707
+		    }
708 708
 
709
-		/**
709
+		    /**
710 710
 		 * Enqueue iconpicker if called.
711 711
 		 */
712
-		public function enqueue_iconpicker(){
713
-			wp_enqueue_style( 'iconpicker' );
714
-			wp_enqueue_script( 'iconpicker' );
715
-		}
712
+		    public function enqueue_iconpicker(){
713
+			    wp_enqueue_style( 'iconpicker' );
714
+			    wp_enqueue_script( 'iconpicker' );
715
+		    }
716 716
 
717
-		/**
717
+		    /**
718 718
 		 * Get the url path to the current folder.
719 719
 		 *
720 720
 		 * @return string
721 721
 		 */
722
-		public function get_url() {
723
-			$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
-			$content_url = untrailingslashit( WP_CONTENT_URL );
722
+		    public function get_url() {
723
+			    $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
724
+			    $content_url = untrailingslashit( WP_CONTENT_URL );
725 725
 
726
-			// Replace http:// to https://.
727
-			if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
-				$content_url = str_replace( 'http://', 'https://', $content_url );
729
-			}
726
+			    // Replace http:// to https://.
727
+			    if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
728
+				    $content_url = str_replace( 'http://', 'https://', $content_url );
729
+			    }
730 730
 
731
-			// Check if we are inside a plugin
732
-			$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
-			$url = str_replace( $content_dir, $content_url, $file_dir );
731
+			    // Check if we are inside a plugin
732
+			    $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
733
+			    $url = str_replace( $content_dir, $content_url, $file_dir );
734 734
 
735
-			return trailingslashit( $url );
736
-		}
735
+			    return trailingslashit( $url );
736
+		    }
737 737
 
738
-		/**
738
+		    /**
739 739
 		 * Get the url path to the current folder.
740 740
 		 *
741 741
 		 * @return string
742 742
 		 */
743
-		public function get_url_old() {
743
+		    public function get_url_old() {
744 744
 
745
-			$url = '';
746
-			// check if we are inside a plugin
747
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
745
+			    $url = '';
746
+			    // check if we are inside a plugin
747
+			    $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
748 748
 
749
-			// add check in-case user has changed wp-content dir name.
750
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
751
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
749
+			    // add check in-case user has changed wp-content dir name.
750
+			    $wp_content_folder_name = basename(WP_CONTENT_DIR);
751
+			    $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
752
+			    $url_parts = explode("/$wp_content_folder_name/",plugins_url());
753 753
 
754
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
-			}
754
+			    if(!empty($url_parts[0]) && !empty($dir_parts[1])){
755
+				    $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
756
+			    }
757 757
 
758
-			return $url;
759
-		}
758
+			    return $url;
759
+		    }
760 760
 
761
-		/**
761
+		    /**
762 762
 		 * Register the database settings with WordPress.
763 763
 		 */
764
-		public function register_settings() {
765
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
-		}
764
+		    public function register_settings() {
765
+			    register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
766
+		    }
767 767
 
768
-		/**
768
+		    /**
769 769
 		 * Add the WordPress settings menu item.
770 770
 		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
771 771
 		 */
772
-		public function menu_item() {
773
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
-				$this,
776
-				'settings_page'
777
-			) );
778
-		}
779
-
780
-		/**
772
+		    public function menu_item() {
773
+			    $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
774
+			    call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
775
+				    $this,
776
+				    'settings_page'
777
+			    ) );
778
+		    }
779
+
780
+		    /**
781 781
 		 * Get a list of themes and their default JS settings.
782 782
 		 *
783 783
 		 * @return array
784 784
 		 */
785
-		public function theme_js_settings(){
786
-			return array(
787
-				'ayetheme' => 'popper',
788
-				'listimia' => 'required',
789
-				'listimia_backend' => 'core-popper',
790
-				//'avada'    => 'required', // removed as we now add compatibility
791
-			);
792
-		}
793
-
794
-		/**
785
+		    public function theme_js_settings(){
786
+			    return array(
787
+				    'ayetheme' => 'popper',
788
+				    'listimia' => 'required',
789
+				    'listimia_backend' => 'core-popper',
790
+				    //'avada'    => 'required', // removed as we now add compatibility
791
+			    );
792
+		    }
793
+
794
+		    /**
795 795
          * Get the date the site was installed.
796 796
          *
797 797
 		 * @return false|string
798 798
 		 */
799
-        public function get_site_install_date() {
800
-	        global $wpdb; // This gives you access to the WordPress database object
799
+            public function get_site_install_date() {
800
+	            global $wpdb; // This gives you access to the WordPress database object
801 801
 
802
-	        // Prepare the SQL query to get the oldest registration date
803
-	        $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
802
+	            // Prepare the SQL query to get the oldest registration date
803
+	            $query = "SELECT MIN(user_registered) AS oldest_registration_date FROM {$wpdb->users}";
804 804
 
805
-	        // Execute the query
806
-	        $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
805
+	            // Execute the query
806
+	            $date = $wpdb->get_var( $query ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
807 807
 
808
-	        return $date ? $date : false;
809
-        }
808
+	            return $date ? $date : false;
809
+            }
810 810
 
811
-		/**
811
+		    /**
812 812
 		 * Show admin notice if backend scripts not loaded.
813 813
 		 */
814
-		public function show_admin_version_notice(){
815
-			$fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
-			$button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
-			$message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
-			echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>';
819
-		}
820
-
821
-		/**
814
+		    public function show_admin_version_notice(){
815
+			    $fix_url = admin_url("options-general.php?page=ayecode-ui-settings" );
816
+			    $button = '<a href="'.esc_url($fix_url).'" class="button-primary">View Settings</a>';
817
+			    $message = __( '<b>Style Issue:</b> AyeCode UI has changed its default version from v4 to v5, if you notice unwanted style changes, please revert to v4 (saving the settings page will remove this notice)')." " .$button;
818
+			    echo '<div class="notice notice-error aui-settings-error-notice"><p>'. wp_kses_post( $message ).'</p></div>';
819
+		    }
820
+
821
+		    /**
822 822
 		 * Get the current Font Awesome output settings.
823 823
 		 *
824 824
 		 * @return array The array of settings.
825 825
 		 */
826
-		public function get_settings() {
827
-
828
-			$db_settings = get_option( 'ayecode-ui-settings' );
829
-
830
-            // Maybe show default version notice
831
-			$site_install_date = new DateTime( self::get_site_install_date() );
832
-			$switch_over_date = new DateTime("2024-02-01");
833
-			if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
-				add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
-			}
836
-
837
-			$js_default = 'core-popper';
838
-			$js_default_backend = $js_default;
839
-
840
-			// maybe set defaults (if no settings set)
841
-			if(empty($db_settings)){
842
-				$active_theme = strtolower( get_template() ); // active parent theme.
843
-				$theme_js_settings = self::theme_js_settings();
844
-				if(isset($theme_js_settings[$active_theme])){
845
-					$js_default = $theme_js_settings[$active_theme];
846
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
-				}
848
-			}
849
-
850
-			/**
826
+		    public function get_settings() {
827
+
828
+			    $db_settings = get_option( 'ayecode-ui-settings' );
829
+
830
+                // Maybe show default version notice
831
+			    $site_install_date = new DateTime( self::get_site_install_date() );
832
+			    $switch_over_date = new DateTime("2024-02-01");
833
+			    if ( empty( $db_settings ) && $site_install_date < $switch_over_date ) {
834
+				    add_action( 'admin_notices', array( $this, 'show_admin_version_notice' ) );
835
+			    }
836
+
837
+			    $js_default = 'core-popper';
838
+			    $js_default_backend = $js_default;
839
+
840
+			    // maybe set defaults (if no settings set)
841
+			    if(empty($db_settings)){
842
+				    $active_theme = strtolower( get_template() ); // active parent theme.
843
+				    $theme_js_settings = self::theme_js_settings();
844
+				    if(isset($theme_js_settings[$active_theme])){
845
+					    $js_default = $theme_js_settings[$active_theme];
846
+					    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
847
+				    }
848
+			    }
849
+
850
+			    /**
851 851
 			 * Filter the default settings.
852 852
 			 */
853
-			$defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
-				'css'            => 'compatibility', // core, compatibility
855
-				'js'             => $js_default, // js to load, core-popper, popper
856
-				'html_font_size' => '16', // js to load, core-popper, popper
857
-				'css_backend'    => 'compatibility', // core, compatibility
858
-				'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
-				'disable_admin'  => '', // URL snippets to disable loading on admin
860
-                'bs_ver'         => '5', // The default bootstrap version to sue by default
861
-			), $db_settings );
862
-
863
-			$settings = wp_parse_args( $db_settings, $defaults );
864
-
865
-			/**
853
+			    $defaults = apply_filters( 'ayecode-ui-default-settings', array(
854
+				    'css'            => 'compatibility', // core, compatibility
855
+				    'js'             => $js_default, // js to load, core-popper, popper
856
+				    'html_font_size' => '16', // js to load, core-popper, popper
857
+				    'css_backend'    => 'compatibility', // core, compatibility
858
+				    'js_backend'     => $js_default_backend, // js to load, core-popper, popper
859
+				    'disable_admin'  => '', // URL snippets to disable loading on admin
860
+                    'bs_ver'         => '5', // The default bootstrap version to sue by default
861
+			    ), $db_settings );
862
+
863
+			    $settings = wp_parse_args( $db_settings, $defaults );
864
+
865
+			    /**
866 866
 			 * Filter the Bootstrap settings.
867 867
 			 *
868 868
 			 * @todo if we add this filer people might use it and then it defeats the purpose of this class :/
869 869
 			 */
870
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
-		}
870
+			    return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
871
+		    }
872 872
 
873 873
 
874
-		/**
874
+		    /**
875 875
 		 * The settings page html output.
876 876
 		 */
877
-		public function settings_page() {
878
-			if ( ! current_user_can( 'manage_options' ) ) {
879
-				wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
-			}
881
-            $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
877
+		    public function settings_page() {
878
+			    if ( ! current_user_can( 'manage_options' ) ) {
879
+				    wp_die( esc_attr__( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
880
+			    }
881
+                $overrides = apply_filters( 'ayecode-ui-settings', array(), array(), array() );
882 882
 
883
-			?>
883
+			    ?>
884 884
             <div class="wrap">
885 885
                 <h1><?php echo esc_attr( $this->name ); ?></h1>
886 886
                 <p><?php echo esc_html( apply_filters( 'ayecode-ui-settings-message', __("Here you can adjust settings if you are having compatibility issues.", 'ayecode-connect' ) ) );?></p>
887 887
                 <form method="post" action="options.php">
888 888
 					<?php
889
-					settings_fields( 'ayecode-ui-settings' );
890
-					do_settings_sections( 'ayecode-ui-settings' );
891
-					?>
889
+					    settings_fields( 'ayecode-ui-settings' );
890
+					    do_settings_sections( 'ayecode-ui-settings' );
891
+					    ?>
892 892
 
893 893
                     <h2><?php esc_html_e( 'BootStrap Version', 'ayecode-connect' ); ?></h2>
894 894
                     <p><?php echo esc_html( 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.", 'ayecode-connect' ) ) );?></p>
895 895
 	                <div class="bsui"><?php
896
-	                if ( ! empty( $overrides ) ) {
897
-		                echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898
-			                'type'=> 'info',
899
-			                'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
-		                ));
901
-	                }
902
-	                ?>
896
+	                    if ( ! empty( $overrides ) ) {
897
+		                    echo aui()->alert(array( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
898
+			                    'type'=> 'info',
899
+			                    'content'=> esc_attr__("Some options are disabled as your current theme is overriding them.", 'ayecode-connect' )
900
+		                    ));
901
+	                    }
902
+	                    ?>
903 903
                     </div>
904 904
                     <table class="form-table wpbs-table-version-settings">
905 905
                         <tr valign="top">
@@ -983,77 +983,77 @@  discard block
 block discarded – undo
983 983
                     </table>
984 984
 
985 985
 					<?php
986
-					submit_button();
987
-					?>
986
+					    submit_button();
987
+					    ?>
988 988
                 </form>
989 989
                 <div id="wpbs-version" data-aui-source="<?php echo esc_attr( $this->get_load_source() ); ?>"><?php echo esc_html( $this->version ); ?></div>
990 990
             </div>
991 991
 			<?php
992
-		}
993
-
994
-        public function get_load_source(){
995
-	        $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
-	        $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
-
998
-	        // Find source plugin/theme of SD
999
-	        $source = array();
1000
-	        if ( strpos( $file, $plugins_dir ) !== false ) {
1001
-		        $source = explode( "/", plugin_basename( $file ) );
1002
-	        } else if ( function_exists( 'get_theme_root' ) ) {
1003
-		        $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
-
1005
-		        if ( strpos( $file, $themes_dir ) !== false ) {
1006
-			        $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
-		        }
1008
-	        }
1009
-
1010
-            return isset($source[0]) ? esc_attr($source[0]) : '';
1011
-        }
1012
-
1013
-		public function customizer_settings($wp_customize){
1014
-			$wp_customize->add_section('aui_settings', array(
1015
-				'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
-				'priority' => 120,
1017
-			));
1018
-
1019
-			//  =============================
1020
-			//  = Color Picker              =
1021
-			//  =============================
1022
-			$wp_customize->add_setting('aui_options[color_primary]', array(
1023
-				'default'           => AUI_PRIMARY_COLOR,
1024
-				'sanitize_callback' => 'sanitize_hex_color',
1025
-				'capability'        => 'edit_theme_options',
1026
-				'type'              => 'option',
1027
-				'transport'         => 'refresh',
1028
-			));
1029
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
-				'label'    => __('Primary Color', 'ayecode-connect' ),
1031
-				'section'  => 'aui_settings',
1032
-				'settings' => 'aui_options[color_primary]',
1033
-			)));
1034
-
1035
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1036
-				'default'           => '#6c757d',
1037
-				'sanitize_callback' => 'sanitize_hex_color',
1038
-				'capability'        => 'edit_theme_options',
1039
-				'type'              => 'option',
1040
-				'transport'         => 'refresh',
1041
-			));
1042
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
-				'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
-				'section'  => 'aui_settings',
1045
-				'settings' => 'aui_options[color_secondary]',
1046
-			)));
1047
-		}
1048
-
1049
-		/**
992
+		    }
993
+
994
+            public function get_load_source(){
995
+	            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
996
+	            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
997
+
998
+	            // Find source plugin/theme of SD
999
+	            $source = array();
1000
+	            if ( strpos( $file, $plugins_dir ) !== false ) {
1001
+		            $source = explode( "/", plugin_basename( $file ) );
1002
+	            } else if ( function_exists( 'get_theme_root' ) ) {
1003
+		            $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1004
+
1005
+		            if ( strpos( $file, $themes_dir ) !== false ) {
1006
+			            $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1007
+		            }
1008
+	            }
1009
+
1010
+                return isset($source[0]) ? esc_attr($source[0]) : '';
1011
+            }
1012
+
1013
+		    public function customizer_settings($wp_customize){
1014
+			    $wp_customize->add_section('aui_settings', array(
1015
+				    'title'    => __('AyeCode UI', 'ayecode-connect' ),
1016
+				    'priority' => 120,
1017
+			    ));
1018
+
1019
+			    //  =============================
1020
+			    //  = Color Picker              =
1021
+			    //  =============================
1022
+			    $wp_customize->add_setting('aui_options[color_primary]', array(
1023
+				    'default'           => AUI_PRIMARY_COLOR,
1024
+				    'sanitize_callback' => 'sanitize_hex_color',
1025
+				    'capability'        => 'edit_theme_options',
1026
+				    'type'              => 'option',
1027
+				    'transport'         => 'refresh',
1028
+			    ));
1029
+			    $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1030
+				    'label'    => __('Primary Color', 'ayecode-connect' ),
1031
+				    'section'  => 'aui_settings',
1032
+				    'settings' => 'aui_options[color_primary]',
1033
+			    )));
1034
+
1035
+			    $wp_customize->add_setting('aui_options[color_secondary]', array(
1036
+				    'default'           => '#6c757d',
1037
+				    'sanitize_callback' => 'sanitize_hex_color',
1038
+				    'capability'        => 'edit_theme_options',
1039
+				    'type'              => 'option',
1040
+				    'transport'         => 'refresh',
1041
+			    ));
1042
+			    $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1043
+				    'label'    => __('Secondary Color', 'ayecode-connect' ),
1044
+				    'section'  => 'aui_settings',
1045
+				    'settings' => 'aui_options[color_secondary]',
1046
+			    )));
1047
+		    }
1048
+
1049
+		    /**
1050 1050
 		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1051 1051
 		 *
1052 1052
 		 * @return mixed
1053 1053
 		 */
1054
-		public static function bs3_compat_css() {
1055
-			ob_start();
1056
-			?>
1054
+		    public static function bs3_compat_css() {
1055
+			    ob_start();
1056
+			    ?>
1057 1057
             <style>
1058 1058
                 /* Bootstrap 3 compatibility */
1059 1059
                 body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
                 /* KLEO theme specific */
1071 1071
                 .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: block !important;}
1072 1072
                 <?php } ?>
1073
-
1073
+    
1074 1074
                 <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1075 1075
                 /* With Avada builder */
1076 1076
                 body.modal-open .modal.in  {opacity:1;z-index: 99999}
@@ -1080,248 +1080,248 @@  discard block
 block discarded – undo
1080 1080
                 .bsui .collapse.in.row:not(.show){display: none;}
1081 1081
 
1082 1082
                 <?php } ?>
1083
-            </style>
1083
+                </style>
1084 1084
 			<?php
1085
-			return str_replace( array(
1086
-				'<style>',
1087
-				'</style>'
1088
-			), '', self::minify_css( ob_get_clean() ) );
1089
-		}
1085
+			    return str_replace( array(
1086
+				    '<style>',
1087
+				    '</style>'
1088
+			    ), '', self::minify_css( ob_get_clean() ) );
1089
+		    }
1090 1090
 
1091 1091
 
1092
-		public static function custom_css($compatibility = true) {
1093
-            global $aui_bs5;
1092
+		    public static function custom_css($compatibility = true) {
1093
+                global $aui_bs5;
1094 1094
 
1095
-			$colors = array();
1096
-			if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1095
+			    $colors = array();
1096
+			    if ( defined( 'BLOCKSTRAP_VERSION' ) ) {
1097 1097
 
1098 1098
 
1099
-				$setting = wp_get_global_settings();
1099
+				    $setting = wp_get_global_settings();
1100 1100
 
1101
-//                print_r(wp_get_global_styles());//exit;
1102
-//                print_r(get_default_block_editor_settings());exit;
1101
+    //                print_r(wp_get_global_styles());//exit;
1102
+    //                print_r(get_default_block_editor_settings());exit;
1103 1103
 
1104
-//                print_r($setting);echo  '###';exit;
1105
-				if(!empty($setting['color']['palette']['theme'])){
1106
-					foreach($setting['color']['palette']['theme'] as $color){
1107
-						$colors[$color['slug']] = esc_attr($color['color']);
1108
-					}
1109
-				}
1104
+    //                print_r($setting);echo  '###';exit;
1105
+				    if(!empty($setting['color']['palette']['theme'])){
1106
+					    foreach($setting['color']['palette']['theme'] as $color){
1107
+						    $colors[$color['slug']] = esc_attr($color['color']);
1108
+					    }
1109
+				    }
1110 1110
 
1111
-				if(!empty($setting['color']['palette']['custom'])){
1112
-					foreach($setting['color']['palette']['custom'] as $color){
1113
-						$colors[$color['slug']] = esc_attr($color['color']);
1114
-					}
1115
-				}
1116
-			}else{
1117
-				$settings = get_option('aui_options');
1118
-				$colors = array(
1119
-					'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
-					'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
-				);
1122
-			}
1111
+				    if(!empty($setting['color']['palette']['custom'])){
1112
+					    foreach($setting['color']['palette']['custom'] as $color){
1113
+						    $colors[$color['slug']] = esc_attr($color['color']);
1114
+					    }
1115
+				    }
1116
+			    }else{
1117
+				    $settings = get_option('aui_options');
1118
+				    $colors = array(
1119
+					    'primary'   => ! empty( $settings['color_primary'] ) ? $settings['color_primary'] : AUI_PRIMARY_COLOR,
1120
+					    'secondary' => ! empty( $settings['color_secondary'] ) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR
1121
+				    );
1122
+			    }
1123 1123
 
1124
-			ob_start();
1124
+			    ob_start();
1125 1125
 
1126
-			?>
1127
-            <style>
1126
+			    ?>
1127
+                <style>
1128 1128
                 <?php
1129 1129
 
1130
-					// BS v3 compat
1131
-					if( self::is_bs3_compat() ){
1132
-						echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1133
-					}
1134
-
1135
-                    $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1136
-                    $is_fse = false;
1137
-                    if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
1138
-                        $is_fse = true;
1139
-                    }
1130
+					    // BS v3 compat
1131
+					    if( self::is_bs3_compat() ){
1132
+						    echo self::bs3_compat_css(); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1133
+					    }
1140 1134
 
1141
-					if(!empty($colors)){
1142
-						$d_colors = self::get_colors(true);
1135
+                        $current_screen = function_exists('get_current_screen' ) ? get_current_screen() : '';
1136
+                        $is_fse = false;
1137
+                        if ( is_admin() && ( !empty($_REQUEST['postType']) || $current_screen->is_block_editor() ) && ( defined( 'BLOCKSTRAP_VERSION' ) || defined( 'AUI_FSE' ) )  ) {
1138
+                            $is_fse = true;
1139
+                        }
1143 1140
 
1144
-//						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
-						foreach($colors as $key => $color ){
1146
-							if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
-								$var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
-								$compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
-								echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1150
-							}
1151
-						}
1152
-					   // exit;
1153
-					}
1141
+					    if(!empty($colors)){
1142
+						    $d_colors = self::get_colors(true);
1143
+
1144
+    //						$is_fse = !empty($_REQUEST['postType']) && $_REQUEST['postType']=='wp_template';
1145
+						    foreach($colors as $key => $color ){
1146
+							    if((empty( $d_colors[$key]) ||  $d_colors[$key] != $color) || $is_fse ) {
1147
+								    $var = $is_fse ? "var(--wp--preset--color--$key)" : $color;
1148
+								    $compat = $is_fse ? '.editor-styles-wrapper' : $compatibility;
1149
+								    echo $aui_bs5 ? self::css_overwrite_bs5($key,$var,$compat,$color) : self::css_overwrite($key,$var,$compat,$color); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1150
+							    }
1151
+						    }
1152
+					       // exit;
1153
+					    }
1154
+
1155
+					    // Set admin bar z-index lower when modal is open.
1156
+					    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1157
+
1158
+					    if(is_admin()){
1159
+						    echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
+					    }
1161
+
1162
+                        if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1163
+                            $css = '';
1164
+                            $theme_settings = wp_get_global_styles();
1165
+
1166
+    //                        print_r( $theme_settings);exit;
1167
+
1168
+                            // font face
1169
+                            if( !empty( $theme_settings['typography']['fontFamily'] ) ){
1170
+                                $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily']  ); //var(--wp--preset--font-family--poppins)
1171
+                                $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';';
1172
+                            }
1154 1173
 
1155
-					// Set admin bar z-index lower when modal is open.
1156
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1174
+                            // font size
1175
+                            if( !empty( $theme_settings['typography']['fontSize'] ) ){
1176
+                                $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;';
1177
+                            }
1157 1178
 
1158
-					if(is_admin()){
1159
-						echo ' body.modal-open #adminmenuwrap{z-index:999} body.modal-open #wpadminbar{z-index:1025}';
1160
-					}
1179
+                            // line height
1180
+                             if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181
+                                $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1182
+                            }
1161 1183
 
1162
-                    if( $aui_bs5 && defined( 'BLOCKSTRAP_VERSION' )  ){
1163
-                        $css = '';
1164
-                        $theme_settings = wp_get_global_styles();
1165 1184
 
1166
-//                        print_r( $theme_settings);exit;
1185
+                               // font weight
1186
+                             if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187
+                                $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1188
+                            }
1167 1189
 
1168
-                        // font face
1169
-                        if( !empty( $theme_settings['typography']['fontFamily'] ) ){
1170
-                            $t_fontface = str_replace( array('var:preset|','font-family|'), array('--wp--preset--','font-family--'), $theme_settings['typography']['fontFamily']  ); //var(--wp--preset--font-family--poppins)
1171
-                            $css .= '--bs-body-font-family: ' . esc_attr($t_fontface) . ';';
1172
-                        }
1190
+                            // Background
1191
+                             if( !empty( $theme_settings['color']['background'] ) ){
1192
+                                $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1193
+                            }
1173 1194
 
1174
-                        // font size
1175
-                        if( !empty( $theme_settings['typography']['fontSize'] ) ){
1176
-                            $css .= '--bs-body-font-size: ' . esc_attr( $theme_settings['typography']['fontSize'] ) . ' ;';
1177
-                        }
1195
+                             // Background Gradient
1196
+                             if( !empty( $theme_settings['color']['gradient'] ) ){
1197
+                                $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1198
+                            }
1178 1199
 
1179
-                        // line height
1180
-                         if( !empty( $theme_settings['typography']['lineHeight'] ) ){
1181
-                            $css .= '--bs-body-line-height: ' . esc_attr( $theme_settings['typography']['lineHeight'] ) . ';';
1182
-                        }
1200
+                               // Background Gradient
1201
+                             if( !empty( $theme_settings['color']['gradient'] ) ){
1202
+                                $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1203
+                            }
1183 1204
 
1205
+                            // text color
1206
+                            if( !empty( $theme_settings['color']['text'] ) ){
1207
+                                $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';';
1208
+                            }
1184 1209
 
1185
-                           // font weight
1186
-                         if( !empty( $theme_settings['typography']['fontWeight'] ) ){
1187
-                            $css .= '--bs-body-font-weight: ' . esc_attr( $theme_settings['typography']['fontWeight'] ) . ';';
1188
-                        }
1189 1210
 
1190
-                        // Background
1191
-                         if( !empty( $theme_settings['color']['background'] ) ){
1192
-                            $css .= '--bs-body-bg: ' . esc_attr( $theme_settings['color']['background'] ) . ';';
1193
-                        }
1211
+                            // link colors
1212
+                            if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){
1213
+                                $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';';
1214
+                            }
1215
+                            if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){
1216
+                                $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';';
1217
+                            }
1194 1218
 
1195
-                         // Background Gradient
1196
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1197
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1198
-                        }
1199 1219
 
1200
-                           // Background Gradient
1201
-                         if( !empty( $theme_settings['color']['gradient'] ) ){
1202
-                            $css .= 'background: ' . esc_attr( $theme_settings['color']['gradient'] ) . ';';
1203
-                        }
1204 1220
 
1205
-                        // text color
1206
-                        if( !empty( $theme_settings['color']['text'] ) ){
1207
-                            $css .= '--bs-body-color: ' . esc_attr( $theme_settings['color']['text'] ) . ';';
1208
-                        }
1221
+                            if($css){
1222
+                                echo  $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}';
1223
+                            }
1209 1224
 
1225
+                            $bep = $is_fse ? 'body.editor-styles-wrapper ' : '';
1210 1226
 
1211
-                        // link colors
1212
-                        if( !empty( $theme_settings['elements']['link']['color']['text'] ) ){
1213
-                            $css .= '--bs-link-color: ' . esc_attr( $theme_settings['elements']['link']['color']['text'] ) . ';';
1214
-                        }
1215
-                        if( !empty( $theme_settings['elements']['link'][':hover']['color']['text'] ) ){
1216
-                            $css .= '--bs-link-hover-color: ' . esc_attr( $theme_settings['elements']['link'][':hover']['color']['text'] ) . ';';
1217
-                        }
1218 1227
 
1228
+                            // Headings
1229
+                            $headings_css = '';
1230
+                            if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){
1231
+                                $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";";
1232
+                            }
1219 1233
 
1234
+                            // heading background
1235
+                            if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){
1236
+                                $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1237
+                            }
1220 1238
 
1221
-                        if($css){
1222
-                            echo  $is_fse ? 'body.editor-styles-wrapper{' . esc_attr( $css ) . '}' : 'body{' . esc_attr( $css ) . '}';
1223
-                        }
1239
+                             // heading font family
1240
+                            if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241
+                                $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1242
+                            }
1224 1243
 
1225
-                        $bep = $is_fse ? 'body.editor-styles-wrapper ' : '';
1244
+                            if( $headings_css ){
1245
+                                echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1246
+                            }
1226 1247
 
1248
+                            $hs = array('h1','h2','h3','h4','h5','h6');
1227 1249
 
1228
-                        // Headings
1229
-                        $headings_css = '';
1230
-                        if( !empty( $theme_settings['elements']['heading']['color']['text'] ) ){
1231
-                            $headings_css .= "color: " . esc_attr( $theme_settings['elements']['heading']['color']['text'] ) . ";";
1232
-                        }
1250
+                            foreach($hs as $hn){
1251
+                                $h_css = '';
1252
+                                 if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253
+                                    $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1254
+                                 }
1233 1255
 
1234
-                        // heading background
1235
-                        if( !empty( $theme_settings['elements']['heading']['color']['background'] ) ){
1236
-                            $headings_css .= 'background: ' . esc_attr( $theme_settings['elements']['heading']['color']['background'] ) . ';';
1237
-                        }
1256
+                                  if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257
+                                    $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1258
+                                 }
1238 1259
 
1239
-                         // heading font family
1240
-                        if( !empty( $theme_settings['elements']['heading']['typography']['fontFamily'] ) ){
1241
-                            $headings_css .= 'font-family: ' . esc_attr( $theme_settings['elements']['heading']['typography']['fontFamily']  ) . ';';
1242
-                        }
1260
+                                  if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261
+                                    $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1262
+                                 }
1243 1263
 
1244
-                        if( $headings_css ){
1245
-                            echo "$bep h1,$bep h2,$bep h3, $bep h4,$bep h5,$bep h6{ " . esc_attr( $headings_css ) . "}"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1264
+                                 if($h_css){
1265
+                                    echo esc_attr( $bep  . $hn ) . '{'.esc_attr( $h_css ).'}';
1266
+                                 }
1267
+                            }
1246 1268
                         }
1247 1269
 
1248
-                        $hs = array('h1','h2','h3','h4','h5','h6');
1249
-
1250
-                        foreach($hs as $hn){
1251
-                            $h_css = '';
1252
-                             if( !empty( $theme_settings['elements'][$hn]['color']['text'] ) ){
1253
-                                $h_css .= 'color: ' . esc_attr( $theme_settings['elements'][$hn]['color']['text'] ) . ';';
1254
-                             }
1255
-
1256
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontSize'] ) ){
1257
-                                $h_css .= 'font-size: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontSize']  ) . ';';
1258
-                             }
1259
-
1260
-                              if( !empty( $theme_settings['elements'][$hn]['typography']['fontFamily'] ) ){
1261
-                                $h_css .= 'font-family: ' . esc_attr( $theme_settings['elements'][$hn]['typography']['fontFamily']  ) . ';';
1262
-                             }
1263
-
1264
-                             if($h_css){
1265
-                                echo esc_attr( $bep  . $hn ) . '{'.esc_attr( $h_css ).'}';
1266
-                             }
1270
+                        // Pagination on Hello Elementor theme.
1271
+                        if ( function_exists( 'hello_elementor_setup' ) ) {
1272
+                            echo '.aui-nav-links .pagination{justify-content:inherit}';
1267 1273
                         }
1268
-                    }
1269
-
1270
-                    // Pagination on Hello Elementor theme.
1271
-                    if ( function_exists( 'hello_elementor_setup' ) ) {
1272
-                        echo '.aui-nav-links .pagination{justify-content:inherit}';
1273
-                    }
1274
-                ?>
1275
-            </style>
1274
+                    ?>
1275
+                </style>
1276 1276
 			<?php
1277
-			/*
1277
+			    /*
1278 1278
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1279 1279
 			 */
1280
-			return str_replace( array(
1281
-				'<style>',
1282
-				'</style>'
1283
-			), '', self::minify_css( ob_get_clean() ) );
1284
-		}
1280
+			    return str_replace( array(
1281
+				    '<style>',
1282
+				    '</style>'
1283
+			    ), '', self::minify_css( ob_get_clean() ) );
1284
+		    }
1285 1285
 
1286
-		/**
1286
+		    /**
1287 1287
 		 * Check if we should add booststrap 3 compatibility changes.
1288 1288
 		 *
1289 1289
 		 * @return bool
1290 1290
 		 */
1291
-		public static function is_bs3_compat(){
1292
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1293
-		}
1291
+		    public static function is_bs3_compat(){
1292
+			    return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1293
+		    }
1294 1294
 
1295
-		public static function hex_to_rgb( $hex ) {
1296
-			// Remove '#' if present
1297
-			$hex = str_replace( '#', '', $hex );
1295
+		    public static function hex_to_rgb( $hex ) {
1296
+			    // Remove '#' if present
1297
+			    $hex = str_replace( '#', '', $hex );
1298 1298
 
1299
-			// Check if input is RGB
1300
-			if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) {
1301
-				$_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) );
1299
+			    // Check if input is RGB
1300
+			    if ( strpos( $hex, 'rgba(' ) === 0 || strpos( $hex, 'rgb(' ) === 0 ) {
1301
+				    $_rgb = explode( ',', str_replace( array( 'rgba(', 'rgb(', ')' ), '', $hex ) );
1302 1302
 
1303
-				$rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ',';
1304
-				$rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ',';
1305
-				$rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' );
1303
+				    $rgb = ( isset( $_rgb[0] ) ? (int) trim( $_rgb[0] ) : '0' ) . ',';
1304
+				    $rgb .= ( isset( $_rgb[1] ) ? (int) trim( $_rgb[1] ) : '0' ) . ',';
1305
+				    $rgb .= ( isset( $_rgb[2] ) ? (int) trim( $_rgb[2] ) : '0' );
1306 1306
 
1307
-				return $rgb;
1308
-			}
1307
+				    return $rgb;
1308
+			    }
1309 1309
 
1310
-			// Convert 3-digit hex to 6-digit hex
1311
-			if ( strlen( $hex ) == 3 ) {
1312
-				$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1313
-			}
1310
+			    // Convert 3-digit hex to 6-digit hex
1311
+			    if ( strlen( $hex ) == 3 ) {
1312
+				    $hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
1313
+			    }
1314 1314
 
1315
-			// Convert hex to RGB
1316
-			$r = hexdec( substr( $hex, 0, 2 ) );
1317
-			$g = hexdec( substr( $hex, 2, 2 ) );
1318
-			$b = hexdec( substr( $hex, 4, 2 ) );
1315
+			    // Convert hex to RGB
1316
+			    $r = hexdec( substr( $hex, 0, 2 ) );
1317
+			    $g = hexdec( substr( $hex, 2, 2 ) );
1318
+			    $b = hexdec( substr( $hex, 4, 2 ) );
1319 1319
 
1320
-			// Return RGB values as an array
1321
-			return $r . ',' . $g . ',' . $b;
1322
-		}
1320
+			    // Return RGB values as an array
1321
+			    return $r . ',' . $g . ',' . $b;
1322
+		    }
1323 1323
 
1324
-		/**
1324
+		    /**
1325 1325
 		 * Build the CSS to overwrite a bootstrap color variable.
1326 1326
 		 *
1327 1327
 		 * @param $type
@@ -1330,120 +1330,120 @@  discard block
 block discarded – undo
1330 1330
 		 *
1331 1331
 		 * @return string
1332 1332
 		 */
1333
-		public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1334
-			global $aui_bs5;
1333
+		    public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex = '' ){
1334
+			    global $aui_bs5;
1335 1335
 
1336
-			$is_var = false;
1337
-			$is_custom = strpos($type, 'custom-') !== false ? true : false;
1338
-			if(!$color_code){return '';}
1339
-			if(strpos($color_code, 'var') !== false){
1340
-				//if(!sanitize_hex_color($color_code)){
1341
-				$color_code = esc_attr($color_code);
1342
-				$is_var = true;
1343
-//				$color_code = "rgba($color_code, 0.5)";
1344
-//                echo '###1'.$color_code.'###';//exit;
1345
-			}
1336
+			    $is_var = false;
1337
+			    $is_custom = strpos($type, 'custom-') !== false ? true : false;
1338
+			    if(!$color_code){return '';}
1339
+			    if(strpos($color_code, 'var') !== false){
1340
+				    //if(!sanitize_hex_color($color_code)){
1341
+				    $color_code = esc_attr($color_code);
1342
+				    $is_var = true;
1343
+    //				$color_code = "rgba($color_code, 0.5)";
1344
+    //                echo '###1'.$color_code.'###';//exit;
1345
+			    }
1346 1346
 
1347
-//            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1347
+    //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1348 1348
 
1349
-			if(!$color_code){return '';}
1349
+			    if(!$color_code){return '';}
1350 1350
 
1351
-			$rgb = self::hex_to_rgb($hex);
1351
+			    $rgb = self::hex_to_rgb($hex);
1352 1352
 
1353
-			if($compatibility===true || $compatibility===1){
1354
-				$compatibility = '.bsui';
1355
-			}elseif(!$compatibility){
1356
-				$compatibility = '';
1357
-			}else{
1358
-				$compatibility = esc_attr($compatibility);
1359
-			}
1353
+			    if($compatibility===true || $compatibility===1){
1354
+				    $compatibility = '.bsui';
1355
+			    }elseif(!$compatibility){
1356
+				    $compatibility = '';
1357
+			    }else{
1358
+				    $compatibility = esc_attr($compatibility);
1359
+			    }
1360 1360
 
1361
-			$prefix = $compatibility ? $compatibility . " " : "";
1361
+			    $prefix = $compatibility ? $compatibility . " " : "";
1362 1362
 
1363 1363
 
1364
-            $output = '';
1364
+                $output = '';
1365 1365
 
1366
-//            echo '####'.$color_code;exit;
1366
+    //            echo '####'.$color_code;exit;
1367 1367
 
1368
-			$type = sanitize_html_class($type);
1368
+			    $type = sanitize_html_class($type);
1369 1369
 
1370
-			/**
1370
+			    /**
1371 1371
 			 * c = color, b = background color, o = border-color, f = fill
1372 1372
 			 */
1373
-			$selectors = array(
1374
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1375
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1376
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1377
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1378
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1379
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1380
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1381
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1382
-				".badge-{$type}"                                            => array( 'b' ),
1383
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1384
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1385
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1386
-				".text-{$type}"                                     => array( 'c' ),
1387
-			);
1388
-
1389
-			if ( $aui_bs5 ) {
1390
-				unset($selectors[".alert-{$type}" ]);
1391
-			}
1392
-
1393
-			if ( $type == 'primary' ) {
1394
-				$selectors = $selectors + array(
1395
-						'a'                                                                                                    => array( 'c' ),
1396
-						'.btn-link'                                                                                            => array( 'c' ),
1397
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1398
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1399
-							'b',
1400
-							'o'
1401
-						),
1402
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1403
-							'b',
1404
-							'o'
1405
-						),
1406
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1407
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1408
-						'.page-link'                                                                                           => array( 'c' ),
1409
-						'.page-item.active .page-link'                                                                         => array(
1410
-							'b',
1411
-							'o'
1412
-						),
1413
-						'.progress-bar'                                                                                        => array( 'b' ),
1414
-						'.list-group-item.active'                                                                              => array(
1415
-							'b',
1416
-							'o'
1417
-						),
1418
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1419
-					);
1420
-			}
1421
-
1422
-
1423
-
1424
-            // link
1425
-			if ( $type === 'primary' ) {
1426
-				$output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1427
-				$output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1428
-				$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).'; }';
1429
-
1430
-				$output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1431
-				$output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1432
-
1433
-                // dropdown
1434
-				$output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1435
-
1436
-                // pagination
1437
-				$output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1438
-
1439
-			}
1440
-
1441
-			$output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1442
-			$output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1443
-
1444
-			//  buttons
1445
-			$output .= $prefix . ' .btn-'.esc_attr($type).'{';
1446
-			$output .= ' 
1373
+			    $selectors = array(
1374
+				    ".btn-{$type}"                                              => array( 'b', 'o' ),
1375
+				    ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1376
+				    ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1377
+				    ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1378
+				    ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1379
+				    ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1380
+				    ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1381
+				    ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1382
+				    ".badge-{$type}"                                            => array( 'b' ),
1383
+				    ".alert-{$type}"                                            => array( 'b', 'o' ),
1384
+				    ".bg-{$type}"                                               => array( 'b', 'f' ),
1385
+				    ".btn-link.btn-{$type}"                                     => array( 'c' ),
1386
+				    ".text-{$type}"                                     => array( 'c' ),
1387
+			    );
1388
+
1389
+			    if ( $aui_bs5 ) {
1390
+				    unset($selectors[".alert-{$type}" ]);
1391
+			    }
1392
+
1393
+			    if ( $type == 'primary' ) {
1394
+				    $selectors = $selectors + array(
1395
+						    'a'                                                                                                    => array( 'c' ),
1396
+						    '.btn-link'                                                                                            => array( 'c' ),
1397
+						    '.dropdown-item.active'                                                                                => array( 'b' ),
1398
+						    '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1399
+							    'b',
1400
+							    'o'
1401
+						    ),
1402
+						    '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1403
+							    'b',
1404
+							    'o'
1405
+						    ),
1406
+						    '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1407
+						    '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1408
+						    '.page-link'                                                                                           => array( 'c' ),
1409
+						    '.page-item.active .page-link'                                                                         => array(
1410
+							    'b',
1411
+							    'o'
1412
+						    ),
1413
+						    '.progress-bar'                                                                                        => array( 'b' ),
1414
+						    '.list-group-item.active'                                                                              => array(
1415
+							    'b',
1416
+							    'o'
1417
+						    ),
1418
+						    '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1419
+					    );
1420
+			    }
1421
+
1422
+
1423
+
1424
+                // link
1425
+			    if ( $type === 'primary' ) {
1426
+				    $output .= 'html body {--bs-link-hover-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .75); --bs-link-color: var(--bs-'.esc_attr($type).'); }';
1427
+				    $output .= $prefix . ' .breadcrumb{--bs-breadcrumb-item-active-color: '.esc_attr($color_code).';  }';
1428
+				    $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).'; }';
1429
+
1430
+				    $output .= $prefix . ' a{color: var(--bs-'.esc_attr($type).');}';
1431
+				    $output .= $prefix . ' .text-primary{color: var(--bs-'.esc_attr($type).') !important;}';
1432
+
1433
+                    // dropdown
1434
+				    $output .= $prefix . ' .dropdown-menu{--bs-dropdown-link-hover-color: var(--bs-'.esc_attr($type).'); --bs-dropdown-link-active-color: var(--bs-'.esc_attr($type).');}';
1435
+
1436
+                    // pagination
1437
+				    $output .= $prefix . ' .pagination{--bs-pagination-hover-color: var(--bs-'.esc_attr($type).'); --bs-pagination-active-bg: var(--bs-'.esc_attr($type).');}';
1438
+
1439
+			    }
1440
+
1441
+			    $output .= $prefix . ' .link-'.esc_attr($type).' {color: var(--bs-'.esc_attr($type).'-rgb) !important;}';
1442
+			    $output .= $prefix . ' .link-'.esc_attr($type).':hover {color: rgba(var(--bs-'.esc_attr($type).'-rgb), .8) !important;}';
1443
+
1444
+			    //  buttons
1445
+			    $output .= $prefix . ' .btn-'.esc_attr($type).'{';
1446
+			    $output .= ' 
1447 1447
             --bs-btn-bg: '.esc_attr($color_code).';
1448 1448
             --bs-btn-border-color: '.esc_attr($color_code).';
1449 1449
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1455,17 +1455,17 @@  discard block
 block discarded – undo
1455 1455
             --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1456 1456
             --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1457 1457
             ';
1458
-//			$output .= '
1459
-//		    --bs-btn-color: #fff;
1460
-//			--bs-btn-hover-color: #fff;
1461
-//			--bs-btn-active-color: #fff;
1462
-//			--bs-btn-disabled-color: #fff;
1463
-//            ';
1464
-			$output .= '}';
1465
-
1466
-			//  buttons outline
1467
-			$output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1468
-			$output .= ' 
1458
+    //			$output .= '
1459
+    //		    --bs-btn-color: #fff;
1460
+    //			--bs-btn-hover-color: #fff;
1461
+    //			--bs-btn-active-color: #fff;
1462
+    //			--bs-btn-disabled-color: #fff;
1463
+    //            ';
1464
+			    $output .= '}';
1465
+
1466
+			    //  buttons outline
1467
+			    $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{';
1468
+			    $output .= ' 
1469 1469
 			--bs-btn-color: '.esc_attr($color_code).';
1470 1470
             --bs-btn-border-color: '.esc_attr($color_code).';
1471 1471
             --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9);
@@ -1477,140 +1477,140 @@  discard block
 block discarded – undo
1477 1477
             --bs-btn-disabled-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .5);
1478 1478
             --bs-btn-disabled-border-color: rgba(var(--bs-'.esc_attr($type).'-rgb), .1);
1479 1479
             ';
1480
-//			$output .= '
1481
-//		    --bs-btn-color: #fff;
1482
-//			--bs-btn-hover-color: #fff;
1483
-//			--bs-btn-active-color: #fff;
1484
-//			--bs-btn-disabled-color: #fff;
1485
-//            ';
1486
-			$output .= '}';
1487
-
1488
-
1489
-            // button hover
1490
-			$output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1491
-			$output .= ' 
1480
+    //			$output .= '
1481
+    //		    --bs-btn-color: #fff;
1482
+    //			--bs-btn-hover-color: #fff;
1483
+    //			--bs-btn-active-color: #fff;
1484
+    //			--bs-btn-disabled-color: #fff;
1485
+    //            ';
1486
+			    $output .= '}';
1487
+
1488
+
1489
+                // button hover
1490
+			    $output .= $prefix . ' .btn-'.esc_attr($type).':hover{';
1491
+			    $output .= ' 
1492 1492
             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);
1493 1493
             }
1494 1494
             ';
1495 1495
 
1496 1496
 
1497
-			if ( $aui_bs5 ) {
1498
-//				$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).'; }';
1499
-				$output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1500
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1501
-			}
1502
-
1503
-
1504
-			if ( $is_custom ) {
1505
-
1506
-//				echo '###'.$type;exit;
1507
-
1508
-				// build rules into each type
1509
-				foreach($selectors as $selector => $types){
1510
-					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1511
-					$types = array_combine($types,$types);
1512
-					if(isset($types['c'])){$color[] = $selector;}
1513
-					if(isset($types['b'])){$background[] = $selector;}
1514
-					if(isset($types['o'])){$border[] = $selector;}
1515
-					if(isset($types['f'])){$fill[] = $selector;}
1516
-				}
1517
-
1518
-//				// build rules into each type
1519
-//				foreach($important_selectors as $selector => $types){
1520
-//					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1521
-//					$types = array_combine($types,$types);
1522
-//					if(isset($types['c'])){$color_i[] = $selector;}
1523
-//					if(isset($types['b'])){$background_i[] = $selector;}
1524
-//					if(isset($types['o'])){$border_i[] = $selector;}
1525
-//					if(isset($types['f'])){$fill_i[] = $selector;}
1526
-//				}
1527
-
1528
-				// add any color rules
1529
-				if(!empty($color)){
1530
-					$output .= implode(",",$color) . "{color: $color_code;} ";
1531
-				}
1532
-				if(!empty($color_i)){
1533
-					$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1534
-				}
1535
-
1536
-				// add any background color rules
1537
-				if(!empty($background)){
1538
-					$output .= implode(",",$background) . "{background-color: $color_code;} ";
1539
-				}
1540
-				if(!empty($background_i)){
1541
-					$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1542
-//				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1543
-				}
1544
-
1545
-				// add any border color rules
1546
-				if(!empty($border)){
1547
-					$output .= implode(",",$border) . "{border-color: $color_code;} ";
1548
-				}
1549
-				if(!empty($border_i)){
1550
-					$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1551
-				}
1552
-
1553
-				// add any fill color rules
1554
-				if(!empty($fill)){
1555
-					$output .= implode(",",$fill) . "{fill: $color_code;} ";
1556
-				}
1557
-				if(!empty($fill_i)){
1558
-					$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1559
-				}
1560
-
1561
-			}
1562
-
1563
-
1564
-
1565
-
1566
-			$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;' : '';
1567
-			// darken
1568
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1569
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1570
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1571
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1572
-
1573
-			// lighten
1574
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1575
-
1576
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1577
-			$op_25 = $color_code."40"; // 25% opacity
1578
-
1579
-
1580
-			// button states
1581
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1582
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1583
-//			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1584
-			$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;} ";
1585
-			$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.";} ";
1586
-            $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;} ";
1587
-            $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} ";
1588
-
1589
-			// text
1590
-//			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
1591
-
1592
-
1593
-//			if ( $type == 'primary' ) {
1594
-//				// dropdown's
1595
-//				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1596
-//
1597
-//				// input states
1598
-//				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1599
-//
1600
-//				// page link
1601
-//				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1602
-//			}
1603
-
1604
-			// alerts
1605
-			if ( $aui_bs5 ) {
1606
-//				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1607
-				$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;} ";
1608
-			}
1609
-
1610
-			return $output;
1611
-		}
1612
-
1613
-		/**
1497
+			    if ( $aui_bs5 ) {
1498
+    //				$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).'; }';
1499
+				    $output .= 'html body {--bs-'.esc_attr($type).': '.esc_attr($color_code).'; }';
1500
+				    $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1501
+			    }
1502
+
1503
+
1504
+			    if ( $is_custom ) {
1505
+
1506
+    //				echo '###'.$type;exit;
1507
+
1508
+				    // build rules into each type
1509
+				    foreach($selectors as $selector => $types){
1510
+					    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1511
+					    $types = array_combine($types,$types);
1512
+					    if(isset($types['c'])){$color[] = $selector;}
1513
+					    if(isset($types['b'])){$background[] = $selector;}
1514
+					    if(isset($types['o'])){$border[] = $selector;}
1515
+					    if(isset($types['f'])){$fill[] = $selector;}
1516
+				    }
1517
+
1518
+    //				// build rules into each type
1519
+    //				foreach($important_selectors as $selector => $types){
1520
+    //					$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1521
+    //					$types = array_combine($types,$types);
1522
+    //					if(isset($types['c'])){$color_i[] = $selector;}
1523
+    //					if(isset($types['b'])){$background_i[] = $selector;}
1524
+    //					if(isset($types['o'])){$border_i[] = $selector;}
1525
+    //					if(isset($types['f'])){$fill_i[] = $selector;}
1526
+    //				}
1527
+
1528
+				    // add any color rules
1529
+				    if(!empty($color)){
1530
+					    $output .= implode(",",$color) . "{color: $color_code;} ";
1531
+				    }
1532
+				    if(!empty($color_i)){
1533
+					    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1534
+				    }
1535
+
1536
+				    // add any background color rules
1537
+				    if(!empty($background)){
1538
+					    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1539
+				    }
1540
+				    if(!empty($background_i)){
1541
+					    $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1542
+    //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1543
+				    }
1544
+
1545
+				    // add any border color rules
1546
+				    if(!empty($border)){
1547
+					    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1548
+				    }
1549
+				    if(!empty($border_i)){
1550
+					    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1551
+				    }
1552
+
1553
+				    // add any fill color rules
1554
+				    if(!empty($fill)){
1555
+					    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1556
+				    }
1557
+				    if(!empty($fill_i)){
1558
+					    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1559
+				    }
1560
+
1561
+			    }
1562
+
1563
+
1564
+
1565
+
1566
+			    $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;' : '';
1567
+			    // darken
1568
+			    $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1569
+			    $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1570
+			    $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1571
+			    $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1572
+
1573
+			    // lighten
1574
+			    $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1575
+
1576
+			    // opacity see https://css-tricks.com/8-digit-hex-codes/
1577
+			    $op_25 = $color_code."40"; // 25% opacity
1578
+
1579
+
1580
+			    // button states
1581
+			    $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1582
+			    $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1583
+    //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1584
+			    $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;} ";
1585
+			    $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.";} ";
1586
+                $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;} ";
1587
+                $output .= $prefix ." .btn-{$type}:not(:disabled):not(.disabled):active:focus, $prefix .btn-{$type}:not(:disabled):not(.disabled):focus {box-shadow: 0 0.25rem 0.25rem 0.125rem rgba(var(--bs-{$type}-rgb), 0.1), 0 0.375rem 0.75rem -0.125rem rgba(var(--bs-{$type}-rgb), 0.4);} ";
1588
+
1589
+			    // text
1590
+    //			$output .= $prefix .".xxx, .text-{$type} {color: var(--bs-".esc_attr($type).");} ";
1591
+
1592
+
1593
+    //			if ( $type == 'primary' ) {
1594
+    //				// dropdown's
1595
+    //				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1596
+    //
1597
+    //				// input states
1598
+    //				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1599
+    //
1600
+    //				// page link
1601
+    //				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1602
+    //			}
1603
+
1604
+			    // alerts
1605
+			    if ( $aui_bs5 ) {
1606
+    //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1607
+				    $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;} ";
1608
+			    }
1609
+
1610
+			    return $output;
1611
+		    }
1612
+
1613
+		    /**
1614 1614
 		 * Build the CSS to overwrite a bootstrap color variable.
1615 1615
 		 *
1616 1616
 		 * @param $type
@@ -1619,214 +1619,214 @@  discard block
 block discarded – undo
1619 1619
 		 *
1620 1620
 		 * @return string
1621 1621
 		 */
1622
-		public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1623
-            global $aui_bs5;
1622
+		    public static function css_overwrite($type,$color_code,$compatibility, $hex = '' ){
1623
+                global $aui_bs5;
1624 1624
 
1625
-			$is_var = false;
1626
-			if(!$color_code){return '';}
1627
-			if(strpos($color_code, 'var') !== false){
1628
-				//if(!sanitize_hex_color($color_code)){
1629
-				$color_code = esc_attr($color_code);
1630
-				$is_var = true;
1631
-//				$color_code = "rgba($color_code, 0.5)";
1632
-//                echo '###1'.$color_code.'###';//exit;
1633
-			}
1625
+			    $is_var = false;
1626
+			    if(!$color_code){return '';}
1627
+			    if(strpos($color_code, 'var') !== false){
1628
+				    //if(!sanitize_hex_color($color_code)){
1629
+				    $color_code = esc_attr($color_code);
1630
+				    $is_var = true;
1631
+    //				$color_code = "rgba($color_code, 0.5)";
1632
+    //                echo '###1'.$color_code.'###';//exit;
1633
+			    }
1634 1634
 
1635
-//            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1635
+    //            echo '@@@'.$color_code.'==='.self::hex_to_rgb($color_code);exit;
1636 1636
 
1637
-			if(!$color_code){return '';}
1637
+			    if(!$color_code){return '';}
1638 1638
 
1639
-            $rgb = self::hex_to_rgb($hex);
1639
+                $rgb = self::hex_to_rgb($hex);
1640 1640
 
1641
-			if($compatibility===true || $compatibility===1){
1642
-				$compatibility = '.bsui';
1643
-			}elseif(!$compatibility){
1644
-				$compatibility = '';
1645
-			}else{
1646
-				$compatibility = esc_attr($compatibility);
1647
-			}
1641
+			    if($compatibility===true || $compatibility===1){
1642
+				    $compatibility = '.bsui';
1643
+			    }elseif(!$compatibility){
1644
+				    $compatibility = '';
1645
+			    }else{
1646
+				    $compatibility = esc_attr($compatibility);
1647
+			    }
1648 1648
 
1649 1649
 
1650 1650
 
1651
-//            echo '####'.$color_code;exit;
1651
+    //            echo '####'.$color_code;exit;
1652 1652
 
1653
-			$type = sanitize_html_class($type);
1653
+			    $type = sanitize_html_class($type);
1654 1654
 
1655
-			/**
1655
+			    /**
1656 1656
 			 * c = color, b = background color, o = border-color, f = fill
1657 1657
 			 */
1658
-			$selectors = array(
1659
-				".btn-{$type}"                                              => array( 'b', 'o' ),
1660
-				".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1661
-				".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1662
-				".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1663
-				".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1664
-				".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1665
-				".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1666
-				".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1667
-				".badge-{$type}"                                            => array( 'b' ),
1668
-				".alert-{$type}"                                            => array( 'b', 'o' ),
1669
-				".bg-{$type}"                                               => array( 'b', 'f' ),
1670
-				".btn-link.btn-{$type}"                                     => array( 'c' ),
1671
-			);
1672
-
1673
-			if ( $aui_bs5 ) {
1674
-                unset($selectors[".alert-{$type}" ]);
1675
-			}
1676
-
1677
-			if ( $type == 'primary' ) {
1678
-				$selectors = $selectors + array(
1679
-						'a'                                                                                                    => array( 'c' ),
1680
-						'.btn-link'                                                                                            => array( 'c' ),
1681
-						'.dropdown-item.active'                                                                                => array( 'b' ),
1682
-						'.custom-control-input:checked~.custom-control-label::before'                                          => array(
1683
-							'b',
1684
-							'o'
1685
-						),
1686
-						'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1687
-							'b',
1688
-							'o'
1689
-						),
1690
-						'.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1691
-						'.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1692
-						'.page-link'                                                                                           => array( 'c' ),
1693
-						'.page-item.active .page-link'                                                                         => array(
1694
-							'b',
1695
-							'o'
1696
-						),
1697
-						'.progress-bar'                                                                                        => array( 'b' ),
1698
-						'.list-group-item.active'                                                                              => array(
1699
-							'b',
1700
-							'o'
1701
-						),
1702
-						'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1703
-//				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1704
-//				    '.custom-range::-moz-range-thumb' => array('b'),
1705
-//				    '.custom-range::-ms-thumb' => array('b'),
1706
-					);
1707
-			}
1708
-
1709
-			$important_selectors = array(
1710
-				".bg-{$type}" => array('b','f'),
1711
-				".border-{$type}" => array('o'),
1712
-				".text-{$type}" => array('c'),
1713
-			);
1714
-
1715
-			$color = array();
1716
-			$color_i = array();
1717
-			$background = array();
1718
-			$background_i = array();
1719
-			$border = array();
1720
-			$border_i = array();
1721
-			$fill = array();
1722
-			$fill_i = array();
1723
-
1724
-			$output = '';
1725
-
1726
-			if ( $aui_bs5 ) {
1727
-//				$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).'; }';
1728
-				$output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1729
-			}
1730
-
1731
-			// build rules into each type
1732
-			foreach($selectors as $selector => $types){
1733
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1734
-				$types = array_combine($types,$types);
1735
-				if(isset($types['c'])){$color[] = $selector;}
1736
-				if(isset($types['b'])){$background[] = $selector;}
1737
-				if(isset($types['o'])){$border[] = $selector;}
1738
-				if(isset($types['f'])){$fill[] = $selector;}
1739
-			}
1740
-
1741
-			// build rules into each type
1742
-			foreach($important_selectors as $selector => $types){
1743
-				$selector = $compatibility ? $compatibility . " ".$selector : $selector;
1744
-				$types = array_combine($types,$types);
1745
-				if(isset($types['c'])){$color_i[] = $selector;}
1746
-				if(isset($types['b'])){$background_i[] = $selector;}
1747
-				if(isset($types['o'])){$border_i[] = $selector;}
1748
-				if(isset($types['f'])){$fill_i[] = $selector;}
1749
-			}
1750
-
1751
-			// add any color rules
1752
-			if(!empty($color)){
1753
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1754
-			}
1755
-			if(!empty($color_i)){
1756
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1757
-			}
1758
-
1759
-			// add any background color rules
1760
-			if(!empty($background)){
1761
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1762
-			}
1763
-			if(!empty($background_i)){
1764
-				$output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1765
-//				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1766
-			}
1767
-
1768
-			// add any border color rules
1769
-			if(!empty($border)){
1770
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1771
-			}
1772
-			if(!empty($border_i)){
1773
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1774
-			}
1775
-
1776
-			// add any fill color rules
1777
-			if(!empty($fill)){
1778
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1779
-			}
1780
-			if(!empty($fill_i)){
1781
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1782
-			}
1783
-
1784
-
1785
-			$prefix = $compatibility ? $compatibility . " " : "";
1786
-
1787
-			$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;' : '';
1788
-			// darken
1789
-			$darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1790
-			$darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1791
-			$darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1792
-			$darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1793
-
1794
-			// lighten
1795
-			$lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1796
-
1797
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1798
-			$op_25 = $color_code."40"; // 25% opacity
1799
-
1800
-
1801
-			// button states
1802
-			$output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1803
-			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1804
-//			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1805
-			$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;} ";
1806
-			$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.";} ";
1807
-			$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;} ";
1808
-
1809
-			if ( $type == 'primary' ) {
1810
-				// dropdown's
1811
-				$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1812
-
1813
-				// input states
1814
-				$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1815
-
1816
-				// page link
1817
-				$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1818
-			}
1819
-
1820
-            // alerts
1821
-			if ( $aui_bs5 ) {
1822
-//				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1823
-				$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;} ";
1824
-			}
1825
-
1826
-			return $output;
1827
-		}
1828
-
1829
-		/**
1658
+			    $selectors = array(
1659
+				    ".btn-{$type}"                                              => array( 'b', 'o' ),
1660
+				    ".btn-{$type}.disabled"                                     => array( 'b', 'o' ),
1661
+				    ".btn-{$type}:disabled"                                     => array( 'b', 'o' ),
1662
+				    ".btn-outline-{$type}"                                      => array( 'c', 'o' ),
1663
+				    ".btn-outline-{$type}:hover"                                => array( 'b', 'o' ),
1664
+				    ".btn-outline-{$type}:not(:disabled):not(.disabled).active" => array( 'b', 'o' ),
1665
+				    ".btn-outline-{$type}:not(:disabled):not(.disabled):active" => array( 'b', 'o' ),
1666
+				    ".show>.btn-outline-{$type}.dropdown-toggle"                => array( 'b', 'o' ),
1667
+				    ".badge-{$type}"                                            => array( 'b' ),
1668
+				    ".alert-{$type}"                                            => array( 'b', 'o' ),
1669
+				    ".bg-{$type}"                                               => array( 'b', 'f' ),
1670
+				    ".btn-link.btn-{$type}"                                     => array( 'c' ),
1671
+			    );
1672
+
1673
+			    if ( $aui_bs5 ) {
1674
+                    unset($selectors[".alert-{$type}" ]);
1675
+			    }
1676
+
1677
+			    if ( $type == 'primary' ) {
1678
+				    $selectors = $selectors + array(
1679
+						    'a'                                                                                                    => array( 'c' ),
1680
+						    '.btn-link'                                                                                            => array( 'c' ),
1681
+						    '.dropdown-item.active'                                                                                => array( 'b' ),
1682
+						    '.custom-control-input:checked~.custom-control-label::before'                                          => array(
1683
+							    'b',
1684
+							    'o'
1685
+						    ),
1686
+						    '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before'                   => array(
1687
+							    'b',
1688
+							    'o'
1689
+						    ),
1690
+						    '.nav-pills .nav-link.active'                                                                          => array( 'b' ),
1691
+						    '.nav-pills .show>.nav-link'                                                                           => array( 'b' ),
1692
+						    '.page-link'                                                                                           => array( 'c' ),
1693
+						    '.page-item.active .page-link'                                                                         => array(
1694
+							    'b',
1695
+							    'o'
1696
+						    ),
1697
+						    '.progress-bar'                                                                                        => array( 'b' ),
1698
+						    '.list-group-item.active'                                                                              => array(
1699
+							    'b',
1700
+							    'o'
1701
+						    ),
1702
+						    '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array( 'b' ),
1703
+    //				    '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1704
+    //				    '.custom-range::-moz-range-thumb' => array('b'),
1705
+    //				    '.custom-range::-ms-thumb' => array('b'),
1706
+					    );
1707
+			    }
1708
+
1709
+			    $important_selectors = array(
1710
+				    ".bg-{$type}" => array('b','f'),
1711
+				    ".border-{$type}" => array('o'),
1712
+				    ".text-{$type}" => array('c'),
1713
+			    );
1714
+
1715
+			    $color = array();
1716
+			    $color_i = array();
1717
+			    $background = array();
1718
+			    $background_i = array();
1719
+			    $border = array();
1720
+			    $border_i = array();
1721
+			    $fill = array();
1722
+			    $fill_i = array();
1723
+
1724
+			    $output = '';
1725
+
1726
+			    if ( $aui_bs5 ) {
1727
+    //				$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).'; }';
1728
+				    $output .= 'html body {--bs-'.esc_attr($type).'-rgb: '.$rgb.'; }';
1729
+			    }
1730
+
1731
+			    // build rules into each type
1732
+			    foreach($selectors as $selector => $types){
1733
+				    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1734
+				    $types = array_combine($types,$types);
1735
+				    if(isset($types['c'])){$color[] = $selector;}
1736
+				    if(isset($types['b'])){$background[] = $selector;}
1737
+				    if(isset($types['o'])){$border[] = $selector;}
1738
+				    if(isset($types['f'])){$fill[] = $selector;}
1739
+			    }
1740
+
1741
+			    // build rules into each type
1742
+			    foreach($important_selectors as $selector => $types){
1743
+				    $selector = $compatibility ? $compatibility . " ".$selector : $selector;
1744
+				    $types = array_combine($types,$types);
1745
+				    if(isset($types['c'])){$color_i[] = $selector;}
1746
+				    if(isset($types['b'])){$background_i[] = $selector;}
1747
+				    if(isset($types['o'])){$border_i[] = $selector;}
1748
+				    if(isset($types['f'])){$fill_i[] = $selector;}
1749
+			    }
1750
+
1751
+			    // add any color rules
1752
+			    if(!empty($color)){
1753
+				    $output .= implode(",",$color) . "{color: $color_code;} ";
1754
+			    }
1755
+			    if(!empty($color_i)){
1756
+				    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1757
+			    }
1758
+
1759
+			    // add any background color rules
1760
+			    if(!empty($background)){
1761
+				    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1762
+			    }
1763
+			    if(!empty($background_i)){
1764
+				    $output .= $aui_bs5 ? '' : implode(",",$background_i) . "{background-color: $color_code !important;} ";
1765
+    //				$output .= implode(",",$background_i) . "{background-color: rgba(var(--bs-primary-rgb), var(--bs-bg-opacity)) !important;} ";
1766
+			    }
1767
+
1768
+			    // add any border color rules
1769
+			    if(!empty($border)){
1770
+				    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1771
+			    }
1772
+			    if(!empty($border_i)){
1773
+				    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1774
+			    }
1775
+
1776
+			    // add any fill color rules
1777
+			    if(!empty($fill)){
1778
+				    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1779
+			    }
1780
+			    if(!empty($fill_i)){
1781
+				    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1782
+			    }
1783
+
1784
+
1785
+			    $prefix = $compatibility ? $compatibility . " " : "";
1786
+
1787
+			    $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;' : '';
1788
+			    // darken
1789
+			    $darker_075 = $is_var ? $color_code.';filter:brightness(0.925)' : self::css_hex_lighten_darken($color_code,"-0.075");
1790
+			    $darker_10 = $is_var ? $color_code.';filter:brightness(0.9)' : self::css_hex_lighten_darken($color_code,"-0.10");
1791
+			    $darker_125 = $is_var ? $color_code.';filter:brightness(0.875)' : self::css_hex_lighten_darken($color_code,"-0.125");
1792
+			    $darker_40 = $is_var ? $color_code.';filter:brightness(0.6)' : self::css_hex_lighten_darken($color_code,"-0.4");
1793
+
1794
+			    // lighten
1795
+			    $lighten_25 = $is_var ? $color_code.';filter:brightness(1.25)' :self::css_hex_lighten_darken($color_code,"0.25");
1796
+
1797
+			    // opacity see https://css-tricks.com/8-digit-hex-codes/
1798
+			    $op_25 = $color_code."40"; // 25% opacity
1799
+
1800
+
1801
+			    // button states
1802
+			    $output .= $is_var ? $prefix ." .btn-{$type}{{$transition }} " : '';
1803
+			    $output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1804
+    //			$output .= $prefix ." .btn-{$type}:hover, $prefix .btn-{$type}:focus, $prefix .btn-{$type}.focus{background-color: #000;    border-color: #000;} ";
1805
+			    $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;} ";
1806
+			    $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.";} ";
1807
+			    $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;} ";
1808
+
1809
+			    if ( $type == 'primary' ) {
1810
+				    // dropdown's
1811
+				    $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1812
+
1813
+				    // input states
1814
+				    $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
1815
+
1816
+				    // page link
1817
+				    $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1818
+			    }
1819
+
1820
+                // alerts
1821
+			    if ( $aui_bs5 ) {
1822
+    //				$output .= $is_var ? '' : $prefix ." .alert-{$type} {background-color: ".$color_code."20;    border-color: ".$color_code."30;color:$darker_40} ";
1823
+				    $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;} ";
1824
+			    }
1825
+
1826
+			    return $output;
1827
+		    }
1828
+
1829
+		    /**
1830 1830
 		 *
1831 1831
 		 * @deprecated 0.1.76 Use css_overwrite()
1832 1832
 		 *
@@ -1836,151 +1836,151 @@  discard block
 block discarded – undo
1836 1836
 		 *
1837 1837
 		 * @return string
1838 1838
 		 */
1839
-		public static function css_primary($color_code,$compatibility, $use_variable = false){
1839
+		    public static function css_primary($color_code,$compatibility, $use_variable = false){
1840 1840
 
1841
-			if(!$use_variable){
1842
-				$color_code = sanitize_hex_color($color_code);
1843
-				if(!$color_code){return '';}
1844
-			}
1841
+			    if(!$use_variable){
1842
+				    $color_code = sanitize_hex_color($color_code);
1843
+				    if(!$color_code){return '';}
1844
+			    }
1845 1845
 
1846
-			/**
1846
+			    /**
1847 1847
 			 * c = color, b = background color, o = border-color, f = fill
1848 1848
 			 */
1849
-			$selectors = array(
1850
-				'a' => array('c'),
1851
-				'.btn-primary' => array('b','o'),
1852
-				'.btn-primary.disabled' => array('b','o'),
1853
-				'.btn-primary:disabled' => array('b','o'),
1854
-				'.btn-outline-primary' => array('c','o'),
1855
-				'.btn-outline-primary:hover' => array('b','o'),
1856
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1857
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1858
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1859
-				'.btn-link' => array('c'),
1860
-				'.dropdown-item.active' => array('b'),
1861
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1862
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1863
-//				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1864
-//				'.custom-range::-moz-range-thumb' => array('b'),
1865
-//				'.custom-range::-ms-thumb' => array('b'),
1866
-				'.nav-pills .nav-link.active' => array('b'),
1867
-				'.nav-pills .show>.nav-link' => array('b'),
1868
-				'.page-link' => array('c'),
1869
-				'.page-item.active .page-link' => array('b','o'),
1870
-				'.badge-primary' => array('b'),
1871
-				'.alert-primary' => array('b','o'),
1872
-				'.progress-bar' => array('b'),
1873
-				'.list-group-item.active' => array('b','o'),
1874
-				'.bg-primary' => array('b','f'),
1875
-				'.btn-link.btn-primary' => array('c'),
1876
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1877
-			);
1878
-
1879
-			$important_selectors = array(
1880
-				'.bg-primary' => array('b','f'),
1881
-				'.border-primary' => array('o'),
1882
-				'.text-primary' => array('c'),
1883
-			);
1884
-
1885
-			$color = array();
1886
-			$color_i = array();
1887
-			$background = array();
1888
-			$background_i = array();
1889
-			$border = array();
1890
-			$border_i = array();
1891
-			$fill = array();
1892
-			$fill_i = array();
1893
-
1894
-			$output = '';
1895
-
1896
-			// build rules into each type
1897
-			foreach($selectors as $selector => $types){
1898
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1899
-				$types = array_combine($types,$types);
1900
-				if(isset($types['c'])){$color[] = $selector;}
1901
-				if(isset($types['b'])){$background[] = $selector;}
1902
-				if(isset($types['o'])){$border[] = $selector;}
1903
-				if(isset($types['f'])){$fill[] = $selector;}
1904
-			}
1905
-
1906
-			// build rules into each type
1907
-			foreach($important_selectors as $selector => $types){
1908
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1909
-				$types = array_combine($types,$types);
1910
-				if(isset($types['c'])){$color_i[] = $selector;}
1911
-				if(isset($types['b'])){$background_i[] = $selector;}
1912
-				if(isset($types['o'])){$border_i[] = $selector;}
1913
-				if(isset($types['f'])){$fill_i[] = $selector;}
1914
-			}
1915
-
1916
-			// add any color rules
1917
-			if(!empty($color)){
1918
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1919
-			}
1920
-			if(!empty($color_i)){
1921
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1922
-			}
1923
-
1924
-			// add any background color rules
1925
-			if(!empty($background)){
1926
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1927
-			}
1928
-			if(!empty($background_i)){
1929
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1930
-			}
1931
-
1932
-			// add any border color rules
1933
-			if(!empty($border)){
1934
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1935
-			}
1936
-			if(!empty($border_i)){
1937
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1938
-			}
1939
-
1940
-			// add any fill color rules
1941
-			if(!empty($fill)){
1942
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1943
-			}
1944
-			if(!empty($fill_i)){
1945
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1946
-			}
1947
-
1948
-
1949
-			$prefix = $compatibility ? ".bsui " : "";
1950
-
1951
-			// darken
1952
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1953
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1954
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1955
-
1956
-			// lighten
1957
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1958
-
1959
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1960
-			$op_25 = $color_code."40"; // 25% opacity
1961
-
1962
-
1963
-			// button states
1964
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1965
-			$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;} ";
1966
-			$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.";} ";
1967
-			$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;} ";
1968
-
1969
-
1970
-			// dropdown's
1971
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1972
-
1973
-
1974
-			// input states
1975
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1976
-
1977
-			// page link
1978
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1979
-
1980
-			return $output;
1981
-		}
1982
-
1983
-		/**
1849
+			    $selectors = array(
1850
+				    'a' => array('c'),
1851
+				    '.btn-primary' => array('b','o'),
1852
+				    '.btn-primary.disabled' => array('b','o'),
1853
+				    '.btn-primary:disabled' => array('b','o'),
1854
+				    '.btn-outline-primary' => array('c','o'),
1855
+				    '.btn-outline-primary:hover' => array('b','o'),
1856
+				    '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1857
+				    '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1858
+				    '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1859
+				    '.btn-link' => array('c'),
1860
+				    '.dropdown-item.active' => array('b'),
1861
+				    '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1862
+				    '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1863
+    //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1864
+    //				'.custom-range::-moz-range-thumb' => array('b'),
1865
+    //				'.custom-range::-ms-thumb' => array('b'),
1866
+				    '.nav-pills .nav-link.active' => array('b'),
1867
+				    '.nav-pills .show>.nav-link' => array('b'),
1868
+				    '.page-link' => array('c'),
1869
+				    '.page-item.active .page-link' => array('b','o'),
1870
+				    '.badge-primary' => array('b'),
1871
+				    '.alert-primary' => array('b','o'),
1872
+				    '.progress-bar' => array('b'),
1873
+				    '.list-group-item.active' => array('b','o'),
1874
+				    '.bg-primary' => array('b','f'),
1875
+				    '.btn-link.btn-primary' => array('c'),
1876
+				    '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1877
+			    );
1878
+
1879
+			    $important_selectors = array(
1880
+				    '.bg-primary' => array('b','f'),
1881
+				    '.border-primary' => array('o'),
1882
+				    '.text-primary' => array('c'),
1883
+			    );
1884
+
1885
+			    $color = array();
1886
+			    $color_i = array();
1887
+			    $background = array();
1888
+			    $background_i = array();
1889
+			    $border = array();
1890
+			    $border_i = array();
1891
+			    $fill = array();
1892
+			    $fill_i = array();
1893
+
1894
+			    $output = '';
1895
+
1896
+			    // build rules into each type
1897
+			    foreach($selectors as $selector => $types){
1898
+				    $selector = $compatibility ? ".bsui ".$selector : $selector;
1899
+				    $types = array_combine($types,$types);
1900
+				    if(isset($types['c'])){$color[] = $selector;}
1901
+				    if(isset($types['b'])){$background[] = $selector;}
1902
+				    if(isset($types['o'])){$border[] = $selector;}
1903
+				    if(isset($types['f'])){$fill[] = $selector;}
1904
+			    }
1905
+
1906
+			    // build rules into each type
1907
+			    foreach($important_selectors as $selector => $types){
1908
+				    $selector = $compatibility ? ".bsui ".$selector : $selector;
1909
+				    $types = array_combine($types,$types);
1910
+				    if(isset($types['c'])){$color_i[] = $selector;}
1911
+				    if(isset($types['b'])){$background_i[] = $selector;}
1912
+				    if(isset($types['o'])){$border_i[] = $selector;}
1913
+				    if(isset($types['f'])){$fill_i[] = $selector;}
1914
+			    }
1915
+
1916
+			    // add any color rules
1917
+			    if(!empty($color)){
1918
+				    $output .= implode(",",$color) . "{color: $color_code;} ";
1919
+			    }
1920
+			    if(!empty($color_i)){
1921
+				    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1922
+			    }
1923
+
1924
+			    // add any background color rules
1925
+			    if(!empty($background)){
1926
+				    $output .= implode(",",$background) . "{background-color: $color_code;} ";
1927
+			    }
1928
+			    if(!empty($background_i)){
1929
+				    $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1930
+			    }
1931
+
1932
+			    // add any border color rules
1933
+			    if(!empty($border)){
1934
+				    $output .= implode(",",$border) . "{border-color: $color_code;} ";
1935
+			    }
1936
+			    if(!empty($border_i)){
1937
+				    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1938
+			    }
1939
+
1940
+			    // add any fill color rules
1941
+			    if(!empty($fill)){
1942
+				    $output .= implode(",",$fill) . "{fill: $color_code;} ";
1943
+			    }
1944
+			    if(!empty($fill_i)){
1945
+				    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1946
+			    }
1947
+
1948
+
1949
+			    $prefix = $compatibility ? ".bsui " : "";
1950
+
1951
+			    // darken
1952
+			    $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1953
+			    $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1954
+			    $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1955
+
1956
+			    // lighten
1957
+			    $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1958
+
1959
+			    // opacity see https://css-tricks.com/8-digit-hex-codes/
1960
+			    $op_25 = $color_code."40"; // 25% opacity
1961
+
1962
+
1963
+			    // button states
1964
+			    $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1965
+			    $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;} ";
1966
+			    $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.";} ";
1967
+			    $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;} ";
1968
+
1969
+
1970
+			    // dropdown's
1971
+			    $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1972
+
1973
+
1974
+			    // input states
1975
+			    $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1976
+
1977
+			    // page link
1978
+			    $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1979
+
1980
+			    return $output;
1981
+		    }
1982
+
1983
+		    /**
1984 1984
 		 *
1985 1985
 		 * @deprecated 0.1.76 Use css_overwrite()
1986 1986
 		 *
@@ -1989,123 +1989,123 @@  discard block
 block discarded – undo
1989 1989
 		 *
1990 1990
 		 * @return string
1991 1991
 		 */
1992
-		public static function css_secondary($color_code,$compatibility){;
1993
-			$color_code = sanitize_hex_color($color_code);
1994
-			if(!$color_code){return '';}
1995
-			/**
1992
+		    public static function css_secondary($color_code,$compatibility){;
1993
+			    $color_code = sanitize_hex_color($color_code);
1994
+			    if(!$color_code){return '';}
1995
+			    /**
1996 1996
 			 * c = color, b = background color, o = border-color, f = fill
1997 1997
 			 */
1998
-			$selectors = array(
1999
-				'.btn-secondary' => array('b','o'),
2000
-				'.btn-secondary.disabled' => array('b','o'),
2001
-				'.btn-secondary:disabled' => array('b','o'),
2002
-				'.btn-outline-secondary' => array('c','o'),
2003
-				'.btn-outline-secondary:hover' => array('b','o'),
2004
-				'.btn-outline-secondary.disabled' => array('c'),
2005
-				'.btn-outline-secondary:disabled' => array('c'),
2006
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2007
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2008
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2009
-				'.badge-secondary' => array('b'),
2010
-				'.alert-secondary' => array('b','o'),
2011
-				'.btn-link.btn-secondary' => array('c'),
2012
-			);
2013
-
2014
-			$important_selectors = array(
2015
-				'.bg-secondary' => array('b','f'),
2016
-				'.border-secondary' => array('o'),
2017
-				'.text-secondary' => array('c'),
2018
-			);
2019
-
2020
-			$color = array();
2021
-			$color_i = array();
2022
-			$background = array();
2023
-			$background_i = array();
2024
-			$border = array();
2025
-			$border_i = array();
2026
-			$fill = array();
2027
-			$fill_i = array();
2028
-
2029
-			$output = '';
2030
-
2031
-			// build rules into each type
2032
-			foreach($selectors as $selector => $types){
2033
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2034
-				$types = array_combine($types,$types);
2035
-				if(isset($types['c'])){$color[] = $selector;}
2036
-				if(isset($types['b'])){$background[] = $selector;}
2037
-				if(isset($types['o'])){$border[] = $selector;}
2038
-				if(isset($types['f'])){$fill[] = $selector;}
2039
-			}
2040
-
2041
-			// build rules into each type
2042
-			foreach($important_selectors as $selector => $types){
2043
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
2044
-				$types = array_combine($types,$types);
2045
-				if(isset($types['c'])){$color_i[] = $selector;}
2046
-				if(isset($types['b'])){$background_i[] = $selector;}
2047
-				if(isset($types['o'])){$border_i[] = $selector;}
2048
-				if(isset($types['f'])){$fill_i[] = $selector;}
2049
-			}
2050
-
2051
-			// add any color rules
2052
-			if(!empty($color)){
2053
-				$output .= implode(",",$color) . "{color: $color_code;} ";
2054
-			}
2055
-			if(!empty($color_i)){
2056
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2057
-			}
2058
-
2059
-			// add any background color rules
2060
-			if(!empty($background)){
2061
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
2062
-			}
2063
-			if(!empty($background_i)){
2064
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2065
-			}
2066
-
2067
-			// add any border color rules
2068
-			if(!empty($border)){
2069
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
2070
-			}
2071
-			if(!empty($border_i)){
2072
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2073
-			}
2074
-
2075
-			// add any fill color rules
2076
-			if(!empty($fill)){
2077
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
2078
-			}
2079
-			if(!empty($fill_i)){
2080
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2081
-			}
2082
-
2083
-
2084
-			$prefix = $compatibility ? ".bsui " : "";
2085
-
2086
-			// darken
2087
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2088
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2089
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2090
-
2091
-			// lighten
2092
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2093
-
2094
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
2095
-			$op_25 = $color_code."40"; // 25% opacity
2096
-
2097
-
2098
-			// button states
2099
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2100
-			$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;} ";
2101
-			$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.";} ";
2102
-			$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;} ";
2103
-
2104
-
2105
-			return $output;
2106
-		}
2107
-
2108
-		/**
1998
+			    $selectors = array(
1999
+				    '.btn-secondary' => array('b','o'),
2000
+				    '.btn-secondary.disabled' => array('b','o'),
2001
+				    '.btn-secondary:disabled' => array('b','o'),
2002
+				    '.btn-outline-secondary' => array('c','o'),
2003
+				    '.btn-outline-secondary:hover' => array('b','o'),
2004
+				    '.btn-outline-secondary.disabled' => array('c'),
2005
+				    '.btn-outline-secondary:disabled' => array('c'),
2006
+				    '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
2007
+				    '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
2008
+				    '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
2009
+				    '.badge-secondary' => array('b'),
2010
+				    '.alert-secondary' => array('b','o'),
2011
+				    '.btn-link.btn-secondary' => array('c'),
2012
+			    );
2013
+
2014
+			    $important_selectors = array(
2015
+				    '.bg-secondary' => array('b','f'),
2016
+				    '.border-secondary' => array('o'),
2017
+				    '.text-secondary' => array('c'),
2018
+			    );
2019
+
2020
+			    $color = array();
2021
+			    $color_i = array();
2022
+			    $background = array();
2023
+			    $background_i = array();
2024
+			    $border = array();
2025
+			    $border_i = array();
2026
+			    $fill = array();
2027
+			    $fill_i = array();
2028
+
2029
+			    $output = '';
2030
+
2031
+			    // build rules into each type
2032
+			    foreach($selectors as $selector => $types){
2033
+				    $selector = $compatibility ? ".bsui ".$selector : $selector;
2034
+				    $types = array_combine($types,$types);
2035
+				    if(isset($types['c'])){$color[] = $selector;}
2036
+				    if(isset($types['b'])){$background[] = $selector;}
2037
+				    if(isset($types['o'])){$border[] = $selector;}
2038
+				    if(isset($types['f'])){$fill[] = $selector;}
2039
+			    }
2040
+
2041
+			    // build rules into each type
2042
+			    foreach($important_selectors as $selector => $types){
2043
+				    $selector = $compatibility ? ".bsui ".$selector : $selector;
2044
+				    $types = array_combine($types,$types);
2045
+				    if(isset($types['c'])){$color_i[] = $selector;}
2046
+				    if(isset($types['b'])){$background_i[] = $selector;}
2047
+				    if(isset($types['o'])){$border_i[] = $selector;}
2048
+				    if(isset($types['f'])){$fill_i[] = $selector;}
2049
+			    }
2050
+
2051
+			    // add any color rules
2052
+			    if(!empty($color)){
2053
+				    $output .= implode(",",$color) . "{color: $color_code;} ";
2054
+			    }
2055
+			    if(!empty($color_i)){
2056
+				    $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
2057
+			    }
2058
+
2059
+			    // add any background color rules
2060
+			    if(!empty($background)){
2061
+				    $output .= implode(",",$background) . "{background-color: $color_code;} ";
2062
+			    }
2063
+			    if(!empty($background_i)){
2064
+				    $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
2065
+			    }
2066
+
2067
+			    // add any border color rules
2068
+			    if(!empty($border)){
2069
+				    $output .= implode(",",$border) . "{border-color: $color_code;} ";
2070
+			    }
2071
+			    if(!empty($border_i)){
2072
+				    $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
2073
+			    }
2074
+
2075
+			    // add any fill color rules
2076
+			    if(!empty($fill)){
2077
+				    $output .= implode(",",$fill) . "{fill: $color_code;} ";
2078
+			    }
2079
+			    if(!empty($fill_i)){
2080
+				    $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
2081
+			    }
2082
+
2083
+
2084
+			    $prefix = $compatibility ? ".bsui " : "";
2085
+
2086
+			    // darken
2087
+			    $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
2088
+			    $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
2089
+			    $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
2090
+
2091
+			    // lighten
2092
+			    $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
2093
+
2094
+			    // opacity see https://css-tricks.com/8-digit-hex-codes/
2095
+			    $op_25 = $color_code."40"; // 25% opacity
2096
+
2097
+
2098
+			    // button states
2099
+			    $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
2100
+			    $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;} ";
2101
+			    $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.";} ";
2102
+			    $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;} ";
2103
+
2104
+
2105
+			    return $output;
2106
+		    }
2107
+
2108
+		    /**
2109 2109
 		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
2110 2110
 		 *
2111 2111
 		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
@@ -2113,265 +2113,265 @@  discard block
 block discarded – undo
2113 2113
 		 *
2114 2114
 		 * @return  string
2115 2115
 		 */
2116
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2117
-			$hexCode = ltrim($hexCode, '#');
2116
+		    public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
2117
+			    $hexCode = ltrim($hexCode, '#');
2118 2118
 
2119
-			if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) {
2120
-				return $hexCode;
2121
-			}
2119
+			    if ( strpos( $hexCode, 'rgba(' ) !== false || strpos( $hexCode, 'rgb(' ) !== false ) {
2120
+				    return $hexCode;
2121
+			    }
2122 2122
 
2123
-			if (strlen($hexCode) == 3) {
2124
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2125
-			}
2123
+			    if (strlen($hexCode) == 3) {
2124
+				    $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
2125
+			    }
2126 2126
 
2127
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
2127
+			    $hexCode = array_map('hexdec', str_split($hexCode, 2));
2128 2128
 
2129
-			foreach ($hexCode as & $color) {
2130
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2131
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
2129
+			    foreach ($hexCode as & $color) {
2130
+				    $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
2131
+				    $adjustAmount = ceil($adjustableLimit * $adjustPercent);
2132 2132
 
2133
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2134
-			}
2133
+				    $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
2134
+			    }
2135 2135
 
2136
-			return '#' . implode($hexCode);
2137
-		}
2136
+			    return '#' . implode($hexCode);
2137
+		    }
2138 2138
 
2139
-		/**
2139
+		    /**
2140 2140
 		 * Check if we should display examples.
2141 2141
 		 */
2142
-		public function maybe_show_examples(){
2143
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2144
-				echo "<head>";
2145
-				wp_head();
2146
-				echo "</head>";
2147
-				echo "<body>";
2148
-				echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2149
-				echo "</body>";
2150
-				exit;
2151
-			}
2152
-		}
2153
-
2154
-		/**
2142
+		    public function maybe_show_examples(){
2143
+			    if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
2144
+				    echo "<head>";
2145
+				    wp_head();
2146
+				    echo "</head>";
2147
+				    echo "<body>";
2148
+				    echo $this->get_examples(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2149
+				    echo "</body>";
2150
+				    exit;
2151
+			    }
2152
+		    }
2153
+
2154
+		    /**
2155 2155
 		 * Get developer examples.
2156 2156
 		 *
2157 2157
 		 * @return string
2158 2158
 		 */
2159
-		public function get_examples(){
2160
-			$output = '';
2161
-
2162
-
2163
-			// open form
2164
-			$output .= "<form class='p-5 m-5 border rounded'>";
2165
-
2166
-			// input example
2167
-			$output .= aui()->input(array(
2168
-				'type'  =>  'text',
2169
-				'id'    =>  'text-example',
2170
-				'name'    =>  'text-example',
2171
-				'placeholder'   => 'text placeholder',
2172
-				'title'   => 'Text input example',
2173
-				'value' =>  '',
2174
-				'required'  => false,
2175
-				'help_text' => 'help text',
2176
-				'label' => 'Text input example label'
2177
-			));
2178
-
2179
-			// input example
2180
-			$output .= aui()->input(array(
2181
-				'type'  =>  'url',
2182
-				'id'    =>  'text-example2',
2183
-				'name'    =>  'text-example',
2184
-				'placeholder'   => 'url placeholder',
2185
-				'title'   => 'Text input example',
2186
-				'value' =>  '',
2187
-				'required'  => false,
2188
-				'help_text' => 'help text',
2189
-				'label' => 'Text input example label'
2190
-			));
2191
-
2192
-			// checkbox example
2193
-			$output .= aui()->input(array(
2194
-				'type'  =>  'checkbox',
2195
-				'id'    =>  'checkbox-example',
2196
-				'name'    =>  'checkbox-example',
2197
-				'placeholder'   => 'checkbox-example',
2198
-				'title'   => 'Checkbox example',
2199
-				'value' =>  '1',
2200
-				'checked'   => true,
2201
-				'required'  => false,
2202
-				'help_text' => 'help text',
2203
-				'label' => 'Checkbox checked'
2204
-			));
2205
-
2206
-			// checkbox example
2207
-			$output .= aui()->input(array(
2208
-				'type'  =>  'checkbox',
2209
-				'id'    =>  'checkbox-example2',
2210
-				'name'    =>  'checkbox-example2',
2211
-				'placeholder'   => 'checkbox-example',
2212
-				'title'   => 'Checkbox example',
2213
-				'value' =>  '1',
2214
-				'checked'   => false,
2215
-				'required'  => false,
2216
-				'help_text' => 'help text',
2217
-				'label' => 'Checkbox un-checked'
2218
-			));
2219
-
2220
-			// switch example
2221
-			$output .= aui()->input(array(
2222
-				'type'  =>  'checkbox',
2223
-				'id'    =>  'switch-example',
2224
-				'name'    =>  'switch-example',
2225
-				'placeholder'   => 'checkbox-example',
2226
-				'title'   => 'Switch example',
2227
-				'value' =>  '1',
2228
-				'checked'   => true,
2229
-				'switch'    => true,
2230
-				'required'  => false,
2231
-				'help_text' => 'help text',
2232
-				'label' => 'Switch on'
2233
-			));
2234
-
2235
-			// switch example
2236
-			$output .= aui()->input(array(
2237
-				'type'  =>  'checkbox',
2238
-				'id'    =>  'switch-example2',
2239
-				'name'    =>  'switch-example2',
2240
-				'placeholder'   => 'checkbox-example',
2241
-				'title'   => 'Switch example',
2242
-				'value' =>  '1',
2243
-				'checked'   => false,
2244
-				'switch'    => true,
2245
-				'required'  => false,
2246
-				'help_text' => 'help text',
2247
-				'label' => 'Switch off'
2248
-			));
2249
-
2250
-			// close form
2251
-			$output .= "</form>";
2252
-
2253
-			return $output;
2254
-		}
2255
-
2256
-		/**
2159
+		    public function get_examples(){
2160
+			    $output = '';
2161
+
2162
+
2163
+			    // open form
2164
+			    $output .= "<form class='p-5 m-5 border rounded'>";
2165
+
2166
+			    // input example
2167
+			    $output .= aui()->input(array(
2168
+				    'type'  =>  'text',
2169
+				    'id'    =>  'text-example',
2170
+				    'name'    =>  'text-example',
2171
+				    'placeholder'   => 'text placeholder',
2172
+				    'title'   => 'Text input example',
2173
+				    'value' =>  '',
2174
+				    'required'  => false,
2175
+				    'help_text' => 'help text',
2176
+				    'label' => 'Text input example label'
2177
+			    ));
2178
+
2179
+			    // input example
2180
+			    $output .= aui()->input(array(
2181
+				    'type'  =>  'url',
2182
+				    'id'    =>  'text-example2',
2183
+				    'name'    =>  'text-example',
2184
+				    'placeholder'   => 'url placeholder',
2185
+				    'title'   => 'Text input example',
2186
+				    'value' =>  '',
2187
+				    'required'  => false,
2188
+				    'help_text' => 'help text',
2189
+				    'label' => 'Text input example label'
2190
+			    ));
2191
+
2192
+			    // checkbox example
2193
+			    $output .= aui()->input(array(
2194
+				    'type'  =>  'checkbox',
2195
+				    'id'    =>  'checkbox-example',
2196
+				    'name'    =>  'checkbox-example',
2197
+				    'placeholder'   => 'checkbox-example',
2198
+				    'title'   => 'Checkbox example',
2199
+				    'value' =>  '1',
2200
+				    'checked'   => true,
2201
+				    'required'  => false,
2202
+				    'help_text' => 'help text',
2203
+				    'label' => 'Checkbox checked'
2204
+			    ));
2205
+
2206
+			    // checkbox example
2207
+			    $output .= aui()->input(array(
2208
+				    'type'  =>  'checkbox',
2209
+				    'id'    =>  'checkbox-example2',
2210
+				    'name'    =>  'checkbox-example2',
2211
+				    'placeholder'   => 'checkbox-example',
2212
+				    'title'   => 'Checkbox example',
2213
+				    'value' =>  '1',
2214
+				    'checked'   => false,
2215
+				    'required'  => false,
2216
+				    'help_text' => 'help text',
2217
+				    'label' => 'Checkbox un-checked'
2218
+			    ));
2219
+
2220
+			    // switch example
2221
+			    $output .= aui()->input(array(
2222
+				    'type'  =>  'checkbox',
2223
+				    'id'    =>  'switch-example',
2224
+				    'name'    =>  'switch-example',
2225
+				    'placeholder'   => 'checkbox-example',
2226
+				    'title'   => 'Switch example',
2227
+				    'value' =>  '1',
2228
+				    'checked'   => true,
2229
+				    'switch'    => true,
2230
+				    'required'  => false,
2231
+				    'help_text' => 'help text',
2232
+				    'label' => 'Switch on'
2233
+			    ));
2234
+
2235
+			    // switch example
2236
+			    $output .= aui()->input(array(
2237
+				    'type'  =>  'checkbox',
2238
+				    'id'    =>  'switch-example2',
2239
+				    'name'    =>  'switch-example2',
2240
+				    'placeholder'   => 'checkbox-example',
2241
+				    'title'   => 'Switch example',
2242
+				    'value' =>  '1',
2243
+				    'checked'   => false,
2244
+				    'switch'    => true,
2245
+				    'required'  => false,
2246
+				    'help_text' => 'help text',
2247
+				    'label' => 'Switch off'
2248
+			    ));
2249
+
2250
+			    // close form
2251
+			    $output .= "</form>";
2252
+
2253
+			    return $output;
2254
+		    }
2255
+
2256
+		    /**
2257 2257
 		 * Calendar params.
2258 2258
 		 *
2259 2259
 		 * @since 0.1.44
2260 2260
 		 *
2261 2261
 		 * @return array Calendar params.
2262 2262
 		 */
2263
-		public static function calendar_params() {
2264
-			$params = array(
2265
-				'month_long_1' => __( 'January', 'ayecode-connect' ),
2266
-				'month_long_2' => __( 'February', 'ayecode-connect' ),
2267
-				'month_long_3' => __( 'March', 'ayecode-connect' ),
2268
-				'month_long_4' => __( 'April', 'ayecode-connect' ),
2269
-				'month_long_5' => __( 'May', 'ayecode-connect' ),
2270
-				'month_long_6' => __( 'June', 'ayecode-connect' ),
2271
-				'month_long_7' => __( 'July', 'ayecode-connect' ),
2272
-				'month_long_8' => __( 'August', 'ayecode-connect' ),
2273
-				'month_long_9' => __( 'September', 'ayecode-connect' ),
2274
-				'month_long_10' => __( 'October', 'ayecode-connect' ),
2275
-				'month_long_11' => __( 'November', 'ayecode-connect' ),
2276
-				'month_long_12' => __( 'December', 'ayecode-connect' ),
2277
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2278
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2279
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2280
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2281
-				'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2282
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2283
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2284
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2285
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2286
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2287
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2288
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2289
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2290
-				'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2291
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2292
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2293
-				'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2294
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2295
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2296
-				'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2297
-				'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2298
-				'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2299
-				'day_s2_4' => __( 'We', 'ayecode-connect' ),
2300
-				'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2301
-				'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2302
-				'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2303
-				'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2304
-				'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2305
-				'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2306
-				'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2307
-				'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2308
-				'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2309
-				'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2310
-				'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2311
-				'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2312
-				'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2313
-				'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2314
-				'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2315
-				'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2316
-				'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2317
-				'am_lower' => __( 'am', 'ayecode-connect' ),
2318
-				'pm_lower' => __( 'pm', 'ayecode-connect' ),
2319
-				'am_upper' => __( 'AM', 'ayecode-connect' ),
2320
-				'pm_upper' => __( 'PM', 'ayecode-connect' ),
2321
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2322
-				'time_24hr' => false,
2323
-				'year' => __( 'Year', 'ayecode-connect' ),
2324
-				'hour' => __( 'Hour', 'ayecode-connect' ),
2325
-				'minute' => __( 'Minute', 'ayecode-connect' ),
2326
-				'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2327
-				'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2328
-				'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2329
-				'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2330
-			);
2331
-
2332
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
2333
-		}
2334
-
2335
-		/**
2263
+		    public static function calendar_params() {
2264
+			    $params = array(
2265
+				    'month_long_1' => __( 'January', 'ayecode-connect' ),
2266
+				    'month_long_2' => __( 'February', 'ayecode-connect' ),
2267
+				    'month_long_3' => __( 'March', 'ayecode-connect' ),
2268
+				    'month_long_4' => __( 'April', 'ayecode-connect' ),
2269
+				    'month_long_5' => __( 'May', 'ayecode-connect' ),
2270
+				    'month_long_6' => __( 'June', 'ayecode-connect' ),
2271
+				    'month_long_7' => __( 'July', 'ayecode-connect' ),
2272
+				    'month_long_8' => __( 'August', 'ayecode-connect' ),
2273
+				    'month_long_9' => __( 'September', 'ayecode-connect' ),
2274
+				    'month_long_10' => __( 'October', 'ayecode-connect' ),
2275
+				    'month_long_11' => __( 'November', 'ayecode-connect' ),
2276
+				    'month_long_12' => __( 'December', 'ayecode-connect' ),
2277
+				    'month_s_1' => _x( 'Jan', 'January abbreviation', 'ayecode-connect' ),
2278
+				    'month_s_2' => _x( 'Feb', 'February abbreviation', 'ayecode-connect' ),
2279
+				    'month_s_3' => _x( 'Mar', 'March abbreviation', 'ayecode-connect' ),
2280
+				    'month_s_4' => _x( 'Apr', 'April abbreviation', 'ayecode-connect' ),
2281
+				    'month_s_5' => _x( 'May', 'May abbreviation', 'ayecode-connect' ),
2282
+				    'month_s_6' => _x( 'Jun', 'June abbreviation', 'ayecode-connect' ),
2283
+				    'month_s_7' => _x( 'Jul', 'July abbreviation', 'ayecode-connect' ),
2284
+				    'month_s_8' => _x( 'Aug', 'August abbreviation', 'ayecode-connect' ),
2285
+				    'month_s_9' => _x( 'Sep', 'September abbreviation', 'ayecode-connect' ),
2286
+				    'month_s_10' => _x( 'Oct', 'October abbreviation', 'ayecode-connect' ),
2287
+				    'month_s_11' => _x( 'Nov', 'November abbreviation', 'ayecode-connect' ),
2288
+				    'month_s_12' => _x( 'Dec', 'December abbreviation', 'ayecode-connect' ),
2289
+				    'day_s1_1' => _x( 'S', 'Sunday initial', 'ayecode-connect' ),
2290
+				    'day_s1_2' => _x( 'M', 'Monday initial', 'ayecode-connect' ),
2291
+				    'day_s1_3' => _x( 'T', 'Tuesday initial', 'ayecode-connect' ),
2292
+				    'day_s1_4' => _x( 'W', 'Wednesday initial', 'ayecode-connect' ),
2293
+				    'day_s1_5' => _x( 'T', 'Friday initial', 'ayecode-connect' ),
2294
+				    'day_s1_6' => _x( 'F', 'Thursday initial', 'ayecode-connect' ),
2295
+				    'day_s1_7' => _x( 'S', 'Saturday initial', 'ayecode-connect' ),
2296
+				    'day_s2_1' => __( 'Su', 'ayecode-connect' ),
2297
+				    'day_s2_2' => __( 'Mo', 'ayecode-connect' ),
2298
+				    'day_s2_3' => __( 'Tu', 'ayecode-connect' ),
2299
+				    'day_s2_4' => __( 'We', 'ayecode-connect' ),
2300
+				    'day_s2_5' => __( 'Th', 'ayecode-connect' ),
2301
+				    'day_s2_6' => __( 'Fr', 'ayecode-connect' ),
2302
+				    'day_s2_7' => __( 'Sa', 'ayecode-connect' ),
2303
+				    'day_s3_1' => __( 'Sun', 'ayecode-connect' ),
2304
+				    'day_s3_2' => __( 'Mon', 'ayecode-connect' ),
2305
+				    'day_s3_3' => __( 'Tue', 'ayecode-connect' ),
2306
+				    'day_s3_4' => __( 'Wed', 'ayecode-connect' ),
2307
+				    'day_s3_5' => __( 'Thu', 'ayecode-connect' ),
2308
+				    'day_s3_6' => __( 'Fri', 'ayecode-connect' ),
2309
+				    'day_s3_7' => __( 'Sat', 'ayecode-connect' ),
2310
+				    'day_s5_1' => __( 'Sunday', 'ayecode-connect' ),
2311
+				    'day_s5_2' => __( 'Monday', 'ayecode-connect' ),
2312
+				    'day_s5_3' => __( 'Tuesday', 'ayecode-connect' ),
2313
+				    'day_s5_4' => __( 'Wednesday', 'ayecode-connect' ),
2314
+				    'day_s5_5' => __( 'Thursday', 'ayecode-connect' ),
2315
+				    'day_s5_6' => __( 'Friday', 'ayecode-connect' ),
2316
+				    'day_s5_7' => __( 'Saturday', 'ayecode-connect' ),
2317
+				    'am_lower' => __( 'am', 'ayecode-connect' ),
2318
+				    'pm_lower' => __( 'pm', 'ayecode-connect' ),
2319
+				    'am_upper' => __( 'AM', 'ayecode-connect' ),
2320
+				    'pm_upper' => __( 'PM', 'ayecode-connect' ),
2321
+				    'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
2322
+				    'time_24hr' => false,
2323
+				    'year' => __( 'Year', 'ayecode-connect' ),
2324
+				    'hour' => __( 'Hour', 'ayecode-connect' ),
2325
+				    'minute' => __( 'Minute', 'ayecode-connect' ),
2326
+				    'weekAbbreviation' => __( 'Wk', 'ayecode-connect' ),
2327
+				    'rangeSeparator' => __( ' to ', 'ayecode-connect' ),
2328
+				    'scrollTitle' => __( 'Scroll to increment', 'ayecode-connect' ),
2329
+				    'toggleTitle' => __( 'Click to toggle', 'ayecode-connect' )
2330
+			    );
2331
+
2332
+			    return apply_filters( 'ayecode_ui_calendar_params', $params );
2333
+		    }
2334
+
2335
+		    /**
2336 2336
 		 * Flatpickr calendar localize.
2337 2337
 		 *
2338 2338
 		 * @since 0.1.44
2339 2339
 		 *
2340 2340
 		 * @return string Calendar locale.
2341 2341
 		 */
2342
-		public static function flatpickr_locale() {
2343
-			$params = self::calendar_params();
2344
-
2345
-			if ( is_string( $params ) ) {
2346
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2347
-			} else {
2348
-				foreach ( (array) $params as $key => $value ) {
2349
-					if ( ! is_scalar( $value ) ) {
2350
-						continue;
2351
-					}
2352
-
2353
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2354
-				}
2355
-			}
2356
-
2357
-			$day_s3 = array();
2358
-			$day_s5 = array();
2359
-
2360
-			for ( $i = 1; $i <= 7; $i ++ ) {
2361
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2363
-			}
2364
-
2365
-			$month_s = array();
2366
-			$month_long = array();
2367
-
2368
-			for ( $i = 1; $i <= 12; $i ++ ) {
2369
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2371
-			}
2372
-
2373
-			ob_start();
2374
-		if ( 0 ) { ?><script><?php } ?>
2342
+		    public static function flatpickr_locale() {
2343
+			    $params = self::calendar_params();
2344
+
2345
+			    if ( is_string( $params ) ) {
2346
+				    $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
2347
+			    } else {
2348
+				    foreach ( (array) $params as $key => $value ) {
2349
+					    if ( ! is_scalar( $value ) ) {
2350
+						    continue;
2351
+					    }
2352
+
2353
+					    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2354
+				    }
2355
+			    }
2356
+
2357
+			    $day_s3 = array();
2358
+			    $day_s5 = array();
2359
+
2360
+			    for ( $i = 1; $i <= 7; $i ++ ) {
2361
+				    $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2362
+				    $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2363
+			    }
2364
+
2365
+			    $month_s = array();
2366
+			    $month_long = array();
2367
+
2368
+			    for ( $i = 1; $i <= 12; $i ++ ) {
2369
+				    $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2370
+				    $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2371
+			    }
2372
+
2373
+			    ob_start();
2374
+		    if ( 0 ) { ?><script><?php } ?>
2375 2375
                 {
2376 2376
                     weekdays: {
2377 2377
                         shorthand: ['<?php echo implode( "','", $day_s3 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>'],
@@ -2407,192 +2407,192 @@  discard block
 block discarded – undo
2407 2407
                     hourAriaLabel: '<?php echo esc_attr( $params[ 'hour' ] ); ?>',
2408 2408
                     minuteAriaLabel: '<?php echo esc_attr( $params[ 'minute' ] ); ?>',
2409 2409
                     time_24hr: <?php echo ( $params[ 'time_24hr' ] ? 'true' : 'false' ) ; ?>
2410
-                }
2410
+                    }
2411 2411
 				<?php if ( 0 ) { ?></script><?php } ?>
2412
-			<?php
2413
-			$locale = ob_get_clean();
2412
+    			<?php
2413
+			    $locale = ob_get_clean();
2414 2414
 
2415
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2416
-		}
2415
+			    return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2416
+		    }
2417 2417
 
2418
-		/**
2418
+		    /**
2419 2419
 		 * Select2 JS params.
2420 2420
 		 *
2421 2421
 		 * @since 0.1.44
2422 2422
 		 *
2423 2423
 		 * @return array Select2 JS params.
2424 2424
 		 */
2425
-		public static function select2_params() {
2426
-			$params = array(
2427
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2428
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2429
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2430
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2431
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2432
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2433
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2434
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2435
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2436
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2437
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2438
-			);
2439
-
2440
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2441
-		}
2442
-
2443
-		/**
2425
+		    public static function select2_params() {
2426
+			    $params = array(
2427
+				    'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'ayecode-connect' ),
2428
+				    'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'ayecode-connect' ),
2429
+				    'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'ayecode-connect' ),
2430
+				    'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'ayecode-connect' ),
2431
+				    'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'ayecode-connect' ),
2432
+				    'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'ayecode-connect' ),
2433
+				    'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'ayecode-connect' ),
2434
+				    'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'ayecode-connect' ),
2435
+				    'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'ayecode-connect' ),
2436
+				    'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'ayecode-connect' ),
2437
+				    'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'ayecode-connect' )
2438
+			    );
2439
+
2440
+			    return apply_filters( 'ayecode_ui_select2_params', $params );
2441
+		    }
2442
+
2443
+		    /**
2444 2444
 		 * Select2 JS localize.
2445 2445
 		 *
2446 2446
 		 * @since 0.1.44
2447 2447
 		 *
2448 2448
 		 * @return string Select2 JS locale.
2449 2449
 		 */
2450
-		public static function select2_locale() {
2451
-			$params = self::select2_params();
2450
+		    public static function select2_locale() {
2451
+			    $params = self::select2_params();
2452 2452
 
2453
-			foreach ( (array) $params as $key => $value ) {
2454
-				if ( ! is_scalar( $value ) ) {
2455
-					continue;
2456
-				}
2453
+			    foreach ( (array) $params as $key => $value ) {
2454
+				    if ( ! is_scalar( $value ) ) {
2455
+					    continue;
2456
+				    }
2457 2457
 
2458
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2459
-			}
2458
+				    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2459
+			    }
2460 2460
 
2461
-			$locale = json_encode( $params );
2461
+			    $locale = json_encode( $params );
2462 2462
 
2463
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2464
-		}
2463
+			    return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2464
+		    }
2465 2465
 
2466
-		/**
2466
+		    /**
2467 2467
 		 * Time ago JS localize.
2468 2468
 		 *
2469 2469
 		 * @since 0.1.47
2470 2470
 		 *
2471 2471
 		 * @return string Time ago JS locale.
2472 2472
 		 */
2473
-		public static function timeago_locale() {
2474
-			$params = array(
2475
-				'prefix_ago' => '',
2476
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2477
-				'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2478
-				'suffix_after' => '',
2479
-				'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2480
-				'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2481
-				'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2482
-				'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2483
-				'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2484
-				'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2485
-				'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2486
-				'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2487
-				'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2488
-				'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2489
-				'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2490
-			);
2491
-
2492
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2493
-
2494
-			foreach ( (array) $params as $key => $value ) {
2495
-				if ( ! is_scalar( $value ) ) {
2496
-					continue;
2497
-				}
2498
-
2499
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2500
-			}
2501
-
2502
-			$locale = json_encode( $params );
2503
-
2504
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2505
-		}
2506
-
2507
-		/**
2473
+		    public static function timeago_locale() {
2474
+			    $params = array(
2475
+				    'prefix_ago' => '',
2476
+				    'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'ayecode-connect' ),
2477
+				    'prefix_after' => _x( 'after', 'time ago', 'ayecode-connect' ) . ' ',
2478
+				    'suffix_after' => '',
2479
+				    'seconds' => _x( 'less than a minute', 'time ago', 'ayecode-connect' ),
2480
+				    'minute' => _x( 'about a minute', 'time ago', 'ayecode-connect' ),
2481
+				    'minutes' => _x( '%d minutes', 'time ago', 'ayecode-connect' ),
2482
+				    'hour' => _x( 'about an hour', 'time ago', 'ayecode-connect' ),
2483
+				    'hours' => _x( 'about %d hours', 'time ago', 'ayecode-connect' ),
2484
+				    'day' => _x( 'a day', 'time ago', 'ayecode-connect' ),
2485
+				    'days' => _x( '%d days', 'time ago', 'ayecode-connect' ),
2486
+				    'month' => _x( 'about a month', 'time ago', 'ayecode-connect' ),
2487
+				    'months' => _x( '%d months', 'time ago', 'ayecode-connect' ),
2488
+				    'year' => _x( 'about a year', 'time ago', 'ayecode-connect' ),
2489
+				    'years' => _x( '%d years', 'time ago', 'ayecode-connect' ),
2490
+			    );
2491
+
2492
+			    $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2493
+
2494
+			    foreach ( (array) $params as $key => $value ) {
2495
+				    if ( ! is_scalar( $value ) ) {
2496
+					    continue;
2497
+				    }
2498
+
2499
+				    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2500
+			    }
2501
+
2502
+			    $locale = json_encode( $params );
2503
+
2504
+			    return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2505
+		    }
2506
+
2507
+		    /**
2508 2508
 		 * JavaScript Minifier
2509 2509
 		 *
2510 2510
 		 * @param $input
2511 2511
 		 *
2512 2512
 		 * @return mixed
2513 2513
 		 */
2514
-		public static function minify_js($input) {
2515
-			if(trim($input) === "") return $input;
2516
-			return preg_replace(
2517
-				array(
2518
-					// Remove comment(s)
2519
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2520
-					// Remove white-space(s) outside the string and regex
2521
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2522
-					// Remove the last semicolon
2523
-					'#;+\}#',
2524
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2525
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2526
-					// --ibid. From `foo['bar']` to `foo.bar`
2527
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2528
-				),
2529
-				array(
2530
-					'$1',
2531
-					'$1$2',
2532
-					'}',
2533
-					'$1$3',
2534
-					'$1.$3'
2535
-				),
2536
-				$input);
2537
-		}
2538
-
2539
-		/**
2514
+		    public static function minify_js($input) {
2515
+			    if(trim($input) === "") return $input;
2516
+			    return preg_replace(
2517
+				    array(
2518
+					    // Remove comment(s)
2519
+					    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2520
+					    // Remove white-space(s) outside the string and regex
2521
+					    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2522
+					    // Remove the last semicolon
2523
+					    '#;+\}#',
2524
+					    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2525
+					    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2526
+					    // --ibid. From `foo['bar']` to `foo.bar`
2527
+					    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2528
+				    ),
2529
+				    array(
2530
+					    '$1',
2531
+					    '$1$2',
2532
+					    '}',
2533
+					    '$1$3',
2534
+					    '$1.$3'
2535
+				    ),
2536
+				    $input);
2537
+		    }
2538
+
2539
+		    /**
2540 2540
 		 * Minify CSS
2541 2541
 		 *
2542 2542
 		 * @param $input
2543 2543
 		 *
2544 2544
 		 * @return mixed
2545 2545
 		 */
2546
-		public static function minify_css($input) {
2547
-			if(trim($input) === "") return $input;
2548
-			return preg_replace(
2549
-				array(
2550
-					// Remove comment(s)
2551
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2552
-					// Remove unused white-space(s)
2553
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2554
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2555
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2556
-					// Replace `:0 0 0 0` with `:0`
2557
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2558
-					// Replace `background-position:0` with `background-position:0 0`
2559
-					'#(background-position):0(?=[;\}])#si',
2560
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2561
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2562
-					// Minify string value
2563
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2564
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2565
-					// Minify HEX color code
2566
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2567
-					// Replace `(border|outline):none` with `(border|outline):0`
2568
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2569
-					// Remove empty selector(s)
2570
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2571
-				),
2572
-				array(
2573
-					'$1',
2574
-					'$1$2$3$4$5$6$7',
2575
-					'$1',
2576
-					':0',
2577
-					'$1:0 0',
2578
-					'.$1',
2579
-					'$1$3',
2580
-					'$1$2$4$5',
2581
-					'$1$2$3',
2582
-					'$1:0',
2583
-					'$1$2'
2584
-				),
2585
-				$input);
2586
-		}
2587
-
2588
-		/**
2546
+		    public static function minify_css($input) {
2547
+			    if(trim($input) === "") return $input;
2548
+			    return preg_replace(
2549
+				    array(
2550
+					    // Remove comment(s)
2551
+					    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2552
+					    // Remove unused white-space(s)
2553
+					    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2554
+					    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2555
+					    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2556
+					    // Replace `:0 0 0 0` with `:0`
2557
+					    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2558
+					    // Replace `background-position:0` with `background-position:0 0`
2559
+					    '#(background-position):0(?=[;\}])#si',
2560
+					    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2561
+					    '#(?<=[\s:,\-])0+\.(\d+)#s',
2562
+					    // Minify string value
2563
+					    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2564
+					    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2565
+					    // Minify HEX color code
2566
+					    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2567
+					    // Replace `(border|outline):none` with `(border|outline):0`
2568
+					    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2569
+					    // Remove empty selector(s)
2570
+					    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2571
+				    ),
2572
+				    array(
2573
+					    '$1',
2574
+					    '$1$2$3$4$5$6$7',
2575
+					    '$1',
2576
+					    ':0',
2577
+					    '$1:0 0',
2578
+					    '.$1',
2579
+					    '$1$3',
2580
+					    '$1$2$4$5',
2581
+					    '$1$2$3',
2582
+					    '$1:0',
2583
+					    '$1$2'
2584
+				    ),
2585
+				    $input);
2586
+		    }
2587
+
2588
+		    /**
2589 2589
 		 * Get the conditional fields JavaScript.
2590 2590
 		 *
2591 2591
 		 * @return mixed
2592 2592
 		 */
2593
-		public function conditional_fields_js() {
2594
-			ob_start();
2595
-			?>
2593
+		    public function conditional_fields_js() {
2594
+			    ob_start();
2595
+			    ?>
2596 2596
             <script>
2597 2597
                 /**
2598 2598
                  * Conditional Fields
@@ -3122,16 +3122,16 @@  discard block
 block discarded – undo
3122 3122
                     }
3123 3123
                 }
3124 3124
 				<?php do_action( 'aui_conditional_fields_js', $this ); ?>
3125
-            </script>
3125
+                </script>
3126 3126
 			<?php
3127
-			$output = ob_get_clean();
3127
+			    $output = ob_get_clean();
3128 3128
 
3129
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3130
-		}
3131
-	}
3129
+			    return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
3130
+		    }
3131
+	    }
3132 3132
 
3133
-	/**
3133
+	    /**
3134 3134
 	 * Run the class if found.
3135 3135
 	 */
3136
-	AyeCode_UI_Settings::instance();
3136
+	    AyeCode_UI_Settings::instance();
3137 3137
 }
3138 3138
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@  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 64
     } elseif ( in_array( strtolower( $discount->post_status ), array( 'pending', 'draft' ) ) && wpinv_current_user_can( 'activate_discount', array( 'discount' => (int) $discount->ID ) ) ) {
@@ -73,8 +73,8 @@  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
     }
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
             $types = wpinv_get_discount_types();
122 122
 
123 123
             foreach ( $types as $name => $type ) {
124
-			echo '<option value="' . esc_attr( $name ) . '"';
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>
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
         // Filter vat rule type
155 155
         if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
156 156
             $meta_query[] = array(
157
-				'key'     => '_wpi_discount_type',
158
-				'value'   => sanitize_key( urldecode( $_GET['discount_type'] ) ),
159
-				'compare' => '=',
160
-			);
161
-			}
157
+                'key'     => '_wpi_discount_type',
158
+                'value'   => sanitize_key( urldecode( $_GET['discount_type'] ) ),
159
+                'compare' => '=',
160
+            );
161
+            }
162 162
 
163 163
         if ( ! empty( $meta_query ) ) {
164 164
             $vars['meta_query'] = $meta_query;
165
-			}
165
+            }
166 166
     }
167 167
 
168 168
     return $vars;
Please login to merge, or discard this 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/gateways/class-getpaid-authorize-net-gateway.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'authorizenet';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array(
28 28
         'subscription',
29 29
         'sandbox',
@@ -36,44 +36,44 @@  discard block
 block discarded – undo
36 36
     );
37 37
 
38 38
     /**
39
-	 * Payment method order.
40
-	 *
41
-	 * @var int
42
-	 */
39
+     * Payment method order.
40
+     *
41
+     * @var int
42
+     */
43 43
     public $order = 4;
44 44
 
45 45
     /**
46
-	 * Endpoint for requests from Authorize.net.
47
-	 *
48
-	 * @var string
49
-	 */
50
-	protected $notify_url;
51
-
52
-	/**
53
-	 * Endpoint for requests to Authorize.net.
54
-	 *
55
-	 * @var string
56
-	 */
46
+     * Endpoint for requests from Authorize.net.
47
+     *
48
+     * @var string
49
+     */
50
+    protected $notify_url;
51
+
52
+    /**
53
+     * Endpoint for requests to Authorize.net.
54
+     *
55
+     * @var string
56
+     */
57 57
     protected $endpoint;
58 58
 
59 59
     /**
60
-	 * Currencies this gateway is allowed for.
61
-	 *
62
-	 * @var array
63
-	 */
64
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
60
+     * Currencies this gateway is allowed for.
61
+     *
62
+     * @var array
63
+     */
64
+    public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
65 65
 
66 66
     /**
67
-	 * URL to view a transaction.
68
-	 *
69
-	 * @var string
70
-	 */
67
+     * URL to view a transaction.
68
+     *
69
+     * @var string
70
+     */
71 71
     public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s';
72 72
 
73 73
     /**
74
-	 * Class constructor.
75
-	 */
76
-	public function __construct() {
74
+     * Class constructor.
75
+     */
76
+    public function __construct() {
77 77
 
78 78
         $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
79 79
         $this->method_title         = __( 'Authorize.Net', 'invoicing' );
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-	 * Displays the payment method select field.
89
-	 *
90
-	 * @param int $invoice_id 0 or invoice id.
91
-	 * @param GetPaid_Payment_Form $form Current payment form.
92
-	 */
88
+     * Displays the payment method select field.
89
+     *
90
+     * @param int $invoice_id 0 or invoice id.
91
+     * @param GetPaid_Payment_Form $form Current payment form.
92
+     */
93 93
     public function payment_fields( $invoice_id, $form ) {
94 94
 
95 95
         // Let the user select a payment method.
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
     }
101 101
 
102 102
     /**
103
-	 * Creates a customer profile.
104
-	 *
105
-	 *
106
-	 * @param WPInv_Invoice $invoice Invoice.
103
+     * Creates a customer profile.
104
+     *
105
+     *
106
+     * @param WPInv_Invoice $invoice Invoice.
107 107
      * @param array $submission_data Posted checkout fields.
108 108
      * @param bool $save Whether or not to save the payment as a token.
109 109
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
110
-	 * @return string|WP_Error Payment profile id.
111
-	 */
112
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
110
+     * @return string|WP_Error Payment profile id.
111
+     */
112
+    public function create_customer_profile( $invoice, $submission_data, $save = true ) {
113 113
 
114 114
         // Remove non-digits from the number
115 115
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
     /**
194
-	 * Retrieves a customer profile.
195
-	 *
196
-	 *
197
-	 * @param string $profile_id profile id.
198
-	 * @return string|WP_Error Profile id.
194
+     * Retrieves a customer profile.
195
+     *
196
+     *
197
+     * @param string $profile_id profile id.
198
+     * @return string|WP_Error Profile id.
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
200
-	 */
201
-	public function get_customer_profile( $profile_id ) {
200
+     */
201
+    public function get_customer_profile( $profile_id ) {
202 202
 
203 203
         // Generate args.
204 204
         $args = array(
@@ -213,17 +213,17 @@  discard block
 block discarded – undo
213 213
     }
214 214
 
215 215
     /**
216
-	 * Creates a customer profile.
217
-	 *
218
-	 *
216
+     * Creates a customer profile.
217
+     *
218
+     *
219 219
      * @param string $profile_id profile id.
220
-	 * @param WPInv_Invoice $invoice Invoice.
220
+     * @param WPInv_Invoice $invoice Invoice.
221 221
      * @param array $submission_data Posted checkout fields.
222 222
      * @param bool $save Whether or not to save the payment as a token.
223 223
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
224
-	 * @return string|WP_Error Profile id.
225
-	 */
226
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
224
+     * @return string|WP_Error Profile id.
225
+     */
226
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
227 227
 
228 228
         // Remove non-digits from the number
229 229
         $submission_data['authorizenet']['cc_number'] = preg_replace( '/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -311,13 +311,13 @@  discard block
 block discarded – undo
311 311
     }
312 312
 
313 313
     /**
314
-	 * Retrieves payment details from cache.
315
-	 *
316
-	 *
314
+     * Retrieves payment details from cache.
315
+     *
316
+     *
317 317
      * @param array $payment_details.
318
-	 * @return array|false Profile id.
319
-	 */
320
-	public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
318
+     * @return array|false Profile id.
319
+     */
320
+    public function retrieve_payment_profile_from_cache( $payment_details, $customer_profile, $invoice ) {
321 321
 
322 322
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
323 323
         $payment_details    = hash_hmac( 'sha256', json_encode( $payment_details ), SECURE_AUTH_KEY );
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
     }
343 343
 
344 344
     /**
345
-	 * Securely adds payment details to cache.
346
-	 *
347
-	 *
345
+     * Securely adds payment details to cache.
346
+     *
347
+     *
348 348
      * @param array $payment_details.
349 349
      * @param string $payment_profile_id.
350
-	 */
351
-	public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
350
+     */
351
+    public function add_payment_profile_to_cache( $payment_details, $payment_profile_id ) {
352 352
 
353 353
         $cached_information = get_option( 'getpaid_authorize_net_cached_profiles', array() );
354 354
         $cached_information = is_array( $cached_information ) ? $cached_information : array();
@@ -360,15 +360,15 @@  discard block
 block discarded – undo
360 360
     }
361 361
 
362 362
     /**
363
-	 * Retrieves a customer payment profile.
364
-	 *
365
-	 *
366
-	 * @param string $customer_profile_id customer profile id.
363
+     * Retrieves a customer payment profile.
364
+     *
365
+     *
366
+     * @param string $customer_profile_id customer profile id.
367 367
      * @param string $payment_profile_id payment profile id.
368
-	 * @return string|WP_Error Profile id.
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
-	 */
371
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
370
+     */
371
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
372 372
 
373 373
         // Generate args.
374 374
         $args = array(
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
     }
385 385
 
386 386
     /**
387
-	 * Charges a customer payment profile.
388
-	 *
387
+     * Charges a customer payment profile.
388
+     *
389 389
      * @param string $customer_profile_id customer profile id.
390 390
      * @param string $payment_profile_id payment profile id.
391
-	 * @param WPInv_Invoice $invoice Invoice.
391
+     * @param WPInv_Invoice $invoice Invoice.
392 392
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
393
-	 * @return WP_Error|object
394
-	 */
395
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
393
+     * @return WP_Error|object
394
+     */
395
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
396 396
 
397 397
         // Generate args.
398 398
         $args = array(
@@ -438,43 +438,43 @@  discard block
 block discarded – undo
438 438
     }
439 439
 
440 440
     /**
441
-	 * Processes a customer charge.
442
-	 *
441
+     * Processes a customer charge.
442
+     *
443 443
      * @param stdClass $result Api response.
444
-	 * @param WPInv_Invoice $invoice Invoice.
445
-	 */
446
-	public function process_charge_response( $result, $invoice ) {
444
+     * @param WPInv_Invoice $invoice Invoice.
445
+     */
446
+    public function process_charge_response( $result, $invoice ) {
447 447
 
448 448
         wpinv_clear_errors();
449
-		$response_code = (int) $result->transactionResponse->responseCode;
449
+        $response_code = (int) $result->transactionResponse->responseCode;
450 450
 
451 451
         $invoice->add_note( 'Transaction Response: ' . print_r( $result->transactionResponse, true ), false, false, true );
452 452
 
453
-		// Succeeded.
454
-		if ( 1 == $response_code || 4 == $response_code ) {
453
+        // Succeeded.
454
+        if ( 1 == $response_code || 4 == $response_code ) {
455 455
 
456
-			// Maybe set a transaction id.
457
-			if ( ! empty( $result->transactionResponse->transId ) ) {
458
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
459
-			}
456
+            // Maybe set a transaction id.
457
+            if ( ! empty( $result->transactionResponse->transId ) ) {
458
+                $invoice->set_transaction_id( $result->transactionResponse->transId );
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 ) {
464
-				return $invoice->mark_paid();
465
-			}
463
+            if ( 1 == $response_code ) {
464
+                return $invoice->mark_paid();
465
+            }
466 466
 
467
-			$invoice->set_status( 'wpi-onhold' );
468
-        	$invoice->add_note(
467
+            $invoice->set_status( 'wpi-onhold' );
468
+            $invoice->add_note(
469 469
                 sprintf(
470 470
                     __( 'Held for review: %s', 'invoicing' ),
471 471
                     $result->transactionResponse->messages->message[0]->description
472 472
                 )
473
-			);
473
+            );
474 474
 
475
-			return $invoice->save();
475
+            return $invoice->save();
476 476
 
477
-		}
477
+        }
478 478
 
479 479
         wpinv_set_error( 'card_declined' );
480 480
 
@@ -486,13 +486,13 @@  discard block
 block discarded – undo
486 486
     }
487 487
 
488 488
     /**
489
-	 * Returns payment information.
490
-	 *
491
-	 *
492
-	 * @param array $card Card details.
493
-	 * @return array
494
-	 */
495
-	public function get_payment_information( $card ) {
489
+     * Returns payment information.
490
+     *
491
+     *
492
+     * @param array $card Card details.
493
+     * @return array
494
+     */
495
+    public function get_payment_information( $card ) {
496 496
         return array(
497 497
 
498 498
             'creditCard' => array(
@@ -505,25 +505,25 @@  discard block
 block discarded – undo
505 505
     }
506 506
 
507 507
     /**
508
-	 * Returns the customer profile meta name.
509
-	 *
510
-	 *
511
-	 * @param WPInv_Invoice $invoice Invoice.
512
-	 * @return string
513
-	 */
514
-	public function get_customer_profile_meta_name( $invoice ) {
508
+     * Returns the customer profile meta name.
509
+     *
510
+     *
511
+     * @param WPInv_Invoice $invoice Invoice.
512
+     * @return string
513
+     */
514
+    public function get_customer_profile_meta_name( $invoice ) {
515 515
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
516 516
     }
517 517
 
518 518
     /**
519
-	 * Validates the submitted data.
520
-	 *
521
-	 *
522
-	 * @param array $submission_data Posted checkout fields.
519
+     * Validates the submitted data.
520
+     *
521
+     *
522
+     * @param array $submission_data Posted checkout fields.
523 523
      * @param WPInv_Invoice $invoice
524
-	 * @return WP_Error|string The payment profile id
525
-	 */
526
-	public function validate_submission_data( $submission_data, $invoice ) {
524
+     * @return WP_Error|string The payment profile id
525
+     */
526
+    public function validate_submission_data( $submission_data, $invoice ) {
527 527
 
528 528
         // Validate authentication details.
529 529
         $auth = $this->get_auth_params();
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
     }
556 556
 
557 557
     /**
558
-	 * Returns invoice line items.
559
-	 *
560
-	 *
561
-	 * @param WPInv_Invoice $invoice Invoice.
562
-	 * @return array
563
-	 */
564
-	public function get_line_items( $invoice ) {
558
+     * Returns invoice line items.
559
+     *
560
+     *
561
+     * @param WPInv_Invoice $invoice Invoice.
562
+     * @return array
563
+     */
564
+    public function get_line_items( $invoice ) {
565 565
         $items = array();
566 566
 
567 567
         foreach ( $invoice->get_items() as $item ) {
@@ -598,15 +598,15 @@  discard block
 block discarded – undo
598 598
     }
599 599
 
600 600
     /**
601
-	 * Process Payment.
602
-	 *
603
-	 *
604
-	 * @param WPInv_Invoice $invoice Invoice.
605
-	 * @param array $submission_data Posted checkout fields.
606
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
607
-	 * @return array
608
-	 */
609
-	public function process_payment( $invoice, $submission_data, $submission ) {
601
+     * Process Payment.
602
+     *
603
+     *
604
+     * @param WPInv_Invoice $invoice Invoice.
605
+     * @param array $submission_data Posted checkout fields.
606
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
607
+     * @return array
608
+     */
609
+    public function process_payment( $invoice, $submission_data, $submission ) {
610 610
 
611 611
         // Validate the submitted data.
612 612
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -639,45 +639,45 @@  discard block
 block discarded – undo
639 639
 
640 640
         exit;
641 641
 
642
-	}
642
+    }
643 643
 
644
-	/**
645
-	 * Processes the initial payment.
646
-	 *
644
+    /**
645
+     * Processes the initial payment.
646
+     *
647 647
      * @param WPInv_Invoice $invoice Invoice.
648
-	 */
649
-	protected function process_initial_payment( $invoice ) {
648
+     */
649
+    protected function process_initial_payment( $invoice ) {
650 650
 
651
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
651
+        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
652 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 );
653
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
654 654
 
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 );
659
-		}
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 );
659
+        }
660 660
 
661
-		// Process the response.
662
-		$this->process_charge_response( $result, $invoice );
661
+        // Process the response.
662
+        $this->process_charge_response( $result, $invoice );
663 663
 
664
-		if ( wpinv_get_errors() ) {
665
-			wpinv_send_back_to_checkout( $invoice );
666
-		}
664
+        if ( wpinv_get_errors() ) {
665
+            wpinv_send_back_to_checkout( $invoice );
666
+        }
667 667
 
668
-	}
668
+    }
669 669
 
670 670
     /**
671
-	 * Processes recurring payments.
672
-	 *
671
+     * Processes recurring payments.
672
+     *
673 673
      * @param WPInv_Invoice $invoice Invoice.
674 674
      * @param WPInv_Subscription[]|WPInv_Subscription $subscriptions Subscriptions.
675
-	 */
676
-	public function process_subscription( $invoice, $subscriptions ) {
675
+     */
676
+    public function process_subscription( $invoice, $subscriptions ) {
677 677
 
678 678
         // Check if there is an initial amount to charge.
679 679
         if ( (float) $invoice->get_total() > 0 ) {
680
-			$this->process_initial_payment( $invoice );
680
+            $this->process_initial_payment( $invoice );
681 681
         }
682 682
 
683 683
         // Activate the subscriptions.
@@ -695,36 +695,36 @@  discard block
 block discarded – undo
695 695
             }
696 696
         }
697 697
 
698
-		// Redirect to the success page.
698
+        // Redirect to the success page.
699 699
         wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
700 700
 
701 701
     }
702 702
 
703
-	/**
704
-	 * (Maybe) renews an authorize.net subscription profile.
705
-	 *
706
-	 *
703
+    /**
704
+     * (Maybe) renews an authorize.net subscription profile.
705
+     *
706
+     *
707 707
      * @param WPInv_Subscription $subscription
708
-	 */
709
-	public function maybe_renew_subscription( $subscription ) {
708
+     */
709
+    public function maybe_renew_subscription( $subscription ) {
710 710
 
711 711
         // Ensure its our subscription && it's active.
712 712
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
713 713
             $this->renew_subscription( $subscription );
714 714
         }
715 715
 
716
-	}
716
+    }
717 717
 
718 718
     /**
719
-	 * Renews a subscription.
720
-	 *
719
+     * Renews a subscription.
720
+     *
721 721
      * @param WPInv_Subscription $subscription
722
-	 */
723
-	public function renew_subscription( $subscription ) {
722
+     */
723
+    public function renew_subscription( $subscription ) {
724 724
 
725
-		// Generate the renewal invoice.
726
-		$new_invoice = $subscription->create_payment();
727
-		$old_invoice = $subscription->get_parent_payment();
725
+        // Generate the renewal invoice.
726
+        $new_invoice = $subscription->create_payment();
727
+        $old_invoice = $subscription->get_parent_payment();
728 728
 
729 729
         if ( empty( $new_invoice ) ) {
730 730
             $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
@@ -733,37 +733,37 @@  discard block
 block discarded – undo
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 );
739
-
740
-		// Do we have an error?
741
-		if ( is_wp_error( $result ) ) {
742
-
743
-			$old_invoice->add_note(
744
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
745
-				true,
746
-				false,
747
-				true
748
-			);
749
-			$subscription->failing();
750
-			return;
751
-
752
-		}
753
-
754
-		// Process the response.
755
-		$this->process_charge_response( $result, $new_invoice );
756
-
757
-		if ( wpinv_get_errors() ) {
758
-
759
-			$old_invoice->add_note(
760
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
761
-				true,
762
-				false,
763
-				true
764
-			);
765
-			$subscription->failing();
766
-			return;
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
+
740
+        // Do we have an error?
741
+        if ( is_wp_error( $result ) ) {
742
+
743
+            $old_invoice->add_note(
744
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
745
+                true,
746
+                false,
747
+                true
748
+            );
749
+            $subscription->failing();
750
+            return;
751
+
752
+        }
753
+
754
+        // Process the response.
755
+        $this->process_charge_response( $result, $new_invoice );
756
+
757
+        if ( wpinv_get_errors() ) {
758
+
759
+            $old_invoice->add_note(
760
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
761
+                true,
762
+                false,
763
+                true
764
+            );
765
+            $subscription->failing();
766
+            return;
767 767
 
768 768
         }
769 769
 
@@ -776,13 +776,13 @@  discard block
 block discarded – undo
776 776
     }
777 777
 
778 778
     /**
779
-	 * Processes invoice addons.
780
-	 *
781
-	 * @param WPInv_Invoice $invoice
782
-	 * @param GetPaid_Form_Item[] $items
783
-	 * @return WPInv_Invoice
784
-	 */
785
-	public function process_addons( $invoice, $items ) {
779
+     * Processes invoice addons.
780
+     *
781
+     * @param WPInv_Invoice $invoice
782
+     * @param GetPaid_Form_Item[] $items
783
+     * @return WPInv_Invoice
784
+     */
785
+    public function process_addons( $invoice, $items ) {
786 786
 
787 787
         global $getpaid_authorize_addons;
788 788
 
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
         $invoice->recalculate_total();
802 802
 
803 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 );
804
+        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
805 805
 
806 806
         add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
807 807
         $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
@@ -816,11 +816,11 @@  discard block
 block discarded – undo
816 816
     }
817 817
 
818 818
     /**
819
-	 * Processes invoice addons.
820
-	 *
819
+     * Processes invoice addons.
820
+     *
821 821
      * @param array $args
822
-	 * @return array
823
-	 */
822
+     * @return array
823
+     */
824 824
     public function filter_addons_request( $args ) {
825 825
 
826 826
         global $getpaid_authorize_addons;
@@ -854,11 +854,11 @@  discard block
 block discarded – undo
854 854
     }
855 855
 
856 856
     /**
857
-	 * Filters the gateway settings.
858
-	 *
859
-	 * @param array $admin_settings
860
-	 */
861
-	public function admin_settings( $admin_settings ) {
857
+     * Filters the gateway settings.
858
+     *
859
+     * @param array $admin_settings
860
+     */
861
+    public function admin_settings( $admin_settings ) {
862 862
 
863 863
         $currencies = sprintf(
864 864
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
             'readonly' => true,
899 899
         );
900 900
 
901
-		return $admin_settings;
902
-	}
901
+        return $admin_settings;
902
+    }
903 903
 
904 904
 }
Please login to merge, or discard this 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/knowledgebase/Knowledgearticle/?code=000001271"><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/knowledgebase/Knowledgearticle/?code=000001271"><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/knowledgebase/Knowledgearticle/?code=000001271"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
887
+            'name' => __('Signature Key', 'invoicing'),
888
+            'desc' => '<a href="https://support.authorize.net/knowledgebase/Knowledgearticle/?code=000001271"><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/knowledgebase/Knowledgearticle/?code=000001542"><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/knowledgebase/Knowledgearticle/?code=000001542"><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 2 patches
Indentation   +1051 added lines, -1051 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => '',
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	/**
66
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
-	 *
68
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
-	 * @param  bool $deprecated
70
-	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
72
-
73
-		parent::__construct( $subscription );
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 );
83
-		} else {
84
-			$this->set_object_read( true );
85
-		}
86
-
87
-		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
-
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
92
-		}
93
-
94
-	}
95
-
96
-	/**
97
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
-	 *
99
-	 *
100
-	 * @static
101
-	 * @param string $value
102
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
103
-	 * @since 1.0.19
104
-	 * @return int
105
-	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => '',
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    /**
66
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
+     *
68
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
+     * @param  bool $deprecated
70
+     */
71
+    function __construct( $subscription = 0, $deprecated = false ) {
72
+
73
+        parent::__construct( $subscription );
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 );
83
+        } else {
84
+            $this->set_object_read( true );
85
+        }
86
+
87
+        // Load the datastore.
88
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
+
90
+        if ( $this->get_id() > 0 ) {
91
+            $this->data_store->read( $this );
92
+        }
93
+
94
+    }
95
+
96
+    /**
97
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
+     *
99
+     *
100
+     * @static
101
+     * @param string $value
102
+     * @param string $field Either invoice_id, transaction_id or profile_id.
103
+     * @since 1.0.19
104
+     * @return int
105
+     */
106
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
107 107
         global $wpdb;
108 108
 
109
-		// Trim the value.
110
-		$value = trim( $value );
109
+        // Trim the value.
110
+        $value = trim( $value );
111 111
 
112
-		if ( empty( $value ) ) {
113
-			return 0;
114
-		}
112
+        if ( empty( $value ) ) {
113
+            return 0;
114
+        }
115 115
 
116
-		if ( 'invoice_id' == $field ) {
117
-			$field = 'parent_payment_id';
118
-		}
116
+        if ( 'invoice_id' == $field ) {
117
+            $field = 'parent_payment_id';
118
+        }
119 119
 
120 120
         // Valid fields.
121 121
         $fields = array(
122
-			'parent_payment_id',
123
-			'transaction_id',
124
-			'profile_id',
125
-		);
126
-
127
-		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
-			return 0;
130
-		}
131
-
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 ) ) {
135
-			return $subscription_id;
136
-		}
122
+            'parent_payment_id',
123
+            'transaction_id',
124
+            'profile_id',
125
+        );
126
+
127
+        // Ensure a field has been passed.
128
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
+            return 0;
130
+        }
131
+
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 ) ) {
135
+            return $subscription_id;
136
+        }
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -141,42 +141,42 @@  discard block
 block discarded – undo
141 141
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
145
-			return 0;
146
-		}
144
+        if ( empty( $subscription_id ) ) {
145
+            return 0;
146
+        }
147 147
 
148
-		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
148
+        // Update the cache with our data.
149
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150 150
 
151
-		return $subscription_id;
152
-	}
151
+        return $subscription_id;
152
+    }
153 153
 
154
-	/**
154
+    /**
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		$caches = array(
159
-			'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
-			'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
-			'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
-			'getpaid_subscriptions'                                       => $this->get_id(),
163
-		);
164
-
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
168
-			}
169
-		}
170
-	}
171
-
172
-	/**
158
+        $caches = array(
159
+            'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
+            'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
+            'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
+            'getpaid_subscriptions'                                       => $this->get_id(),
163
+        );
164
+
165
+        foreach ( $caches as $cache => $value ) {
166
+            if ( '' !== $value && false !== $value ) {
167
+                wp_cache_delete( $value, $cache );
168
+            }
169
+        }
170
+    }
171
+
172
+    /**
173 173
      * Checks if a subscription key is set.
174 174
      */
175 175
     public function _isset( $key ) {
176 176
         return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
177
-	}
177
+    }
178 178
 
179
-	/*
179
+    /*
180 180
 	|--------------------------------------------------------------------------
181 181
 	| CRUD methods
182 182
 	|--------------------------------------------------------------------------
@@ -185,544 +185,544 @@  discard block
 block discarded – undo
185 185
 	|
186 186
     */
187 187
 
188
-	/*
188
+    /*
189 189
 	|--------------------------------------------------------------------------
190 190
 	| Getters
191 191
 	|--------------------------------------------------------------------------
192 192
 	*/
193 193
 
194
-	/**
195
-	 * Get customer id.
196
-	 *
197
-	 * @since 1.0.19
198
-	 * @param  string $context View or edit context.
199
-	 * @return int
200
-	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
203
-	}
204
-
205
-	/**
206
-	 * Get customer information.
207
-	 *
208
-	 * @since 1.0.19
209
-	 * @param  string $context View or edit context.
210
-	 * @return WP_User|false WP_User object on success, false on failure.
211
-	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
214
-	}
215
-
216
-	/**
217
-	 * Get parent invoice id.
218
-	 *
219
-	 * @since 1.0.19
220
-	 * @param  string $context View or edit context.
221
-	 * @return int
222
-	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
225
-	}
226
-
227
-	/**
228
-	 * Alias for self::get_parent_invoice_id().
229
-	 *
230
-	 * @since 1.0.19
231
-	 * @param  string $context View or edit context.
232
-	 * @return int
233
-	 */
194
+    /**
195
+     * Get customer id.
196
+     *
197
+     * @since 1.0.19
198
+     * @param  string $context View or edit context.
199
+     * @return int
200
+     */
201
+    public function get_customer_id( $context = 'view' ) {
202
+        return (int) $this->get_prop( 'customer_id', $context );
203
+    }
204
+
205
+    /**
206
+     * Get customer information.
207
+     *
208
+     * @since 1.0.19
209
+     * @param  string $context View or edit context.
210
+     * @return WP_User|false WP_User object on success, false on failure.
211
+     */
212
+    public function get_customer( $context = 'view' ) {
213
+        return get_userdata( $this->get_customer_id( $context ) );
214
+    }
215
+
216
+    /**
217
+     * Get parent invoice id.
218
+     *
219
+     * @since 1.0.19
220
+     * @param  string $context View or edit context.
221
+     * @return int
222
+     */
223
+    public function get_parent_invoice_id( $context = 'view' ) {
224
+        return (int) $this->get_prop( 'parent_payment_id', $context );
225
+    }
226
+
227
+    /**
228
+     * Alias for self::get_parent_invoice_id().
229
+     *
230
+     * @since 1.0.19
231
+     * @param  string $context View or edit context.
232
+     * @return int
233
+     */
234 234
     public function get_parent_payment_id( $context = 'view' ) {
235 235
         return $this->get_parent_invoice_id( $context );
236
-	}
236
+    }
237
+
238
+    /**
239
+     * Alias for self::get_parent_invoice_id().
240
+     *
241
+     * @since  1.0.0
242
+     * @return int
243
+     */
244
+    public function get_original_payment_id( $context = 'view' ) {
245
+        return $this->get_parent_invoice_id( $context );
246
+    }
247
+
248
+    /**
249
+     * Get parent invoice.
250
+     *
251
+     * @since 1.0.19
252
+     * @param  string $context View or edit context.
253
+     * @return WPInv_Invoice
254
+     */
255
+    public function get_parent_invoice( $context = 'view' ) {
256
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
+    }
258
+
259
+    /**
260
+     * Alias for self::get_parent_invoice().
261
+     *
262
+     * @since 1.0.19
263
+     * @param  string $context View or edit context.
264
+     * @return WPInv_Invoice
265
+     */
266
+    public function get_parent_payment( $context = 'view' ) {
267
+        return $this->get_parent_invoice( $context );
268
+    }
269
+
270
+    /**
271
+     * Get subscription's product id.
272
+     *
273
+     * @since 1.0.19
274
+     * @param  string $context View or edit context.
275
+     * @return int
276
+     */
277
+    public function get_product_id( $context = 'view' ) {
278
+        return (int) $this->get_prop( 'product_id', $context );
279
+    }
280
+
281
+    /**
282
+     * Get the subscription product.
283
+     *
284
+     * @since 1.0.19
285
+     * @param  string $context View or edit context.
286
+     * @return WPInv_Item
287
+     */
288
+    public function get_product( $context = 'view' ) {
289
+        return new WPInv_Item( $this->get_product_id( $context ) );
290
+    }
291
+
292
+    /**
293
+     * Get parent invoice's gateway.
294
+     *
295
+     * Here for backwards compatibility.
296
+     *
297
+     * @since 1.0.19
298
+     * @param  string $context View or edit context.
299
+     * @return string
300
+     */
301
+    public function get_gateway( $context = 'view' ) {
302
+        return $this->get_parent_invoice( $context )->get_gateway();
303
+    }
304
+
305
+    /**
306
+     * Get the period of a renewal.
307
+     *
308
+     * @since 1.0.19
309
+     * @param  string $context View or edit context.
310
+     * @return string
311
+     */
312
+    public function get_period( $context = 'view' ) {
313
+        return $this->get_prop( 'period', $context );
314
+    }
315
+
316
+    /**
317
+     * Get number of periods each renewal is valid for.
318
+     *
319
+     * @since 1.0.19
320
+     * @param  string $context View or edit context.
321
+     * @return int
322
+     */
323
+    public function get_frequency( $context = 'view' ) {
324
+        return (int) $this->get_prop( 'frequency', $context );
325
+    }
326
+
327
+    /**
328
+     * Get the initial amount for the subscription.
329
+     *
330
+     * @since 1.0.19
331
+     * @param  string $context View or edit context.
332
+     * @return float
333
+     */
334
+    public function get_initial_amount( $context = 'view' ) {
335
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
+    }
337
+
338
+    /**
339
+     * Get the recurring amount for the subscription.
340
+     *
341
+     * @since 1.0.19
342
+     * @param  string $context View or edit context.
343
+     * @return float
344
+     */
345
+    public function get_recurring_amount( $context = 'view' ) {
346
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
+    }
348
+
349
+    /**
350
+     * Get number of times that this subscription can be renewed.
351
+     *
352
+     * @since 1.0.19
353
+     * @param  string $context View or edit context.
354
+     * @return int
355
+     */
356
+    public function get_bill_times( $context = 'view' ) {
357
+        return (int) $this->get_prop( 'bill_times', $context );
358
+    }
359
+
360
+    /**
361
+     * Get transaction id of this subscription's parent invoice.
362
+     *
363
+     * @since 1.0.19
364
+     * @param  string $context View or edit context.
365
+     * @return string
366
+     */
367
+    public function get_transaction_id( $context = 'view' ) {
368
+        return $this->get_prop( 'transaction_id', $context );
369
+    }
370
+
371
+    /**
372
+     * Get the date that the subscription was created.
373
+     *
374
+     * @since 1.0.19
375
+     * @param  string $context View or edit context.
376
+     * @return string
377
+     */
378
+    public function get_created( $context = 'view' ) {
379
+        return $this->get_prop( 'created', $context );
380
+    }
381
+
382
+    /**
383
+     * Alias for self::get_created().
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $context View or edit context.
387
+     * @return string
388
+     */
389
+    public function get_date_created( $context = 'view' ) {
390
+        return $this->get_created( $context );
391
+    }
392
+
393
+    /**
394
+     * Retrieves the creation date in a timestamp
395
+     *
396
+     * @since  1.0.0
397
+     * @return int
398
+     */
399
+    public function get_time_created() {
400
+        $created = $this->get_date_created();
401
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
+    }
403
+
404
+    /**
405
+     * Get GMT date when the subscription was created.
406
+     *
407
+     * @since 1.0.19
408
+     * @param  string $context View or edit context.
409
+     * @return string
410
+     */
411
+    public function get_date_created_gmt( $context = 'view' ) {
412
+        $date = $this->get_date_created( $context );
413
+
414
+        if ( $date ) {
415
+            $date = get_gmt_from_date( $date );
416
+        }
417
+        return $date;
418
+    }
419
+
420
+    /**
421
+     * Get the date that the subscription will renew.
422
+     *
423
+     * @since 1.0.19
424
+     * @param  string $context View or edit context.
425
+     * @return string
426
+     */
427
+    public function get_next_renewal_date( $context = 'view' ) {
428
+        return $this->get_prop( 'expiration', $context );
429
+    }
430
+
431
+    /**
432
+     * Alias for self::get_next_renewal_date().
433
+     *
434
+     * @since 1.0.19
435
+     * @param  string $context View or edit context.
436
+     * @return string
437
+     */
438
+    public function get_expiration( $context = 'view' ) {
439
+        return $this->get_next_renewal_date( $context );
440
+    }
441
+
442
+    /**
443
+     * Retrieves the expiration date in a timestamp
444
+     *
445
+     * @since  1.0.0
446
+     * @return int
447
+     */
448
+    public function get_expiration_time() {
449
+        $expiration = $this->get_expiration();
450
+
451
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
+            return current_time( 'timestamp' );
453
+        }
454
+
455
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
+    }
458
+
459
+    /**
460
+     * Get GMT date when the subscription will renew.
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
467
+        $date = $this->get_next_renewal_date( $context );
468
+
469
+        if ( $date ) {
470
+            $date = get_gmt_from_date( $date );
471
+        }
472
+        return $date;
473
+    }
474
+
475
+    /**
476
+     * Get the subscription's trial period.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_trial_period( $context = 'view' ) {
483
+        return $this->get_prop( 'trial_period', $context );
484
+    }
485
+
486
+    /**
487
+     * Get the subscription's status.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_status( $context = 'view' ) {
494
+        return $this->get_prop( 'status', $context );
495
+    }
496
+
497
+    /**
498
+     * Get the subscription's profile id.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_profile_id( $context = 'view' ) {
505
+        return $this->get_prop( 'profile_id', $context );
506
+    }
507
+
508
+    /*
509
+	|--------------------------------------------------------------------------
510
+	| Setters
511
+	|--------------------------------------------------------------------------
512
+	*/
513
+
514
+    /**
515
+     * Set customer id.
516
+     *
517
+     * @since 1.0.19
518
+     * @param  int $value The customer's id.
519
+     */
520
+    public function set_customer_id( $value ) {
521
+        $this->set_prop( 'customer_id', (int) $value );
522
+    }
523
+
524
+    /**
525
+     * Set parent invoice id.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  int $value The parent invoice id.
529
+     */
530
+    public function set_parent_invoice_id( $value ) {
531
+        $this->set_prop( 'parent_payment_id', (int) $value );
532
+    }
533
+
534
+    /**
535
+     * Alias for self::set_parent_invoice_id().
536
+     *
537
+     * @since 1.0.19
538
+     * @param  int $value The parent invoice id.
539
+     */
540
+    public function set_parent_payment_id( $value ) {
541
+        $this->set_parent_invoice_id( $value );
542
+    }
543
+
544
+    /**
545
+     * Alias for self::set_parent_invoice_id().
546
+     *
547
+     * @since 1.0.19
548
+     * @param  int $value The parent invoice id.
549
+     */
550
+    public function set_original_payment_id( $value ) {
551
+        $this->set_parent_invoice_id( $value );
552
+    }
553
+
554
+    /**
555
+     * Set subscription's product id.
556
+     *
557
+     * @since 1.0.19
558
+     * @param  int $value The subscription product id.
559
+     */
560
+    public function set_product_id( $value ) {
561
+        $this->set_prop( 'product_id', (int) $value );
562
+    }
563
+
564
+    /**
565
+     * Set the period of a renewal.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $value The renewal period.
569
+     */
570
+    public function set_period( $value ) {
571
+        $this->set_prop( 'period', $value );
572
+    }
573
+
574
+    /**
575
+     * Set number of periods each renewal is valid for.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  int $value The subscription frequency.
579
+     */
580
+    public function set_frequency( $value ) {
581
+        $value = empty( $value ) ? 1 : (int) $value;
582
+        $this->set_prop( 'frequency', absint( $value ) );
583
+    }
584
+
585
+    /**
586
+     * Set the initial amount for the subscription.
587
+     *
588
+     * @since 1.0.19
589
+     * @param  float $value The initial subcription amount.
590
+     */
591
+    public function set_initial_amount( $value ) {
592
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
+    }
594
+
595
+    /**
596
+     * Set the recurring amount for the subscription.
597
+     *
598
+     * @since 1.0.19
599
+     * @param  float $value The recurring subcription amount.
600
+     */
601
+    public function set_recurring_amount( $value ) {
602
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
+    }
604
+
605
+    /**
606
+     * Set number of times that this subscription can be renewed.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  int $value Bill times.
610
+     */
611
+    public function set_bill_times( $value ) {
612
+        $this->set_prop( 'bill_times', (int) $value );
613
+    }
614
+
615
+    /**
616
+     * Get transaction id of this subscription's parent invoice.
617
+     *
618
+     * @since 1.0.19
619
+     * @param string $value Bill times.
620
+     */
621
+    public function set_transaction_id( $value ) {
622
+        $this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
+    }
624
+
625
+    /**
626
+     * Set date when this subscription started.
627
+     *
628
+     * @since 1.0.19
629
+     * @param string $value strtotime compliant date.
630
+     */
631
+    public function set_created( $value ) {
632
+        $date = strtotime( $value );
633
+
634
+        if ( $date && $value !== '0000-00-00 00:00:00' ) {
635
+            $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) );
636
+            return;
637
+        }
638
+
639
+        $this->set_prop( 'created', '' );
640
+
641
+    }
237 642
 
238
-	/**
239
-     * Alias for self::get_parent_invoice_id().
643
+    /**
644
+     * Alias for self::set_created().
240 645
      *
241
-     * @since  1.0.0
242
-     * @return int
646
+     * @since 1.0.19
647
+     * @param string $value strtotime compliant date.
243 648
      */
244
-    public function get_original_payment_id( $context = 'view' ) {
245
-        return $this->get_parent_invoice_id( $context );
649
+    public function set_date_created( $value ) {
650
+        $this->set_created( $value );
246 651
     }
247 652
 
248
-	/**
249
-	 * Get parent invoice.
250
-	 *
251
-	 * @since 1.0.19
252
-	 * @param  string $context View or edit context.
253
-	 * @return WPInv_Invoice
254
-	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
-	}
258
-
259
-	/**
260
-	 * Alias for self::get_parent_invoice().
261
-	 *
262
-	 * @since 1.0.19
263
-	 * @param  string $context View or edit context.
264
-	 * @return WPInv_Invoice
265
-	 */
266
-    public function get_parent_payment( $context = 'view' ) {
267
-        return $this->get_parent_invoice( $context );
268
-	}
269
-
270
-	/**
271
-	 * Get subscription's product id.
272
-	 *
273
-	 * @since 1.0.19
274
-	 * @param  string $context View or edit context.
275
-	 * @return int
276
-	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
279
-	}
280
-
281
-	/**
282
-	 * Get the subscription product.
283
-	 *
284
-	 * @since 1.0.19
285
-	 * @param  string $context View or edit context.
286
-	 * @return WPInv_Item
287
-	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
290
-	}
291
-
292
-	/**
293
-	 * Get parent invoice's gateway.
294
-	 *
295
-	 * Here for backwards compatibility.
296
-	 *
297
-	 * @since 1.0.19
298
-	 * @param  string $context View or edit context.
299
-	 * @return string
300
-	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
303
-	}
304
-
305
-	/**
306
-	 * Get the period of a renewal.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @param  string $context View or edit context.
310
-	 * @return string
311
-	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
314
-	}
315
-
316
-	/**
317
-	 * Get number of periods each renewal is valid for.
318
-	 *
319
-	 * @since 1.0.19
320
-	 * @param  string $context View or edit context.
321
-	 * @return int
322
-	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
325
-	}
326
-
327
-	/**
328
-	 * Get the initial amount for the subscription.
329
-	 *
330
-	 * @since 1.0.19
331
-	 * @param  string $context View or edit context.
332
-	 * @return float
333
-	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
-	}
337
-
338
-	/**
339
-	 * Get the recurring amount for the subscription.
340
-	 *
341
-	 * @since 1.0.19
342
-	 * @param  string $context View or edit context.
343
-	 * @return float
344
-	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
-	}
348
-
349
-	/**
350
-	 * Get number of times that this subscription can be renewed.
351
-	 *
352
-	 * @since 1.0.19
353
-	 * @param  string $context View or edit context.
354
-	 * @return int
355
-	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
358
-	}
359
-
360
-	/**
361
-	 * Get transaction id of this subscription's parent invoice.
362
-	 *
363
-	 * @since 1.0.19
364
-	 * @param  string $context View or edit context.
365
-	 * @return string
366
-	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
369
-	}
370
-
371
-	/**
372
-	 * Get the date that the subscription was created.
373
-	 *
374
-	 * @since 1.0.19
375
-	 * @param  string $context View or edit context.
376
-	 * @return string
377
-	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
380
-	}
381
-
382
-	/**
383
-	 * Alias for self::get_created().
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $context View or edit context.
387
-	 * @return string
388
-	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
391
-	}
392
-
393
-	/**
394
-	 * Retrieves the creation date in a timestamp
395
-	 *
396
-	 * @since  1.0.0
397
-	 * @return int
398
-	 */
399
-	public function get_time_created() {
400
-		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
-	}
403
-
404
-	/**
405
-	 * Get GMT date when the subscription was created.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @param  string $context View or edit context.
409
-	 * @return string
410
-	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
412
-        $date = $this->get_date_created( $context );
653
+    /**
654
+     * Set the date that the subscription will renew.
655
+     *
656
+     * @since 1.0.19
657
+     * @param string $value strtotime compliant date.
658
+     */
659
+    public function set_next_renewal_date( $value ) {
660
+        $date = strtotime( $value );
413 661
 
414
-        if ( $date ) {
415
-            $date = get_gmt_from_date( $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
+            return;
416 665
         }
417
-		return $date;
418
-	}
419
-
420
-	/**
421
-	 * Get the date that the subscription will renew.
422
-	 *
423
-	 * @since 1.0.19
424
-	 * @param  string $context View or edit context.
425
-	 * @return string
426
-	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
429
-	}
430
-
431
-	/**
432
-	 * Alias for self::get_next_renewal_date().
433
-	 *
434
-	 * @since 1.0.19
435
-	 * @param  string $context View or edit context.
436
-	 * @return string
437
-	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
440
-	}
441
-
442
-	/**
443
-	 * Retrieves the expiration date in a timestamp
444
-	 *
445
-	 * @since  1.0.0
446
-	 * @return int
447
-	 */
448
-	public function get_expiration_time() {
449
-		$expiration = $this->get_expiration();
450
-
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
453
-		}
454
-
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
-	}
458
-
459
-	/**
460
-	 * Get GMT date when the subscription will renew.
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_next_renewal_date( $context );
468 666
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
471
-        }
472
-		return $date;
473
-	}
474
-
475
-	/**
476
-	 * Get the subscription's trial period.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
484
-	}
485
-
486
-	/**
487
-	 * Get the subscription's status.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
495
-	}
496
-
497
-	/**
498
-	 * Get the subscription's profile id.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
506
-	}
507
-
508
-	/*
509
-	|--------------------------------------------------------------------------
510
-	| Setters
511
-	|--------------------------------------------------------------------------
512
-	*/
667
+        $this->set_prop( 'expiration', '' );
513 668
 
514
-	/**
515
-	 * Set customer id.
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param  int $value The customer's id.
519
-	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
522
-	}
523
-
524
-	/**
525
-	 * Set parent invoice id.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  int $value The parent invoice id.
529
-	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
532
-	}
533
-
534
-	/**
535
-	 * Alias for self::set_parent_invoice_id().
536
-	 *
537
-	 * @since 1.0.19
538
-	 * @param  int $value The parent invoice id.
539
-	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
542
-	}
669
+    }
543 670
 
544
-	/**
545
-     * Alias for self::set_parent_invoice_id().
671
+    /**
672
+     * Alias for self::set_next_renewal_date().
546 673
      *
547 674
      * @since 1.0.19
548
-	 * @param  int $value The parent invoice id.
675
+     * @param string $value strtotime compliant date.
549 676
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
552
-	}
553
-
554
-	/**
555
-	 * Set subscription's product id.
556
-	 *
557
-	 * @since 1.0.19
558
-	 * @param  int $value The subscription product id.
559
-	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
562
-	}
563
-
564
-	/**
565
-	 * Set the period of a renewal.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $value The renewal period.
569
-	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
572
-	}
573
-
574
-	/**
575
-	 * Set number of periods each renewal is valid for.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  int $value The subscription frequency.
579
-	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
583
-	}
584
-
585
-	/**
586
-	 * Set the initial amount for the subscription.
587
-	 *
588
-	 * @since 1.0.19
589
-	 * @param  float $value The initial subcription amount.
590
-	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
-	}
594
-
595
-	/**
596
-	 * Set the recurring amount for the subscription.
597
-	 *
598
-	 * @since 1.0.19
599
-	 * @param  float $value The recurring subcription amount.
600
-	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
-	}
604
-
605
-	/**
606
-	 * Set number of times that this subscription can be renewed.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  int $value Bill times.
610
-	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
613
-	}
614
-
615
-	/**
616
-	 * Get transaction id of this subscription's parent invoice.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @param string $value Bill times.
620
-	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
-	}
624
-
625
-	/**
626
-	 * Set date when this subscription started.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param string $value strtotime compliant date.
630
-	 */
631
-	public function set_created( $value ) {
632
-        $date = strtotime( $value );
677
+    public function set_expiration( $value ) {
678
+        $this->set_next_renewal_date( $value );
679
+    }
633 680
 
634
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
635
-            $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) );
681
+    /**
682
+     * Set the subscription's trial period.
683
+     *
684
+     * @since 1.0.19
685
+     * @param string $value trial period e.g 1 year.
686
+     */
687
+    public function set_trial_period( $value ) {
688
+        $this->set_prop( 'trial_period', $value );
689
+    }
690
+
691
+    /**
692
+     * Set the subscription's status.
693
+     *
694
+     * @since 1.0.19
695
+     * @param string $new_status    New subscription status.
696
+     */
697
+    public function set_status( $new_status ) {
698
+
699
+        // Abort if this is not a valid status;
700
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
636 701
             return;
637 702
         }
638 703
 
639
-		$this->set_prop( 'created', '' );
640
-
641
-	}
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
+            $this->status_transition = array(
707
+                'from' => $old_status,
708
+                'to'   => $new_status,
709
+            );
710
+        }
642 711
 
643
-	/**
644
-	 * Alias for self::set_created().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param string $value strtotime compliant date.
648
-	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
712
+        $this->set_prop( 'status', $new_status );
651 713
     }
652 714
 
653
-	/**
654
-	 * Set the date that the subscription will renew.
655
-	 *
656
-	 * @since 1.0.19
657
-	 * @param string $value strtotime compliant date.
658
-	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
715
+    /**
716
+     * Set the subscription's (remote) profile id.
717
+     *
718
+     * @since 1.0.19
719
+     * @param  string $value the remote profile id.
720
+     */
721
+    public function set_profile_id( $value ) {
722
+        $this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
+    }
661 724
 
662
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
663
-            $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
664
-            return;
665
-		}
666
-
667
-		$this->set_prop( 'expiration', '' );
668
-
669
-	}
670
-
671
-	/**
672
-	 * Alias for self::set_next_renewal_date().
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param string $value strtotime compliant date.
676
-	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
679
-    }
680
-
681
-	/**
682
-	 * Set the subscription's trial period.
683
-	 *
684
-	 * @since 1.0.19
685
-	 * @param string $value trial period e.g 1 year.
686
-	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
689
-	}
690
-
691
-	/**
692
-	 * Set the subscription's status.
693
-	 *
694
-	 * @since 1.0.19
695
-	 * @param string $new_status    New subscription status.
696
-	 */
697
-	public function set_status( $new_status ) {
698
-
699
-		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
701
-			return;
702
-		}
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 ) {
706
-			$this->status_transition = array(
707
-				'from' => $old_status,
708
-				'to'   => $new_status,
709
-			);
710
-		}
711
-
712
-		$this->set_prop( 'status', $new_status );
713
-	}
714
-
715
-	/**
716
-	 * Set the subscription's (remote) profile id.
717
-	 *
718
-	 * @since 1.0.19
719
-	 * @param  string $value the remote profile id.
720
-	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
-	}
724
-
725
-	/*
725
+    /*
726 726
 	|--------------------------------------------------------------------------
727 727
 	| Boolean methods
728 728
 	|--------------------------------------------------------------------------
@@ -731,55 +731,55 @@  discard block
 block discarded – undo
731 731
 	|
732 732
 	*/
733 733
 
734
-	/**
734
+    /**
735 735
      * Checks if the subscription has a given status.
736
-	 *
737
-	 * @param string|array String or array of strings to check for.
738
-	 * @return bool
736
+     *
737
+     * @param string|array String or array of strings to check for.
738
+     * @return bool
739 739
      */
740 740
     public function has_status( $status ) {
741 741
         return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
742
-	}
742
+    }
743 743
 
744
-	/**
744
+    /**
745 745
      * Checks if the subscription has a trial period.
746
-	 *
747
-	 * @return bool
746
+     *
747
+     * @return bool
748 748
      */
749 749
     public function has_trial_period() {
750
-		$period = $this->get_trial_period();
750
+        $period = $this->get_trial_period();
751 751
         return ! empty( $period );
752
-	}
753
-
754
-	/**
755
-	 * Is the subscription active?
756
-	 *
757
-	 * @return bool
758
-	 */
759
-	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
-	}
762
-
763
-	/**
764
-	 * Is the subscription expired?
765
-	 *
766
-	 * @return bool
767
-	 */
768
-	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
-	}
771
-
772
-	/**
773
-	 * Is this the last renewals?
774
-	 *
775
-	 * @return bool
776
-	 */
777
-	public function is_last_renewal() {
778
-		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
-	}
781
-
782
-	/*
752
+    }
753
+
754
+    /**
755
+     * Is the subscription active?
756
+     *
757
+     * @return bool
758
+     */
759
+    public function is_active() {
760
+        return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
+    }
762
+
763
+    /**
764
+     * Is the subscription expired?
765
+     *
766
+     * @return bool
767
+     */
768
+    public function is_expired() {
769
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
+    }
771
+
772
+    /**
773
+     * Is this the last renewals?
774
+     *
775
+     * @return bool
776
+     */
777
+    public function is_last_renewal() {
778
+        $max_bills = $this->get_bill_times();
779
+        return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
+    }
781
+
782
+    /*
783 783
 	|--------------------------------------------------------------------------
784 784
 	| Additional methods
785 785
 	|--------------------------------------------------------------------------
@@ -788,27 +788,27 @@  discard block
 block discarded – undo
788 788
 	|
789 789
 	*/
790 790
 
791
-	/**
792
-	 * Backwards compatibilty.
793
-	 */
794
-	public function create( $data = array() ) {
791
+    /**
792
+     * Backwards compatibilty.
793
+     */
794
+    public function create( $data = array() ) {
795 795
 
796
-		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
799
-		}
796
+        // Set the properties.
797
+        if ( is_array( $data ) ) {
798
+            $this->set_props( $data );
799
+        }
800 800
 
801
-		// Save the item.
802
-		return $this->save();
801
+        // Save the item.
802
+        return $this->save();
803 803
 
804
-	}
804
+    }
805 805
 
806
-	/**
807
-	 * Backwards compatibilty.
808
-	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
811
-	}
806
+    /**
807
+     * Backwards compatibilty.
808
+     */
809
+    public function update( $args = array() ) {
810
+        return $this->create( $args );
811
+    }
812 812
 
813 813
     /**
814 814
      * Retrieve renewal payments for a subscription
@@ -818,22 +818,22 @@  discard block
 block discarded – undo
818 818
      */
819 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() );
825
-		}
823
+        if ( ! $hide_pending ) {
824
+            $statuses = array_keys( wpinv_get_invoice_statuses() );
825
+        }
826 826
 
827 827
         return get_posts(
828
-			array(
829
-            	'post_parent' => $this->get_parent_payment_id(),
830
-            	'numberposts' => -1,
831
-            	'post_status' => $statuses,
832
-            	'orderby'     => 'ID',
833
-            	'order'       => 'ASC',
834
-            	'post_type'   => 'wpi_invoice',
835
-			)
836
-		);
828
+            array(
829
+                'post_parent' => $this->get_parent_payment_id(),
830
+                'numberposts' => -1,
831
+                'post_status' => $statuses,
832
+                'orderby'     => 'ID',
833
+                'order'       => 'ASC',
834
+                'post_type'   => 'wpi_invoice',
835
+            )
836
+        );
837 837
     }
838 838
 
839 839
     /**
@@ -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
     /**
@@ -867,192 +867,192 @@  discard block
 block discarded – undo
867 867
      *
868 868
      * @since  2.4
869 869
      * @param  array $args Array of values for the payment, including amount and transaction ID
870
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
870
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873 873
     public function add_payment( $args = array(), $invoice = false ) {
874 874
 
875
-		// Process each payment once.
875
+        // Process each payment once.
876 876
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
877 877
             return false;
878 878
         }
879 879
 
880
-		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
880
+        // Are we creating a new invoice?
881
+        if ( empty( $invoice ) ) {
882
+            $invoice = $this->create_payment( false );
883 883
 
884
-			if ( empty( $invoice ) ) {
885
-				return false;
886
-			}
887
-		}
884
+            if ( empty( $invoice ) ) {
885
+                return false;
886
+            }
887
+        }
888 888
 
889
-		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
892
-		}
889
+        // Maybe set a transaction id.
890
+        if ( ! empty( $args['transaction_id'] ) ) {
891
+            $invoice->set_transaction_id( $args['transaction_id'] );
892
+        }
893 893
 
894
-		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
894
+        // Set the completed date.
895
+        $invoice->set_completed_date( current_time( 'mysql' ) );
896 896
 
897
-		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
900
-		}
897
+        // And the gateway.
898
+        if ( ! empty( $args['gateway'] ) ) {
899
+            $invoice->set_gateway( $args['gateway'] );
900
+        }
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
903
-		$invoice->save();
902
+        $invoice->set_status( 'wpi-renewal' );
903
+        $invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
906
-			return false;
907
-		}
905
+        if ( ! $invoice->exists() ) {
906
+            return false;
907
+        }
908 908
 
909
-		return $this->after_add_payment( $invoice );
910
-	}
909
+        return $this->after_add_payment( $invoice );
910
+    }
911 911
 
912 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 );
914
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916 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 918
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
919 919
 
920 920
         return $invoice->get_id();
921
-	}
921
+    }
922 922
 
923
-	/**
923
+    /**
924 924
      * Creates a new invoice and returns it.
925 925
      *
926 926
      * @since  1.0.19
927
-	 * @param bool $save Whether we should save the invoice.
927
+     * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930 930
     public function create_payment( $save = true ) {
931 931
 
932
-		$parent_invoice = $this->get_parent_payment();
933
-
934
-		if ( ! $parent_invoice->exists() ) {
935
-			return false;
936
-		}
937
-
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() );
943
-
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'] );
947
-		$invoice_items      = array();
948
-
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
951
-				$invoice_items[] = $item;
952
-			}
953
-		}
954
-
955
-		$invoice->set_items( $invoice_items );
956
-
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
959
-		}
960
-
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 ) );
965
-		}
966
-
967
-		$invoice->recalculate_total();
968
-		$invoice->set_status( 'wpi-pending' );
969
-
970
-		if ( ! $save ) {
971
-			return $invoice;
972
-		}
973
-
974
-		$invoice->save();
975
-
976
-		return $invoice->exists() ? $invoice : false;
977
-    }
978
-
979
-	/**
980
-	 * Renews or completes a subscription
981
-	 *
982
-	 * @since  1.0.0
983
-	 * @return int The subscription's id
984
-	 */
985
-	public function renew( $calculate_from = null ) {
986
-
987
-		// Complete subscription if applicable
988
-		if ( $this->is_last_renewal() ) {
989
-			return $this->complete();
990
-		}
991
-
992
-		// Calculate new expiration
993
-		$frequency      = $this->get_frequency();
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 );
997
-
998
-		$this->set_expiration( date( 'Y-m-d H:i:s', $new_expiration ) );
999
-		$this->set_status( 'active' );
1000
-		$this->save();
1001
-
1002
-		do_action( 'getpaid_subscription_renewed', $this );
1003
-
1004
-		return $this->get_id();
1005
-	}
1006
-
1007
-	/**
1008
-	 * Marks a subscription as completed
1009
-	 *
1010
-	 * Subscription is completed when the number of payments matches the billing_times field
1011
-	 *
1012
-	 * @since  1.0.0
1013
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
1014
-	 */
1015
-	public function complete() {
1016
-
1017
-		// Only mark a subscription as complete if it's not already cancelled.
1018
-		if ( $this->has_status( 'cancelled' ) ) {
1019
-			return false;
1020
-		}
1021
-
1022
-		$this->set_status( 'completed' );
1023
-		return $this->save();
1024
-
1025
-	}
1026
-
1027
-	/**
1028
-	 * Marks a subscription as expired
1029
-	 *
1030
-	 * @since  1.0.0
1031
-	 * @param  bool $check_expiration
1032
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1033
-	 */
1034
-	public function expire( $check_expiration = false ) {
1035
-
1036
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1037
-			// Do not mark as expired since real expiration date is in the future
1038
-			return false;
1039
-		}
1040
-
1041
-		$this->set_status( 'expired' );
1042
-		return $this->save();
1043
-
1044
-	}
1045
-
1046
-	/**
1047
-	 * Marks a subscription as failing
1048
-	 *
1049
-	 * @since  2.4.2
1050
-	 * @return int Subscription id.
1051
-	 */
1052
-	public function failing() {
1053
-		$this->set_status( 'failing' );
1054
-		return $this->save();
1055
-	}
932
+        $parent_invoice = $this->get_parent_payment();
933
+
934
+        if ( ! $parent_invoice->exists() ) {
935
+            return false;
936
+        }
937
+
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() );
943
+
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'] );
947
+        $invoice_items      = array();
948
+
949
+        foreach ( $invoice->get_items() as $item ) {
950
+            if ( in_array( $item->get_id(), $allowed_items ) ) {
951
+                $invoice_items[] = $item;
952
+            }
953
+        }
954
+
955
+        $invoice->set_items( $invoice_items );
956
+
957
+        if ( ! empty( $subscription_group['fees'] ) ) {
958
+            $invoice->set_fees( $subscription_group['fees'] );
959
+        }
960
+
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 ) );
965
+        }
966
+
967
+        $invoice->recalculate_total();
968
+        $invoice->set_status( 'wpi-pending' );
969
+
970
+        if ( ! $save ) {
971
+            return $invoice;
972
+        }
973
+
974
+        $invoice->save();
975
+
976
+        return $invoice->exists() ? $invoice : false;
977
+    }
978
+
979
+    /**
980
+     * Renews or completes a subscription
981
+     *
982
+     * @since  1.0.0
983
+     * @return int The subscription's id
984
+     */
985
+    public function renew( $calculate_from = null ) {
986
+
987
+        // Complete subscription if applicable
988
+        if ( $this->is_last_renewal() ) {
989
+            return $this->complete();
990
+        }
991
+
992
+        // Calculate new expiration
993
+        $frequency      = $this->get_frequency();
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 );
997
+
998
+        $this->set_expiration( date( 'Y-m-d H:i:s', $new_expiration ) );
999
+        $this->set_status( 'active' );
1000
+        $this->save();
1001
+
1002
+        do_action( 'getpaid_subscription_renewed', $this );
1003
+
1004
+        return $this->get_id();
1005
+    }
1006
+
1007
+    /**
1008
+     * Marks a subscription as completed
1009
+     *
1010
+     * Subscription is completed when the number of payments matches the billing_times field
1011
+     *
1012
+     * @since  1.0.0
1013
+     * @return int|bool Subscription id or false if the subscription is cancelled.
1014
+     */
1015
+    public function complete() {
1016
+
1017
+        // Only mark a subscription as complete if it's not already cancelled.
1018
+        if ( $this->has_status( 'cancelled' ) ) {
1019
+            return false;
1020
+        }
1021
+
1022
+        $this->set_status( 'completed' );
1023
+        return $this->save();
1024
+
1025
+    }
1026
+
1027
+    /**
1028
+     * Marks a subscription as expired
1029
+     *
1030
+     * @since  1.0.0
1031
+     * @param  bool $check_expiration
1032
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1033
+     */
1034
+    public function expire( $check_expiration = false ) {
1035
+
1036
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1037
+            // Do not mark as expired since real expiration date is in the future
1038
+            return false;
1039
+        }
1040
+
1041
+        $this->set_status( 'expired' );
1042
+        return $this->save();
1043
+
1044
+    }
1045
+
1046
+    /**
1047
+     * Marks a subscription as failing
1048
+     *
1049
+     * @since  2.4.2
1050
+     * @return int Subscription id.
1051
+     */
1052
+    public function failing() {
1053
+        $this->set_status( 'failing' );
1054
+        return $this->save();
1055
+    }
1056 1056
 
1057 1057
     /**
1058 1058
      * Marks a subscription as cancelled
@@ -1061,19 +1061,19 @@  discard block
 block discarded – undo
1061 1061
      * @return int Subscription id.
1062 1062
      */
1063 1063
     public function cancel() {
1064
-		$this->set_status( 'cancelled' );
1065
-		return $this->save();
1064
+        $this->set_status( 'cancelled' );
1065
+        return $this->save();
1066 1066
     }
1067 1067
 
1068
-	/**
1069
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1070
-	 *
1071
-	 * @since  1.0.0
1072
-	 * @return bool
1073
-	 */
1074
-	public function can_cancel() {
1075
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1076
-	}
1068
+    /**
1069
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1070
+     *
1071
+     * @since  1.0.0
1072
+     * @return bool
1073
+     */
1074
+    public function can_cancel() {
1075
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1076
+    }
1077 1077
 
1078 1078
     /**
1079 1079
      * Returns an array of subscription statuses that can be cancelled
@@ -1086,109 +1086,109 @@  discard block
 block discarded – undo
1086 1086
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1087 1087
     }
1088 1088
 
1089
-	/**
1090
-	 * Retrieves the URL to cancel subscription
1091
-	 *
1092
-	 * @since  1.0.0
1093
-	 * @return string
1094
-	 */
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 );
1098
-	}
1099
-
1100
-	/**
1101
-	 * Retrieves the URL to view a subscription
1102
-	 *
1103
-	 * @since  1.0.19
1104
-	 * @return string
1105
-	 */
1106
-	public function get_view_url() {
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 );
1110
-
1111
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1112
-	}
1113
-
1114
-	/**
1115
-	 * Determines if subscription can be manually renewed
1116
-	 *
1117
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1118
-	 * that can be renewed manually
1119
-	 *
1120
-	 * @since  2.5
1121
-	 * @return bool
1122
-	 */
1123
-	public function can_renew() {
1124
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1125
-	}
1126
-
1127
-	/**
1128
-	 * Retrieves the URL to renew a subscription
1129
-	 *
1130
-	 * @since  2.5
1131
-	 * @return string
1132
-	 */
1133
-	public function get_renew_url() {
1134
-		$url = wp_nonce_url(
1089
+    /**
1090
+     * Retrieves the URL to cancel subscription
1091
+     *
1092
+     * @since  1.0.0
1093
+     * @return string
1094
+     */
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 );
1098
+    }
1099
+
1100
+    /**
1101
+     * Retrieves the URL to view a subscription
1102
+     *
1103
+     * @since  1.0.19
1104
+     * @return string
1105
+     */
1106
+    public function get_view_url() {
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 );
1110
+
1111
+        return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1112
+    }
1113
+
1114
+    /**
1115
+     * Determines if subscription can be manually renewed
1116
+     *
1117
+     * This method is filtered by payment gateways in order to return true on subscriptions
1118
+     * that can be renewed manually
1119
+     *
1120
+     * @since  2.5
1121
+     * @return bool
1122
+     */
1123
+    public function can_renew() {
1124
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1125
+    }
1126
+
1127
+    /**
1128
+     * Retrieves the URL to renew a subscription
1129
+     *
1130
+     * @since  2.5
1131
+     * @return string
1132
+     */
1133
+    public function get_renew_url() {
1134
+        $url = wp_nonce_url(
1135 1135
             add_query_arg(
1136 1136
                 array(
1137
-					'getpaid-action' => 'renew_subscription',
1138
-					'sub_id'         => $this->get_id,
1137
+                    'getpaid-action' => 'renew_subscription',
1138
+                    'sub_id'         => $this->get_id,
1139 1139
                 )
1140 1140
             ),
1141 1141
             'getpaid-nonce'
1142 1142
         );
1143
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1144
-	}
1145
-
1146
-	/**
1147
-	 * Determines if subscription can have their payment method updated
1148
-	 *
1149
-	 * @since  1.0.0
1150
-	 * @return bool
1151
-	 */
1152
-	public function can_update() {
1153
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1154
-	}
1155
-
1156
-	/**
1157
-	 * Retrieves the URL to update subscription
1158
-	 *
1159
-	 * @since  1.0.0
1160
-	 * @return string
1161
-	 */
1162
-	public function get_update_url() {
1163
-		$url = add_query_arg(
1143
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1144
+    }
1145
+
1146
+    /**
1147
+     * Determines if subscription can have their payment method updated
1148
+     *
1149
+     * @since  1.0.0
1150
+     * @return bool
1151
+     */
1152
+    public function can_update() {
1153
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1154
+    }
1155
+
1156
+    /**
1157
+     * Retrieves the URL to update subscription
1158
+     *
1159
+     * @since  1.0.0
1160
+     * @return string
1161
+     */
1162
+    public function get_update_url() {
1163
+        $url = add_query_arg(
1164 1164
             array(
1165
-				'action'          => 'update',
1166
-				'subscription_id' => $this->get_id(),
1165
+                'action'          => 'update',
1166
+                'subscription_id' => $this->get_id(),
1167 1167
             )
1168 1168
         );
1169
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1170
-	}
1171
-
1172
-	/**
1173
-	 * Retrieves the subscription status label
1174
-	 *
1175
-	 * @since  1.0.0
1176
-	 * @return string
1177
-	 */
1178
-	public function get_status_label() {
1179
-		return getpaid_get_subscription_status_label( $this->get_status() );
1180
-	}
1181
-
1182
-	/**
1183
-	 * Retrieves the subscription status class
1184
-	 *
1185
-	 * @since  1.0.19
1186
-	 * @return string
1187
-	 */
1188
-	public function get_status_class() {
1189
-		$statuses = getpaid_get_subscription_status_classes();
1190
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1191
-	}
1169
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1170
+    }
1171
+
1172
+    /**
1173
+     * Retrieves the subscription status label
1174
+     *
1175
+     * @since  1.0.0
1176
+     * @return string
1177
+     */
1178
+    public function get_status_label() {
1179
+        return getpaid_get_subscription_status_label( $this->get_status() );
1180
+    }
1181
+
1182
+    /**
1183
+     * Retrieves the subscription status class
1184
+     *
1185
+     * @since  1.0.19
1186
+     * @return string
1187
+     */
1188
+    public function get_status_class() {
1189
+        $statuses = getpaid_get_subscription_status_classes();
1190
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1191
+    }
1192 1192
 
1193 1193
     /**
1194 1194
      * Retrieves the subscription status label
@@ -1198,11 +1198,11 @@  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
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1205
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1206 1206
     }
1207 1207
 
1208 1208
     /**
@@ -1213,75 +1213,75 @@  discard block
 block discarded – undo
1213 1213
      * @return bool
1214 1214
      */
1215 1215
     public function payment_exists( $txn_id = '' ) {
1216
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1216
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1217 1217
         return ! empty( $invoice_id );
1218
-	}
1219
-
1220
-	/**
1221
-	 * Handle the status transition.
1222
-	 */
1223
-	protected function status_transition() {
1224
-		$status_transition = $this->status_transition;
1225
-
1226
-		// Reset status transition variable.
1227
-		$this->status_transition = false;
1228
-
1229
-		if ( $status_transition ) {
1230
-			try {
1231
-
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 );
1235
-
1236
-				if ( ! empty( $status_transition['from'] ) ) {
1237
-
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'] ) );
1240
-
1241
-					// Note the transition occurred.
1242
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1243
-
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'] );
1247
-
1248
-				} else {
1249
-					/* translators: %s: new invoice status */
1250
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1251
-
1252
-					// Note the transition occurred.
1253
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1254
-
1255
-				}
1256
-			} catch ( Exception $e ) {
1257
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1258
-			}
1259
-		}
1260
-
1261
-	}
1262
-
1263
-	/**
1264
-	 * Save data to the database.
1265
-	 *
1266
-	 * @since 1.0.19
1267
-	 * @return int subscription ID
1268
-	 */
1269
-	public function save() {
1270
-		parent::save();
1271
-		$this->status_transition();
1272
-		return $this->get_id();
1273
-	}
1274
-
1275
-	/**
1276
-	 * Activates a subscription.
1277
-	 *
1278
-	 * @since 1.0.19
1279
-	 * @return int subscription ID
1280
-	 */
1281
-	public function activate() {
1282
-		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1283
-		$this->set_status( $status );
1284
-		return $this->save();
1285
-	}
1218
+    }
1219
+
1220
+    /**
1221
+     * Handle the status transition.
1222
+     */
1223
+    protected function status_transition() {
1224
+        $status_transition = $this->status_transition;
1225
+
1226
+        // Reset status transition variable.
1227
+        $this->status_transition = false;
1228
+
1229
+        if ( $status_transition ) {
1230
+            try {
1231
+
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 );
1235
+
1236
+                if ( ! empty( $status_transition['from'] ) ) {
1237
+
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'] ) );
1240
+
1241
+                    // Note the transition occurred.
1242
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1243
+
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'] );
1247
+
1248
+                } else {
1249
+                    /* translators: %s: new invoice status */
1250
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1251
+
1252
+                    // Note the transition occurred.
1253
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1254
+
1255
+                }
1256
+            } catch ( Exception $e ) {
1257
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1258
+            }
1259
+        }
1260
+
1261
+    }
1262
+
1263
+    /**
1264
+     * Save data to the database.
1265
+     *
1266
+     * @since 1.0.19
1267
+     * @return int subscription ID
1268
+     */
1269
+    public function save() {
1270
+        parent::save();
1271
+        $this->status_transition();
1272
+        return $this->get_id();
1273
+    }
1274
+
1275
+    /**
1276
+     * Activates a subscription.
1277
+     *
1278
+     * @since 1.0.19
1279
+     * @return int subscription ID
1280
+     */
1281
+    public function activate() {
1282
+        $status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1283
+        $this->set_status( $status );
1284
+        return $this->save();
1285
+    }
1286 1286
 
1287 1287
 }
Please login to merge, or discard this 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/data-stores/class-getpaid-customer-data-store.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,196 +15,196 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Customer_Data_Store {
17 17
 
18
-	/*
18
+    /*
19 19
 	|--------------------------------------------------------------------------
20 20
 	| CRUD Methods
21 21
 	|--------------------------------------------------------------------------
22 22
 	*/
23 23
 
24
-	/**
25
-	 * Method to create a new customer in the database.
26
-	 *
27
-	 * @param GetPaid_Customer $customer customer object.
28
-	 */
29
-	public function create( &$customer ) {
30
-		global $wpdb;
31
-
32
-		$values  = array();
33
-		$formats = array();
34
-
35
-		$fields = self::get_database_fields();
36
-		unset( $fields['id'] );
37
-
38
-		foreach ( $fields as $key => $format ) {
39
-			$values[ $key ] = $customer->get( $key, 'edit' );
40
-			$formats[]      = $format;
41
-		}
42
-
43
-		$result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
44
-
45
-		if ( $result ) {
46
-			$customer->set_id( $wpdb->insert_id );
47
-			$customer->apply_changes();
48
-			$customer->clear_cache();
49
-			do_action( 'getpaid_new_customer', $customer );
50
-			return true;
51
-		}
52
-
53
-		return false;
54
-	}
55
-
56
-	/**
57
-	 * Method to read a customer from the database.
58
-	 *
59
-	 * @param GetPaid_Customer $customer customer object.
60
-	 *
61
-	 */
62
-	public function read( &$customer ) {
63
-		global $wpdb;
64
-
65
-		$customer->set_defaults();
66
-
67
-		if ( ! $customer->get_id() ) {
68
-			$customer->last_error = 'Invalid customer.';
69
-			$customer->set_id( 0 );
70
-			return false;
71
-		}
72
-
73
-		// Maybe retrieve from the cache.
74
-		$raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
75
-
76
-		// If not found, retrieve from the db.
77
-		if ( false === $raw_customer ) {
78
-
79
-			$raw_customer = $wpdb->get_row(
80
-				$wpdb->prepare(
81
-					"SELECT * FROM {$wpdb->prefix}getpaid_customers WHERE id = %d",
82
-					$customer->get_id()
83
-				)
84
-			);
85
-
86
-			// Update the cache with our data
87
-			wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
88
-
89
-		}
90
-
91
-		if ( ! $raw_customer ) {
92
-			$raw_customer->last_error = 'Invalid customer.';
93
-			return false;
94
-		}
95
-
96
-		// Loop through raw customer fields.
97
-		foreach ( (array) $raw_customer as $key => $value ) {
98
-			$customer->set( $key, $value );
99
-		}
100
-
101
-		$customer->set_object_read( true );
102
-		do_action( 'getpaid_read_customer', $customer );
103
-
104
-	}
105
-
106
-	/**
107
-	 * Method to update a customer in the database.
108
-	 *
109
-	 * @param GetPaid_Customer $customer Customer object.
110
-	 */
111
-	public function update( &$customer ) {
112
-		global $wpdb;
113
-
114
-		do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
115
-
116
-		$changes = $customer->get_changes();
117
-		$values  = array();
118
-		$format  = array();
119
-
120
-		foreach ( self::get_database_fields() as $key => $format ) {
121
-			if ( array_key_exists( $key, $changes ) ) {
122
-				$values[ $key ] = $customer->get( $key, 'edit' );
123
-				$formats[]      = $format;
124
-			}
125
-		}
126
-
127
-		if ( empty( $values ) ) {
128
-			return;
129
-		}
130
-
131
-		$wpdb->update(
132
-			$wpdb->prefix . 'getpaid_customers',
133
-			$values,
134
-			array(
135
-				'id' => $customer->get_id(),
136
-			),
137
-			$formats,
138
-			'%d'
139
-		);
140
-
141
-		// Apply the changes.
142
-		$customer->apply_changes();
143
-
144
-		// Delete cache.
145
-		$customer->clear_cache();
146
-
147
-		// Fire a hook.
148
-		do_action( 'getpaid_update_customer', $customer );
149
-
150
-	}
151
-
152
-	/**
153
-	 * Method to delete a customer from the database.
154
-	 *
155
-	 * @param GetPaid_Customer $customer
156
-	 */
157
-	public function delete( &$customer ) {
158
-		global $wpdb;
159
-
160
-		do_action( 'getpaid_before_delete_customer', $customer );
161
-
162
-		$wpdb->delete(
163
-			$wpdb->prefix . 'getpaid_customers',
164
-			array(
165
-				'id' => $customer->get_id(),
166
-			),
167
-			'%d'
168
-		);
169
-
170
-		// Delete cache.
171
-		$customer->clear_cache();
172
-
173
-		// Fire a hook.
174
-		do_action( 'getpaid_delete_customer', $customer );
175
-
176
-		$customer->set_id( 0 );
177
-	}
178
-
179
-	/*
24
+    /**
25
+     * Method to create a new customer in the database.
26
+     *
27
+     * @param GetPaid_Customer $customer customer object.
28
+     */
29
+    public function create( &$customer ) {
30
+        global $wpdb;
31
+
32
+        $values  = array();
33
+        $formats = array();
34
+
35
+        $fields = self::get_database_fields();
36
+        unset( $fields['id'] );
37
+
38
+        foreach ( $fields as $key => $format ) {
39
+            $values[ $key ] = $customer->get( $key, 'edit' );
40
+            $formats[]      = $format;
41
+        }
42
+
43
+        $result = $wpdb->insert( $wpdb->prefix . 'getpaid_customers', $values, $formats );
44
+
45
+        if ( $result ) {
46
+            $customer->set_id( $wpdb->insert_id );
47
+            $customer->apply_changes();
48
+            $customer->clear_cache();
49
+            do_action( 'getpaid_new_customer', $customer );
50
+            return true;
51
+        }
52
+
53
+        return false;
54
+    }
55
+
56
+    /**
57
+     * Method to read a customer from the database.
58
+     *
59
+     * @param GetPaid_Customer $customer customer object.
60
+     *
61
+     */
62
+    public function read( &$customer ) {
63
+        global $wpdb;
64
+
65
+        $customer->set_defaults();
66
+
67
+        if ( ! $customer->get_id() ) {
68
+            $customer->last_error = 'Invalid customer.';
69
+            $customer->set_id( 0 );
70
+            return false;
71
+        }
72
+
73
+        // Maybe retrieve from the cache.
74
+        $raw_customer = wp_cache_get( $customer->get_id(), 'getpaid_customers' );
75
+
76
+        // If not found, retrieve from the db.
77
+        if ( false === $raw_customer ) {
78
+
79
+            $raw_customer = $wpdb->get_row(
80
+                $wpdb->prepare(
81
+                    "SELECT * FROM {$wpdb->prefix}getpaid_customers WHERE id = %d",
82
+                    $customer->get_id()
83
+                )
84
+            );
85
+
86
+            // Update the cache with our data
87
+            wp_cache_set( $customer->get_id(), $raw_customer, 'getpaid_customers' );
88
+
89
+        }
90
+
91
+        if ( ! $raw_customer ) {
92
+            $raw_customer->last_error = 'Invalid customer.';
93
+            return false;
94
+        }
95
+
96
+        // Loop through raw customer fields.
97
+        foreach ( (array) $raw_customer as $key => $value ) {
98
+            $customer->set( $key, $value );
99
+        }
100
+
101
+        $customer->set_object_read( true );
102
+        do_action( 'getpaid_read_customer', $customer );
103
+
104
+    }
105
+
106
+    /**
107
+     * Method to update a customer in the database.
108
+     *
109
+     * @param GetPaid_Customer $customer Customer object.
110
+     */
111
+    public function update( &$customer ) {
112
+        global $wpdb;
113
+
114
+        do_action( 'getpaid_before_update_customer', $customer, $customer->get_changes() );
115
+
116
+        $changes = $customer->get_changes();
117
+        $values  = array();
118
+        $format  = array();
119
+
120
+        foreach ( self::get_database_fields() as $key => $format ) {
121
+            if ( array_key_exists( $key, $changes ) ) {
122
+                $values[ $key ] = $customer->get( $key, 'edit' );
123
+                $formats[]      = $format;
124
+            }
125
+        }
126
+
127
+        if ( empty( $values ) ) {
128
+            return;
129
+        }
130
+
131
+        $wpdb->update(
132
+            $wpdb->prefix . 'getpaid_customers',
133
+            $values,
134
+            array(
135
+                'id' => $customer->get_id(),
136
+            ),
137
+            $formats,
138
+            '%d'
139
+        );
140
+
141
+        // Apply the changes.
142
+        $customer->apply_changes();
143
+
144
+        // Delete cache.
145
+        $customer->clear_cache();
146
+
147
+        // Fire a hook.
148
+        do_action( 'getpaid_update_customer', $customer );
149
+
150
+    }
151
+
152
+    /**
153
+     * Method to delete a customer from the database.
154
+     *
155
+     * @param GetPaid_Customer $customer
156
+     */
157
+    public function delete( &$customer ) {
158
+        global $wpdb;
159
+
160
+        do_action( 'getpaid_before_delete_customer', $customer );
161
+
162
+        $wpdb->delete(
163
+            $wpdb->prefix . 'getpaid_customers',
164
+            array(
165
+                'id' => $customer->get_id(),
166
+            ),
167
+            '%d'
168
+        );
169
+
170
+        // Delete cache.
171
+        $customer->clear_cache();
172
+
173
+        // Fire a hook.
174
+        do_action( 'getpaid_delete_customer', $customer );
175
+
176
+        $customer->set_id( 0 );
177
+    }
178
+
179
+    /*
180 180
 	|--------------------------------------------------------------------------
181 181
 	| Additional Methods
182 182
 	|--------------------------------------------------------------------------
183 183
 	*/
184
-	public static function get_database_fields() {
185
-
186
-		$fields = array(
187
-			'id'             => '%d',
188
-			'user_id'        => '%d',
189
-			'email'          => '%s',
190
-			'email_cc'       => '%s',
191
-			'status'         => '%s',
192
-			'purchase_value' => '%f',
193
-			'purchase_count' => '%d',
194
-			'date_created'   => '%s',
195
-			'date_modified'  => '%s',
196
-			'uuid'           => '%s',
197
-		);
198
-
199
-		// Add address fields.
200
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
201
-
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';
205
-			}
206
-		}
207
-
208
-		return $fields;
209
-	}
184
+    public static function get_database_fields() {
185
+
186
+        $fields = array(
187
+            'id'             => '%d',
188
+            'user_id'        => '%d',
189
+            'email'          => '%s',
190
+            'email_cc'       => '%s',
191
+            'status'         => '%s',
192
+            'purchase_value' => '%f',
193
+            'purchase_count' => '%d',
194
+            'date_created'   => '%s',
195
+            'date_modified'  => '%s',
196
+            'uuid'           => '%s',
197
+        );
198
+
199
+        // Add address fields.
200
+        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
201
+
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';
205
+            }
206
+        }
207
+
208
+        return $fields;
209
+    }
210 210
 }
Please login to merge, or discard this 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.
includes/class-getpaid-customer.php 2 patches
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -15,69 +15,69 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Customer extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23 23
     protected $data_store_name = 'customer';
24 24
 
25 25
     /**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'customer';
31
-
32
-	/**
33
-	 * Get the customer if ID is passed, otherwise the customer is new and empty.
34
-	 *
35
-	 * @param int|string|GetPaid_Customer|object $customer customer id, object, or email.
36
-	 */
37
-	public function __construct( $customer = 0 ) {
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'customer';
31
+
32
+    /**
33
+     * Get the customer if ID is passed, otherwise the customer is new and empty.
34
+     *
35
+     * @param int|string|GetPaid_Customer|object $customer customer id, object, or email.
36
+     */
37
+    public function __construct( $customer = 0 ) {
38 38
 
39 39
         // Setup default customer data.
40 40
         $this->setup_default_data();
41 41
 
42
-		if ( is_numeric( $customer ) ) {
43
-			$this->set_id( $customer );
44
-		} elseif ( $customer instanceof self ) {
45
-			$this->set_id( $customer->get_id() );
46
-		} elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
-			$this->set_id( $customer_id );
48
-		} elseif ( ! empty( $customer->id ) ) {
49
-			$this->set_id( $customer->id );
50
-		}
42
+        if ( is_numeric( $customer ) ) {
43
+            $this->set_id( $customer );
44
+        } elseif ( $customer instanceof self ) {
45
+            $this->set_id( $customer->get_id() );
46
+        } elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
+            $this->set_id( $customer_id );
48
+        } elseif ( ! empty( $customer->id ) ) {
49
+            $this->set_id( $customer->id );
50
+        }
51 51
 
52 52
         // Load the datastore.
53
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
53
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
54 54
 
55
-		if ( $this->get_id() > 0 ) {
56
-			$this->data_store->read( $this );
55
+        if ( $this->get_id() > 0 ) {
56
+            $this->data_store->read( $this );
57 57
         }
58 58
 
59 59
         $this->set_object_read( true );
60
-	}
60
+    }
61 61
 
62 62
     /**
63
-	 * Sets up default customer data.
64
-	 */
65
-	private function setup_default_data() {
63
+     * Sets up default customer data.
64
+     */
65
+    private function setup_default_data() {
66 66
 
67 67
         $this->data = array(
68
-			'user_id'        => 0,
69
-			'email'          => '',
70
-			'email_cc'       => '',
71
-			'status'         => 'active',
72
-			'purchase_value' => 0,
73
-			'purchase_count' => 0,
74
-			'date_created'   => current_time( 'mysql' ),
75
-			'date_modified'  => current_time( 'mysql' ),
76
-			'uuid'           => wp_generate_uuid4(),
77
-		);
68
+            'user_id'        => 0,
69
+            'email'          => '',
70
+            'email_cc'       => '',
71
+            'status'         => 'active',
72
+            'purchase_value' => 0,
73
+            'purchase_count' => 0,
74
+            'date_created'   => current_time( 'mysql' ),
75
+            'date_modified'  => current_time( 'mysql' ),
76
+            'uuid'           => wp_generate_uuid4(),
77
+        );
78 78
 
79 79
         // Add address fields.
80
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
80
+        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
81 81
 
82 82
             if ( isset( $this->data[ $field ] ) ) {
83 83
                 continue;
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
                 continue;
96 96
             }
97 97
 
98
-			$this->data[ $field ] = '';
99
-		}
98
+            $this->data[ $field ] = '';
99
+        }
100 100
 
101 101
         $this->default_data = $this->data;
102
-	}
103
-
104
-	/**
105
-	 * Given a customer email or user id, it returns a customer id.
106
-	 *
107
-	 * @static
108
-	 * @param string $value
109
-	 * @since 1.0.15
110
-	 * @return int
111
-	 */
112
-	public static function get_customer_id_by( $value, $by = 'email' ) {
113
-		global $wpdb;
102
+    }
103
+
104
+    /**
105
+     * Given a customer email or user id, it returns a customer id.
106
+     *
107
+     * @static
108
+     * @param string $value
109
+     * @since 1.0.15
110
+     * @return int
111
+     */
112
+    public static function get_customer_id_by( $value, $by = 'email' ) {
113
+        global $wpdb;
114 114
 
115 115
         // Prepare value.
116 116
         if ( 'email' === $by ) {
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
             return 0;
126 126
         }
127 127
 
128
-		// Maybe retrieve from the cache.
128
+        // Maybe retrieve from the cache.
129 129
         $cache_key   = 'getpaid_customer_ids_by_' . $by;
130
-		$customer_id = wp_cache_get( $value, $cache_key );
131
-		if ( false !== $customer_id ) {
132
-			return $customer_id;
133
-		}
130
+        $customer_id = wp_cache_get( $value, $cache_key );
131
+        if ( false !== $customer_id ) {
132
+            return $customer_id;
133
+        }
134 134
 
135 135
         if ( 'email' === $by ) {
136 136
             $customer_id = (int) $wpdb->get_var(
@@ -142,23 +142,23 @@  discard block
 block discarded – undo
142 142
             );
143 143
         }
144 144
 
145
-		// Update the cache with our data
146
-		wp_cache_set( $value, $customer_id, $cache_key );
145
+        // Update the cache with our data
146
+        wp_cache_set( $value, $customer_id, $cache_key );
147 147
 
148
-		return $customer_id;
148
+        return $customer_id;
149 149
 
150
-	}
150
+    }
151 151
 
152
-	/**
152
+    /**
153 153
      * Clears the customer's cache.
154 154
      */
155 155
     public function clear_cache() {
156 156
         wp_cache_delete( $this->get( 'email' ), 'getpaid_customer_ids_by_email' );
157 157
         wp_cache_delete( $this->get( 'user_id' ), 'getpaid_customer_ids_by_user_id' );
158
-		wp_cache_delete( $this->get_id(), 'getpaid_customers' );
159
-	}
158
+        wp_cache_delete( $this->get_id(), 'getpaid_customers' );
159
+    }
160 160
 
161
-	/*
161
+    /*
162 162
 	|--------------------------------------------------------------------------
163 163
 	| CRUD methods
164 164
 	|--------------------------------------------------------------------------
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
             return call_user_func( array( $this, 'get_' . $key ), $context );
190 190
         }
191 191
 
192
-		return $this->get_prop( $key, $context );
192
+        return $this->get_prop( $key, $context );
193 193
 
194 194
     }
195 195
 
196
-	/*
196
+    /*
197 197
 	|--------------------------------------------------------------------------
198 198
 	| Setters
199 199
 	|--------------------------------------------------------------------------
@@ -216,114 +216,114 @@  discard block
 block discarded – undo
216 216
             return call_user_func( array( $this, 'set_' . $key ), $value );
217 217
         }
218 218
 
219
-		return $this->set_prop( $key, $value );
219
+        return $this->set_prop( $key, $value );
220 220
 
221 221
     }
222 222
 
223
-	/**
224
-	 * Sets customer status.
225
-	 *
226
-	 * @since 1.0.0
227
-	 * @param  string $status New status.
228
-	 */
229
-	public function set_status( $status ) {
230
-
231
-		if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
232
-			return $this->set_prop( 'status', $status );
233
-		}
234
-
235
-		$this->set_prop( 'status', 'inactive' );
236
-	}
237
-
238
-	/**
239
-	 * Sets the purchase value.
240
-	 *
241
-	 * @since 1.0.0
242
-	 * @param float $purchase_value.
243
-	 */
244
-	public function set_purchase_value( $purchase_value ) {
245
-		$this->set_prop( 'purchase_value', (float) $purchase_value );
246
-	}
223
+    /**
224
+     * Sets customer status.
225
+     *
226
+     * @since 1.0.0
227
+     * @param  string $status New status.
228
+     */
229
+    public function set_status( $status ) {
230
+
231
+        if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
232
+            return $this->set_prop( 'status', $status );
233
+        }
234
+
235
+        $this->set_prop( 'status', 'inactive' );
236
+    }
237
+
238
+    /**
239
+     * Sets the purchase value.
240
+     *
241
+     * @since 1.0.0
242
+     * @param float $purchase_value.
243
+     */
244
+    public function set_purchase_value( $purchase_value ) {
245
+        $this->set_prop( 'purchase_value', (float) $purchase_value );
246
+    }
247 247
 
248 248
     /**
249
-	 * Sets the purchase count.
250
-	 *
251
-	 * @since 1.0.0
252
-	 * @param int $purchase_count.
253
-	 */
254
-	public function set_purchase_count( $purchase_count ) {
255
-		$this->set_prop( 'purchase_count', absint( $purchase_count ) );
256
-	}
249
+     * Sets the purchase count.
250
+     *
251
+     * @since 1.0.0
252
+     * @param int $purchase_count.
253
+     */
254
+    public function set_purchase_count( $purchase_count ) {
255
+        $this->set_prop( 'purchase_count', absint( $purchase_count ) );
256
+    }
257 257
 
258 258
     /**
259
-	 * Sets the user id.
260
-	 *
261
-	 * @since 1.0.0
262
-	 * @param int $user_id.
263
-	 */
264
-	public function set_user_id( $user_id ) {
265
-		$this->set_prop( 'user_id', absint( $user_id ) );
266
-	}
259
+     * Sets the user id.
260
+     *
261
+     * @since 1.0.0
262
+     * @param int $user_id.
263
+     */
264
+    public function set_user_id( $user_id ) {
265
+        $this->set_prop( 'user_id', absint( $user_id ) );
266
+    }
267 267
 
268 268
     /**
269
-	 * Sets the email.
270
-	 *
271
-	 * @since 1.0.0
272
-	 * @param string $email.
273
-	 */
274
-	public function set_email( $email ) {
269
+     * Sets the email.
270
+     *
271
+     * @since 1.0.0
272
+     * @param string $email.
273
+     */
274
+    public function set_email( $email ) {
275 275
         $email = is_string( $email ) ? sanitize_email( $email ) : '';
276
-		$this->set_prop( 'email', $email );
277
-	}
276
+        $this->set_prop( 'email', $email );
277
+    }
278 278
 
279 279
     /**
280
-	 * Sets the email cc.
281
-	 *
282
-	 * @since 1.0.0
283
-	 * @param string $email_cc.
284
-	 */
285
-	public function set_email_cc( $email_cc ) {
280
+     * Sets the email cc.
281
+     *
282
+     * @since 1.0.0
283
+     * @param string $email_cc.
284
+     */
285
+    public function set_email_cc( $email_cc ) {
286 286
         $email_cc = implode( ', ', wp_parse_list( $email_cc ) );
287
-		$this->set_prop( 'email_cc', $email_cc );
288
-	}
287
+        $this->set_prop( 'email_cc', $email_cc );
288
+    }
289 289
 
290 290
     /**
291
-	 * Sets the created date.
292
-	 *
293
-	 * @since 1.0.0
294
-	 * @param  string $date_created date created.
295
-	 */
296
-	public function set_date_created( $date_created ) {
291
+     * Sets the created date.
292
+     *
293
+     * @since 1.0.0
294
+     * @param  string $date_created date created.
295
+     */
296
+    public function set_date_created( $date_created ) {
297 297
 
298
-		$date = strtotime( $date_created );
298
+        $date = strtotime( $date_created );
299 299
 
300 300
         if ( $date && $date_created !== '0000-00-00 00:00:00'  && $date_created !== '0000-00-00 00:00' ) {
301 301
             $this->set_prop( 'date_created', gmdate( 'Y-m-d H:i:s', $date ) );
302 302
             return;
303
-		}
303
+        }
304 304
 
305
-		$this->set_prop( 'date_created', null );
306
-	}
305
+        $this->set_prop( 'date_created', null );
306
+    }
307 307
 
308 308
     /**
309
-	 * Sets the created date.
310
-	 *
311
-	 * @since 1.0.0
312
-	 * @param  string $date_modified date created.
313
-	 */
314
-	public function set_date_modified( $date_modified ) {
309
+     * Sets the created date.
310
+     *
311
+     * @since 1.0.0
312
+     * @param  string $date_modified date created.
313
+     */
314
+    public function set_date_modified( $date_modified ) {
315 315
 
316
-		$date = strtotime( $date_modified );
316
+        $date = strtotime( $date_modified );
317 317
 
318 318
         if ( $date && $date_modified !== '0000-00-00 00:00:00'  && $date_modified !== '0000-00-00 00:00' ) {
319 319
             $this->set_prop( 'date_modified', gmdate( 'Y-m-d H:i:s', $date ) );
320 320
             return;
321
-		}
321
+        }
322 322
 
323
-		$this->set_prop( 'date_modified', null );
324
-	}
323
+        $this->set_prop( 'date_modified', null );
324
+    }
325 325
 
326
-	/*
326
+    /*
327 327
 	|--------------------------------------------------------------------------
328 328
 	| Additional methods
329 329
 	|--------------------------------------------------------------------------
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 	|
333 333
 	*/
334 334
 
335
-	/**
336
-	 * Saves the customer.
337
-	 *
338
-	 * @since 1.0.0
339
-	 */
340
-	public function save() {
335
+    /**
336
+     * Saves the customer.
337
+     *
338
+     * @since 1.0.0
339
+     */
340
+    public function save() {
341 341
 
342 342
         $maybe_set = array(
343 343
             'uuid'         => wp_generate_uuid4(),
@@ -354,29 +354,29 @@  discard block
 block discarded – undo
354 354
 
355 355
         $this->set( 'date_modified', current_time( 'mysql' ) );
356 356
 
357
-		return parent::save();
358
-	}
357
+        return parent::save();
358
+    }
359 359
 
360 360
     /**
361
-	 * Helper method to clone a customer from a user ID.
362
-	 *
363
-	 * @since 1.0.0
364
-	 * @param int $user_id.
365
-	 */
366
-	public function clone_user( $user_id ) {
361
+     * Helper method to clone a customer from a user ID.
362
+     *
363
+     * @since 1.0.0
364
+     * @param int $user_id.
365
+     */
366
+    public function clone_user( $user_id ) {
367 367
         $user = get_userdata( $user_id );
368 368
 
369 369
         if ( empty( $user ) ) {
370 370
             return;
371 371
         }
372 372
 
373
-		$this->set_user_id( $user->ID );
373
+        $this->set_user_id( $user->ID );
374 374
         $this->set_email( $user->user_email );
375 375
         $this->set_purchase_value( getpaid_get_user_total_spend( $user->ID ) );
376 376
         $this->set_purchase_count( getpaid_count_user_invoices( $user->ID ) );
377 377
         $this->set( 'first_name', $user->first_name );
378 378
         $this->set( 'last_name', $user->last_name );
379
-		$this->set_date_created( $user->user_registered );
379
+        $this->set_date_created( $user->user_registered );
380 380
 
381 381
         // Fetch extra data from WC or old GetPaid.
382 382
         $prefixes = array(
@@ -400,18 +400,18 @@  discard block
 block discarded – undo
400 400
                     continue;
401 401
                 }
402 402
             }
403
-		}
404
-	}
403
+        }
404
+    }
405 405
 
406 406
     /**
407
-	 * Helper method to migrate an existing user ID to the new customers table.
408
-	 *
409
-	 * @since 1.0.0
410
-	 * @param int $user_id.
411
-	 */
412
-	public function migrate_from_user( $user_id ) {
407
+     * Helper method to migrate an existing user ID to the new customers table.
408
+     *
409
+     * @since 1.0.0
410
+     * @param int $user_id.
411
+     */
412
+    public function migrate_from_user( $user_id ) {
413 413
         $this->clone_user( $user_id );
414 414
         do_action( 'getpaid_customer_migrated_from_user', $this, $user_id );
415 415
         $this->save();
416
-	}
416
+    }
417 417
 }
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @since   1.0.15
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Customer class.
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param int|string|GetPaid_Customer|object $customer customer id, object, or email.
36 36
 	 */
37
-	public function __construct( $customer = 0 ) {
37
+	public function __construct($customer = 0) {
38 38
 
39 39
         // Setup default customer data.
40 40
         $this->setup_default_data();
41 41
 
42
-		if ( is_numeric( $customer ) ) {
43
-			$this->set_id( $customer );
44
-		} elseif ( $customer instanceof self ) {
45
-			$this->set_id( $customer->get_id() );
46
-		} elseif ( is_string( $customer ) && $customer_id = self::get_customer_id_by( $customer, 'email' ) ) {
47
-			$this->set_id( $customer_id );
48
-		} elseif ( ! empty( $customer->id ) ) {
49
-			$this->set_id( $customer->id );
42
+		if (is_numeric($customer)) {
43
+			$this->set_id($customer);
44
+		} elseif ($customer instanceof self) {
45
+			$this->set_id($customer->get_id());
46
+		} elseif (is_string($customer) && $customer_id = self::get_customer_id_by($customer, 'email')) {
47
+			$this->set_id($customer_id);
48
+		} elseif (!empty($customer->id)) {
49
+			$this->set_id($customer->id);
50 50
 		}
51 51
 
52 52
         // Load the datastore.
53
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
53
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
54 54
 
55
-		if ( $this->get_id() > 0 ) {
56
-			$this->data_store->read( $this );
55
+		if ($this->get_id() > 0) {
56
+			$this->data_store->read($this);
57 57
         }
58 58
 
59
-        $this->set_object_read( true );
59
+        $this->set_object_read(true);
60 60
 	}
61 61
 
62 62
     /**
@@ -71,31 +71,31 @@  discard block
 block discarded – undo
71 71
 			'status'         => 'active',
72 72
 			'purchase_value' => 0,
73 73
 			'purchase_count' => 0,
74
-			'date_created'   => current_time( 'mysql' ),
75
-			'date_modified'  => current_time( 'mysql' ),
74
+			'date_created'   => current_time('mysql'),
75
+			'date_modified'  => current_time('mysql'),
76 76
 			'uuid'           => wp_generate_uuid4(),
77 77
 		);
78 78
 
79 79
         // Add address fields.
80
-		foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
80
+		foreach (array_keys(getpaid_user_address_fields()) as $field) {
81 81
 
82
-            if ( isset( $this->data[ $field ] ) ) {
82
+            if (isset($this->data[$field])) {
83 83
                 continue;
84 84
             }
85 85
 
86 86
             // Country.
87
-            if ( 'country' === $field ) {
88
-                $this->data[ $field ] = wpinv_get_default_country();
87
+            if ('country' === $field) {
88
+                $this->data[$field] = wpinv_get_default_country();
89 89
                 continue;
90 90
             }
91 91
 
92 92
             // State.
93
-            if ( 'state' === $field ) {
94
-                $this->data[ $field ] = wpinv_get_default_state();
93
+            if ('state' === $field) {
94
+                $this->data[$field] = wpinv_get_default_state();
95 95
                 continue;
96 96
             }
97 97
 
98
-			$this->data[ $field ] = '';
98
+			$this->data[$field] = '';
99 99
 		}
100 100
 
101 101
         $this->default_data = $this->data;
@@ -109,41 +109,41 @@  discard block
 block discarded – undo
109 109
 	 * @since 1.0.15
110 110
 	 * @return int
111 111
 	 */
112
-	public static function get_customer_id_by( $value, $by = 'email' ) {
112
+	public static function get_customer_id_by($value, $by = 'email') {
113 113
 		global $wpdb;
114 114
 
115 115
         // Prepare value.
116
-        if ( 'email' === $by ) {
117
-            $value = sanitize_email( $value );
118
-        } elseif ( 'user_id' === $by ) {
119
-            $value = absint( $value );
116
+        if ('email' === $by) {
117
+            $value = sanitize_email($value);
118
+        } elseif ('user_id' === $by) {
119
+            $value = absint($value);
120 120
         } else {
121 121
             return 0;
122 122
         }
123 123
 
124
-        if ( empty( $value ) ) {
124
+        if (empty($value)) {
125 125
             return 0;
126 126
         }
127 127
 
128 128
 		// Maybe retrieve from the cache.
129
-        $cache_key   = 'getpaid_customer_ids_by_' . $by;
130
-		$customer_id = wp_cache_get( $value, $cache_key );
131
-		if ( false !== $customer_id ) {
129
+        $cache_key = 'getpaid_customer_ids_by_' . $by;
130
+		$customer_id = wp_cache_get($value, $cache_key);
131
+		if (false !== $customer_id) {
132 132
 			return $customer_id;
133 133
 		}
134 134
 
135
-        if ( 'email' === $by ) {
135
+        if ('email' === $by) {
136 136
             $customer_id = (int) $wpdb->get_var(
137
-                $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE email=%s LIMIT 1", $value )
137
+                $wpdb->prepare("SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE email=%s LIMIT 1", $value)
138 138
             );
139
-        } elseif ( 'user_id' === $by ) {
139
+        } elseif ('user_id' === $by) {
140 140
             $customer_id = (int) $wpdb->get_var(
141
-                $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE user_id=%d LIMIT 1", $value )
141
+                $wpdb->prepare("SELECT id FROM {$wpdb->prefix}getpaid_customers WHERE user_id=%d LIMIT 1", $value)
142 142
             );
143 143
         }
144 144
 
145 145
 		// Update the cache with our data
146
-		wp_cache_set( $value, $customer_id, $cache_key );
146
+		wp_cache_set($value, $customer_id, $cache_key);
147 147
 
148 148
 		return $customer_id;
149 149
 
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
      * Clears the customer's cache.
154 154
      */
155 155
     public function clear_cache() {
156
-        wp_cache_delete( $this->get( 'email' ), 'getpaid_customer_ids_by_email' );
157
-        wp_cache_delete( $this->get( 'user_id' ), 'getpaid_customer_ids_by_user_id' );
158
-		wp_cache_delete( $this->get_id(), 'getpaid_customers' );
156
+        wp_cache_delete($this->get('email'), 'getpaid_customer_ids_by_email');
157
+        wp_cache_delete($this->get('user_id'), 'getpaid_customer_ids_by_user_id');
158
+		wp_cache_delete($this->get_id(), 'getpaid_customers');
159 159
 	}
160 160
 
161 161
 	/*
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
      * @param  string $key The key to fetch.
180 180
      * @param  string $context View or edit context.
181 181
      */
182
-    public function get( $key, $context = 'view' ) {
182
+    public function get($key, $context = 'view') {
183 183
 
184 184
         // Maybe strip _wpinv_ prefix from key.
185
-        $key = str_replace( '_wpinv_', '', $key );
185
+        $key = str_replace('_wpinv_', '', $key);
186 186
 
187 187
         // Check if we have a helper method for that.
188
-        if ( method_exists( $this, 'get_' . $key ) ) {
189
-            return call_user_func( array( $this, 'get_' . $key ), $context );
188
+        if (method_exists($this, 'get_' . $key)) {
189
+            return call_user_func(array($this, 'get_' . $key), $context);
190 190
         }
191 191
 
192
-		return $this->get_prop( $key, $context );
192
+		return $this->get_prop($key, $context);
193 193
 
194 194
     }
195 195
 
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
      * @param string $key The key to fetch.
210 210
      * @param mixed $value The new value.
211 211
      */
212
-    public function set( $key, $value ) {
212
+    public function set($key, $value) {
213 213
 
214 214
         // Check if we have a helper method for that.
215
-        if ( method_exists( $this, 'set_' . $key ) ) {
216
-            return call_user_func( array( $this, 'set_' . $key ), $value );
215
+        if (method_exists($this, 'set_' . $key)) {
216
+            return call_user_func(array($this, 'set_' . $key), $value);
217 217
         }
218 218
 
219
-		return $this->set_prop( $key, $value );
219
+		return $this->set_prop($key, $value);
220 220
 
221 221
     }
222 222
 
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
 	 * @since 1.0.0
227 227
 	 * @param  string $status New status.
228 228
 	 */
229
-	public function set_status( $status ) {
229
+	public function set_status($status) {
230 230
 
231
-		if ( in_array( $status, array( 'active', 'inactive', 'blocked' ), true ) ) {
232
-			return $this->set_prop( 'status', $status );
231
+		if (in_array($status, array('active', 'inactive', 'blocked'), true)) {
232
+			return $this->set_prop('status', $status);
233 233
 		}
234 234
 
235
-		$this->set_prop( 'status', 'inactive' );
235
+		$this->set_prop('status', 'inactive');
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * @since 1.0.0
242 242
 	 * @param float $purchase_value.
243 243
 	 */
244
-	public function set_purchase_value( $purchase_value ) {
245
-		$this->set_prop( 'purchase_value', (float) $purchase_value );
244
+	public function set_purchase_value($purchase_value) {
245
+		$this->set_prop('purchase_value', (float) $purchase_value);
246 246
 	}
247 247
 
248 248
     /**
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	 * @since 1.0.0
252 252
 	 * @param int $purchase_count.
253 253
 	 */
254
-	public function set_purchase_count( $purchase_count ) {
255
-		$this->set_prop( 'purchase_count', absint( $purchase_count ) );
254
+	public function set_purchase_count($purchase_count) {
255
+		$this->set_prop('purchase_count', absint($purchase_count));
256 256
 	}
257 257
 
258 258
     /**
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 * @since 1.0.0
262 262
 	 * @param int $user_id.
263 263
 	 */
264
-	public function set_user_id( $user_id ) {
265
-		$this->set_prop( 'user_id', absint( $user_id ) );
264
+	public function set_user_id($user_id) {
265
+		$this->set_prop('user_id', absint($user_id));
266 266
 	}
267 267
 
268 268
     /**
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 	 * @since 1.0.0
272 272
 	 * @param string $email.
273 273
 	 */
274
-	public function set_email( $email ) {
275
-        $email = is_string( $email ) ? sanitize_email( $email ) : '';
276
-		$this->set_prop( 'email', $email );
274
+	public function set_email($email) {
275
+        $email = is_string($email) ? sanitize_email($email) : '';
276
+		$this->set_prop('email', $email);
277 277
 	}
278 278
 
279 279
     /**
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 	 * @since 1.0.0
283 283
 	 * @param string $email_cc.
284 284
 	 */
285
-	public function set_email_cc( $email_cc ) {
286
-        $email_cc = implode( ', ', wp_parse_list( $email_cc ) );
287
-		$this->set_prop( 'email_cc', $email_cc );
285
+	public function set_email_cc($email_cc) {
286
+        $email_cc = implode(', ', wp_parse_list($email_cc));
287
+		$this->set_prop('email_cc', $email_cc);
288 288
 	}
289 289
 
290 290
     /**
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
 	 * @since 1.0.0
294 294
 	 * @param  string $date_created date created.
295 295
 	 */
296
-	public function set_date_created( $date_created ) {
296
+	public function set_date_created($date_created) {
297 297
 
298
-		$date = strtotime( $date_created );
298
+		$date = strtotime($date_created);
299 299
 
300
-        if ( $date && $date_created !== '0000-00-00 00:00:00'  && $date_created !== '0000-00-00 00:00' ) {
301
-            $this->set_prop( 'date_created', gmdate( 'Y-m-d H:i:s', $date ) );
300
+        if ($date && $date_created !== '0000-00-00 00:00:00' && $date_created !== '0000-00-00 00:00') {
301
+            $this->set_prop('date_created', gmdate('Y-m-d H:i:s', $date));
302 302
             return;
303 303
 		}
304 304
 
305
-		$this->set_prop( 'date_created', null );
305
+		$this->set_prop('date_created', null);
306 306
 	}
307 307
 
308 308
     /**
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
 	 * @since 1.0.0
312 312
 	 * @param  string $date_modified date created.
313 313
 	 */
314
-	public function set_date_modified( $date_modified ) {
314
+	public function set_date_modified($date_modified) {
315 315
 
316
-		$date = strtotime( $date_modified );
316
+		$date = strtotime($date_modified);
317 317
 
318
-        if ( $date && $date_modified !== '0000-00-00 00:00:00'  && $date_modified !== '0000-00-00 00:00' ) {
319
-            $this->set_prop( 'date_modified', gmdate( 'Y-m-d H:i:s', $date ) );
318
+        if ($date && $date_modified !== '0000-00-00 00:00:00' && $date_modified !== '0000-00-00 00:00') {
319
+            $this->set_prop('date_modified', gmdate('Y-m-d H:i:s', $date));
320 320
             return;
321 321
 		}
322 322
 
323
-		$this->set_prop( 'date_modified', null );
323
+		$this->set_prop('date_modified', null);
324 324
 	}
325 325
 
326 326
 	/*
@@ -341,18 +341,18 @@  discard block
 block discarded – undo
341 341
 
342 342
         $maybe_set = array(
343 343
             'uuid'         => wp_generate_uuid4(),
344
-            'date_created' => current_time( 'mysql' ),
344
+            'date_created' => current_time('mysql'),
345 345
         );
346 346
 
347
-        foreach ( $maybe_set as $key => $value ) {
348
-            $current_value = $this->get( $key );
347
+        foreach ($maybe_set as $key => $value) {
348
+            $current_value = $this->get($key);
349 349
 
350
-            if ( empty( $current_value ) ) {
351
-                $this->set( $key, $value );
350
+            if (empty($current_value)) {
351
+                $this->set($key, $value);
352 352
             }
353 353
         }
354 354
 
355
-        $this->set( 'date_modified', current_time( 'mysql' ) );
355
+        $this->set('date_modified', current_time('mysql'));
356 356
 
357 357
 		return parent::save();
358 358
 	}
@@ -363,20 +363,20 @@  discard block
 block discarded – undo
363 363
 	 * @since 1.0.0
364 364
 	 * @param int $user_id.
365 365
 	 */
366
-	public function clone_user( $user_id ) {
367
-        $user = get_userdata( $user_id );
366
+	public function clone_user($user_id) {
367
+        $user = get_userdata($user_id);
368 368
 
369
-        if ( empty( $user ) ) {
369
+        if (empty($user)) {
370 370
             return;
371 371
         }
372 372
 
373
-		$this->set_user_id( $user->ID );
374
-        $this->set_email( $user->user_email );
375
-        $this->set_purchase_value( getpaid_get_user_total_spend( $user->ID ) );
376
-        $this->set_purchase_count( getpaid_count_user_invoices( $user->ID ) );
377
-        $this->set( 'first_name', $user->first_name );
378
-        $this->set( 'last_name', $user->last_name );
379
-		$this->set_date_created( $user->user_registered );
373
+		$this->set_user_id($user->ID);
374
+        $this->set_email($user->user_email);
375
+        $this->set_purchase_value(getpaid_get_user_total_spend($user->ID));
376
+        $this->set_purchase_count(getpaid_count_user_invoices($user->ID));
377
+        $this->set('first_name', $user->first_name);
378
+        $this->set('last_name', $user->last_name);
379
+		$this->set_date_created($user->user_registered);
380 380
 
381 381
         // Fetch extra data from WC or old GetPaid.
382 382
         $prefixes = array(
@@ -385,18 +385,18 @@  discard block
 block discarded – undo
385 385
             '',
386 386
         );
387 387
 
388
-        foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
388
+        foreach (array_keys(getpaid_user_address_fields()) as $field) {
389 389
 
390
-            foreach ( $prefixes as $prefix ) {
390
+            foreach ($prefixes as $prefix) {
391 391
 
392 392
                 // Meta table.
393
-                $value = get_user_meta( $user_id, $prefix . $field, true );
393
+                $value = get_user_meta($user_id, $prefix . $field, true);
394 394
 
395 395
                 // UWP table.
396
-                $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
396
+                $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
397 397
 
398
-                if ( ! empty( $value ) ) {
399
-                    $this->set( $field, $value );
398
+                if (!empty($value)) {
399
+                    $this->set($field, $value);
400 400
                     continue;
401 401
                 }
402 402
             }
@@ -409,9 +409,9 @@  discard block
 block discarded – undo
409 409
 	 * @since 1.0.0
410 410
 	 * @param int $user_id.
411 411
 	 */
412
-	public function migrate_from_user( $user_id ) {
413
-        $this->clone_user( $user_id );
414
-        do_action( 'getpaid_customer_migrated_from_user', $this, $user_id );
412
+	public function migrate_from_user($user_id) {
413
+        $this->clone_user($user_id);
414
+        do_action('getpaid_customer_migrated_from_user', $this, $user_id);
415 415
         $this->save();
416 416
 	}
417 417
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 2 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
78
-		$refund_url = wp_nonce_url(
79
-			add_query_arg(
80
-				array(
81
-					'getpaid-admin-action' => 'refund_invoice',
82
-					'invoice_id'           => $invoice->get_id(),
83
-				)
84
-			),
85
-			'getpaid-nonce',
86
-			'getpaid-nonce'
87
-		);
78
+        $refund_url = wp_nonce_url(
79
+            add_query_arg(
80
+                array(
81
+                    'getpaid-admin-action' => 'refund_invoice',
82
+                    'invoice_id'           => $invoice->get_id(),
83
+                )
84
+            ),
85
+            'getpaid-nonce',
86
+            'getpaid-nonce'
87
+        );
88 88
     ?>
89 89
 
90 90
         <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
                             <th class="
97 97
                             <?php
98 98
                             echo esc_attr( $key );
99
-							echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '';
100
-							?>
99
+                            echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '';
100
+                            ?>
101 101
 							"><?php echo wp_kses_post( $label ); ?></th>
102 102
                         <?php endforeach; ?>
103 103
                     </tr>
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
                 <tbody class="wpinv-line-items">
107 107
                     <?php
108 108
                         foreach ( $invoice->get_items() as $int => $item ) {
109
-						self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
109
+                        self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
110 110
                         }
111 111
                     ?>
112 112
                 </tbody>
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
                                                         <?php
152 152
                                                         wpinv_html_select(
153 153
                                                             array(
154
-																'options'          => $item_types,
155
-																'name'             => '_wpinv_quick[type]',
156
-																'id'               => '_wpinv_quick_type',
157
-																'selected'         => 'custom',
158
-																'show_option_all'  => false,
159
-																'show_option_none' => false,
160
-																'class'            => 'gdmbx2-text-medium wpinv-quick-type',
154
+                                                                'options'          => $item_types,
155
+                                                                'name'             => '_wpinv_quick[type]',
156
+                                                                'id'               => '_wpinv_quick_type',
157
+                                                                'selected'         => 'custom',
158
+                                                                'show_option_all'  => false,
159
+                                                                'show_option_none' => false,
160
+                                                                'class'            => 'gdmbx2-text-medium wpinv-quick-type',
161 161
                                                             )
162 162
                                                         );
163 163
                                                             ?>
@@ -172,16 +172,16 @@  discard block
 block discarded – undo
172 172
                                                             <?php
173 173
                                                                 wpinv_html_select(
174 174
                                                                     array(
175
-																		'options'          => array_merge(
176
-																			array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
177
-																			getpaid_get_tax_rules()
178
-																		),
179
-																		'name'             => '_wpinv_quick[vat_rule]',
180
-																		'id'               => '_wpinv_quick_vat_rule',
181
-																		'show_option_all'  => false,
182
-																		'show_option_none' => false,
183
-																		'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
184
-																		'selected'         => 'digital',
175
+                                                                        'options'          => array_merge(
176
+                                                                            array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
177
+                                                                            getpaid_get_tax_rules()
178
+                                                                        ),
179
+                                                                        'name'             => '_wpinv_quick[vat_rule]',
180
+                                                                        'id'               => '_wpinv_quick_vat_rule',
181
+                                                                        'show_option_all'  => false,
182
+                                                                        'show_option_none' => false,
183
+                                                                        'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
184
+                                                                        'selected'         => 'digital',
185 185
                                                                     )
186 186
                                                                 );
187 187
                                                             ?>
@@ -194,16 +194,16 @@  discard block
 block discarded – undo
194 194
                                                             <?php
195 195
                                                                 wpinv_html_select(
196 196
                                                                     array(
197
-																		'options'          => array_merge(
198
-																			array( '' => __( 'Select VAT Class', 'invoicing' ) ),
199
-																			getpaid_get_tax_classes()
200
-																		),
201
-																		'name'             => '_wpinv_quick[vat_class]',
202
-																		'id'               => '_wpinv_quick_vat_class',
203
-																		'show_option_all'  => false,
204
-																		'show_option_none' => false,
205
-																		'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
206
-																		'selected'         => '_standard',
197
+                                                                        'options'          => array_merge(
198
+                                                                            array( '' => __( 'Select VAT Class', 'invoicing' ) ),
199
+                                                                            getpaid_get_tax_classes()
200
+                                                                        ),
201
+                                                                        'name'             => '_wpinv_quick[vat_class]',
202
+                                                                        'id'               => '_wpinv_quick_vat_class',
203
+                                                                        'show_option_all'  => false,
204
+                                                                        'show_option_none' => false,
205
+                                                                        'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
206
+                                                                        'selected'         => '_standard',
207 207
                                                                     )
208 208
                                                                 );
209 209
                                                             ?>
@@ -294,37 +294,37 @@  discard block
 block discarded – undo
294 294
 								</p>
295 295
 								<?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?>
296 296
 									<?php
297
-										aui()->input(
298
-											array(
299
-												'type'  => 'checkbox',
300
-												'name'  => 'getpaid_refund_remote',
301
-												'id'    => 'getpaid_refund_remote',
302
-												'label' => sprintf(
303
-													'Refund payment in %s',
304
-													wpinv_get_gateway_admin_label( $invoice->get_gateway() )
305
-												),
306
-												'value' => 1,
307
-												'class' => 'getpaid-refund-field',
308
-											),
309
-											true
310
-										);
311
-									?>
297
+                                        aui()->input(
298
+                                            array(
299
+                                                'type'  => 'checkbox',
300
+                                                'name'  => 'getpaid_refund_remote',
301
+                                                'id'    => 'getpaid_refund_remote',
302
+                                                'label' => sprintf(
303
+                                                    'Refund payment in %s',
304
+                                                    wpinv_get_gateway_admin_label( $invoice->get_gateway() )
305
+                                                ),
306
+                                                'value' => 1,
307
+                                                'class' => 'getpaid-refund-field',
308
+                                            ),
309
+                                            true
310
+                                        );
311
+                                    ?>
312 312
 								<?php endif; ?>
313 313
 
314 314
 								<?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?>
315 315
 									<?php
316
-										aui()->input(
317
-											array(
318
-												'type'  => 'checkbox',
319
-												'name'  => 'getpaid_cancel_subscription',
320
-												'id'    => 'getpaid_cancel_subscription',
321
-												'label' => __( 'Cancel subscription', 'invoicing' ),
322
-												'value' => 1,
323
-												'class' => 'getpaid-refund-field',
324
-											),
325
-											true
326
-										);
327
-									?>
316
+                                        aui()->input(
317
+                                            array(
318
+                                                'type'  => 'checkbox',
319
+                                                'name'  => 'getpaid_cancel_subscription',
320
+                                                'id'    => 'getpaid_cancel_subscription',
321
+                                                'label' => __( 'Cancel subscription', 'invoicing' ),
322
+                                                'value' => 1,
323
+                                                'class' => 'getpaid-refund-field',
324
+                                            ),
325
+                                            true
326
+                                        );
327
+                                    ?>
328 328
 								<?php endif; ?>
329 329
                             </div>
330 330
                             <div class="modal-footer">
@@ -364,23 +364,23 @@  discard block
 block discarded – undo
364 364
                 <?php
365 365
                     if ( $invoice->is_paid() ) {
366 366
 
367
-						printf(
368
-							'<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>',
369
-							esc_html__( 'Refund', 'invoicing' )
370
-						);
367
+                        printf(
368
+                            '<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>',
369
+                            esc_html__( 'Refund', 'invoicing' )
370
+                        );
371 371
                     } elseif ( ! $invoice->is_refunded() ) {
372
-						wpinv_item_dropdown(
373
-							array(
374
-								'name'           => 'wpinv_invoice_item',
375
-								'id'             => 'wpinv_invoice_item',
376
-								'show_recurring' => true,
377
-								'class'          => 'wpi_select2',
378
-							)
379
-						);
380
-
381
-						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>';
382
-						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
383
-						echo '&nbsp;' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
372
+                        wpinv_item_dropdown(
373
+                            array(
374
+                                'name'           => 'wpinv_invoice_item',
375
+                                'id'             => 'wpinv_invoice_item',
376
+                                'show_recurring' => true,
377
+                                'class'          => 'wpi_select2',
378
+                            )
379
+                        );
380
+
381
+                        echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>';
382
+                        echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
383
+                        echo '&nbsp;' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
384 384
 
385 385
                     }
386 386
                 ?>
@@ -397,72 +397,72 @@  discard block
 block discarded – undo
397 397
             <?php foreach ( array_keys( $columns ) as $column ) : ?>
398 398
                 <td class="
399 399
 					<?php
400
-						echo esc_attr( $column );
401
-						echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '';
402
-					?>
400
+                        echo esc_attr( $column );
401
+                        echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '';
402
+                    ?>
403 403
 				">
404 404
                     <?php
405 405
                         switch ( $column ) {
406
-						case 'id':
407
-							echo (int) $item->get_id();
408
-							break;
409
-						case 'title':
410
-							printf(
411
-								'<a href="%s" target="_blank">%s</a>',
412
-								esc_url( get_edit_post_link( $item->get_id() ) ),
413
-								esc_html( $item->get_raw_name() )
414
-							);
415
-
416
-							$summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
417
-							if ( $summary !== '' ) {
418
-								printf(
419
-									'<span class="meta">%s</span>',
420
-									wp_kses_post( wpautop( $summary ) )
421
-								);
422
-							}
423
-
424
-							printf(
425
-								'<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
426
-								esc_attr( $item->get_raw_name() ),
427
-								(int) $item->get_id()
428
-							);
429
-
430
-							printf(
431
-								'<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
432
-								(int) $item->get_id(),
433
-								esc_attr( $item->get_description() )
434
-							);
435
-
436
-							break;
437
-						case 'price':
438
-							printf(
439
-								'<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
440
-								esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
441
-								(int) $item->get_id()
442
-							);
443
-
444
-							break;
445
-						case 'qty':
446
-							printf(
447
-								'<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
448
-								floatval( $item->get_quantity() ),
449
-								(int) $item->get_id()
450
-							);
451
-
452
-							break;
453
-						case 'total':
454
-							wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() );
455
-
456
-							break;
457
-						case 'tax':
458
-							echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
459
-
460
-							break;
461
-						case 'action':
462
-							if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
463
-								echo '<i class="fa fa-trash wpinv-item-remove"></i>';
406
+                        case 'id':
407
+                            echo (int) $item->get_id();
408
+                            break;
409
+                        case 'title':
410
+                            printf(
411
+                                '<a href="%s" target="_blank">%s</a>',
412
+                                esc_url( get_edit_post_link( $item->get_id() ) ),
413
+                                esc_html( $item->get_raw_name() )
414
+                            );
415
+
416
+                            $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
417
+                            if ( $summary !== '' ) {
418
+                                printf(
419
+                                    '<span class="meta">%s</span>',
420
+                                    wp_kses_post( wpautop( $summary ) )
421
+                                );
422
+                            }
423
+
424
+                            printf(
425
+                                '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
426
+                                esc_attr( $item->get_raw_name() ),
427
+                                (int) $item->get_id()
428
+                            );
429
+
430
+                            printf(
431
+                                '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
432
+                                (int) $item->get_id(),
433
+                                esc_attr( $item->get_description() )
434
+                            );
435
+
436
+                            break;
437
+                        case 'price':
438
+                            printf(
439
+                                '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
440
+                                esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
441
+                                (int) $item->get_id()
442
+                            );
443
+
444
+                            break;
445
+                        case 'qty':
446
+                            printf(
447
+                                '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
448
+                                floatval( $item->get_quantity() ),
449
+                                (int) $item->get_id()
450
+                            );
451
+
452
+                            break;
453
+                        case 'total':
454
+                            wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() );
455
+
456
+                            break;
457
+                        case 'tax':
458
+                            echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
459
+
460
+                            break;
461
+                        case 'action':
462
+                            if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
463
+                                echo '<i class="fa fa-trash wpinv-item-remove"></i>';
464 464
                                 }
465
-							break;
465
+                            break;
466 466
                         }
467 467
                         do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
468 468
                     ?>
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
     }
474 474
 
475 475
     /**
476
-	 * Output the metabox.
477
-	 *
478
-	 * @param WP_Post $post
479
-	 */
476
+     * Output the metabox.
477
+     *
478
+     * @param WP_Post $post
479
+     */
480 480
     public static function output2( $post ) {
481 481
 
482 482
         // Prepare the invoice.
Please login to merge, or discard this patch.
Spacing   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns   = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38 38
             'tax'    => $invoice->get_item_tax_name(),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) {
52
-            return self::output2( $post );
51
+        if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) {
52
+            return self::output2($post);
53 53
         }
54 54
 
55
-        $post_id    = ! empty( $post->ID ) ? $post->ID : 0;
56
-        $invoice    = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
55
+        $post_id    = !empty($post->ID) ? $post->ID : 0;
56
+        $invoice    = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
57 57
         $use_taxes  = $invoice->is_taxable() && wpinv_use_taxes();
58
-        $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
59
-        $columns    = self::get_columns( $invoice );
60
-        $cols       = count( $columns );
58
+        $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
59
+        $columns    = self::get_columns($invoice);
60
+        $cols       = count($columns);
61 61
         $class      = '';
62 62
 
63
-        unset( $item_types['adv'] );
64
-        unset( $item_types['package'] );
63
+        unset($item_types['adv']);
64
+        unset($item_types['package']);
65 65
 
66
-        if ( $invoice->is_paid() ) {
66
+        if ($invoice->is_paid()) {
67 67
             $class .= ' wpinv-paid';
68 68
         }
69 69
 
70
-        if ( $invoice->is_refunded() ) {
70
+        if ($invoice->is_refunded()) {
71 71
             $class .= ' wpinv-refunded';
72 72
         }
73 73
 
74
-        if ( $invoice->is_recurring() ) {
74
+        if ($invoice->is_recurring()) {
75 75
             $class .= ' wpi-recurring';
76 76
         }
77 77
 
@@ -87,26 +87,26 @@  discard block
 block discarded – undo
87 87
 		);
88 88
     ?>
89 89
 
90
-        <div class="wpinv-items-wrap<?php echo esc_attr( $class ); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
90
+        <div class="wpinv-items-wrap<?php echo esc_attr($class); ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
91 91
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
92 92
 
93 93
                 <thead>
94 94
                     <tr>
95
-                        <?php foreach ( $columns as $key => $label ) : ?>
95
+                        <?php foreach ($columns as $key => $label) : ?>
96 96
                             <th class="
97 97
                             <?php
98
-                            echo esc_attr( $key );
98
+                            echo esc_attr($key);
99 99
 							echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '';
100 100
 							?>
101
-							"><?php echo wp_kses_post( $label ); ?></th>
101
+							"><?php echo wp_kses_post($label); ?></th>
102 102
                         <?php endforeach; ?>
103 103
                     </tr>
104 104
                 </thead>
105 105
 
106 106
                 <tbody class="wpinv-line-items">
107 107
                     <?php
108
-                        foreach ( $invoice->get_items() as $int => $item ) {
109
-						self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
108
+                        foreach ($invoice->get_items() as $int => $item) {
109
+						self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
110 110
                         }
111 111
                     ?>
112 112
                 </tbody>
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                                             <div class="wp-clearfix">
124 124
                                                 <label class="wpi-item-name">
125 125
                                                     <span class="input-text-wrap">
126
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
126
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
127 127
                                                     </span>
128 128
                                                 </label>
129 129
                                             </div>
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
                                             <div class="wp-clearfix">
132 132
                                                 <label class="wpi-item-price">
133 133
                                                     <span class="input-text-wrap">
134
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' ); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
135
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' ); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
134
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
135
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
136 136
                                                     </span>
137 137
                                                 </label>
138 138
                                             </div>
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                                             <div class="wp-clearfix">
141 141
                                                 <label class="wpi-item-name">
142 142
                                                     <span class="input-text-wrap">
143
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' ); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
143
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
144 144
                                                     </span>
145 145
                                                 </label>
146 146
                                             </div>
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                                                 </label>
166 166
                                             </div>
167 167
 
168
-                                            <?php if ( $use_taxes ) : ?>
168
+                                            <?php if ($use_taxes) : ?>
169 169
                                                 <div class="wp-clearfix">
170 170
                                                     <label class="wpi-vat-rule">
171 171
                                                         <span class="input-text-wrap">
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
                                                                 wpinv_html_select(
174 174
                                                                     array(
175 175
 																		'options'          => array_merge(
176
-																			array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
176
+																			array('' => __('Select VAT Rule', 'invoicing')),
177 177
 																			getpaid_get_tax_rules()
178 178
 																		),
179 179
 																		'name'             => '_wpinv_quick[vat_rule]',
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                                                                 wpinv_html_select(
196 196
                                                                     array(
197 197
 																		'options'          => array_merge(
198
-																			array( '' => __( 'Select VAT Class', 'invoicing' ) ),
198
+																			array('' => __('Select VAT Class', 'invoicing')),
199 199
 																			getpaid_get_tax_classes()
200 200
 																		),
201 201
 																		'name'             => '_wpinv_quick[vat_class]',
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                                                             'type'    => 'checkbox',
220 220
                                                             'name'    => '_wpinv_quick[one-time]',
221 221
                                                             'id'      => '_wpinv_quick-one-time',
222
-                                                            'label'   => __( "One time item (won't be saved to regular items list)", 'invoicing' ),
222
+                                                            'label'   => __("One time item (won't be saved to regular items list)", 'invoicing'),
223 223
                                                             'value'   => 1,
224 224
                                                             'no_wrap' => true,
225 225
                                                             'checked' => false,
@@ -243,39 +243,39 @@  discard block
 block discarded – undo
243 243
                         </td>
244 244
                     </tr>
245 245
                     <tr class="totals">
246
-                        <td colspan="<?php echo ( (int) $cols - 4 ); ?>"></td>
246
+                        <td colspan="<?php echo ((int) $cols - 4); ?>"></td>
247 247
                         <td colspan="4">
248 248
                             <table cellspacing="0" cellpadding="0">
249 249
                                 <tr class="subtotal">
250
-                                    <td class="name"><?php esc_html_e( 'Sub Total:', 'invoicing' ); ?></td>
251
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_subtotal(), $invoice->get_currency() ); ?></td>
250
+                                    <td class="name"><?php esc_html_e('Sub Total:', 'invoicing'); ?></td>
251
+                                    <td class="total"><?php wpinv_the_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
252 252
                                     <td class="action"></td>
253 253
                                 </tr>
254 254
                                 <tr class="discount">
255
-                                    <td class="name"><?php esc_html_e( 'Discount:', 'invoicing' ); ?></td>
256
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total_discount(), $invoice->get_currency() ); ?></td>
255
+                                    <td class="name"><?php esc_html_e('Discount:', 'invoicing'); ?></td>
256
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
257 257
                                     <td class="action"></td>
258 258
                                 </tr>
259
-                                <?php if ( $use_taxes ) : ?>
260
-                                <?php if ( is_array( $taxes = $invoice->get_taxes() ) && wpinv_display_individual_tax_rates() ) { ?>
261
-                                <?php foreach ( $taxes as $tax_key => $tax_item ) { ?>
259
+                                <?php if ($use_taxes) : ?>
260
+                                <?php if (is_array($taxes = $invoice->get_taxes()) && wpinv_display_individual_tax_rates()) { ?>
261
+                                <?php foreach ($taxes as $tax_key => $tax_item) { ?>
262 262
                                 <tr class="tax">
263
-                                    <td class="name"><?php echo esc_html( $invoice->get_tax_item_name( $tax_key, $tax_item, ':' ) ); ?></td>
264
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_tax_item_amount( $tax_key, $tax_item ), $invoice->get_currency() ); ?></td>
263
+                                    <td class="name"><?php echo esc_html($invoice->get_tax_item_name($tax_key, $tax_item, ':')); ?></td>
264
+                                    <td class="total"><?php wpinv_the_price($invoice->get_tax_item_amount($tax_key, $tax_item), $invoice->get_currency()); ?></td>
265 265
                                     <td class="action"></td>
266 266
                                 </tr>
267 267
                                 <?php } ?>
268 268
                                 <?php } else { ?>
269 269
                                 <tr class="tax">
270
-                                    <td class="name"><?php esc_html_e( 'Tax:', 'invoicing' ); ?></td>
271
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total_tax(), $invoice->get_currency() ); ?></td>
270
+                                    <td class="name"><?php esc_html_e('Tax:', 'invoicing'); ?></td>
271
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
272 272
                                     <td class="action"></td>
273 273
                                 </tr>
274 274
                                 <?php } ?>
275 275
                                 <?php endif; ?>
276 276
                                 <tr class="total">
277
-                                    <td class="name"><?php esc_html_e( 'Total:', 'invoicing' ); ?></td>
278
-                                    <td class="total"><?php wpinv_the_price( $invoice->get_total(), $invoice->get_currency() ); ?></td>
277
+                                    <td class="name"><?php esc_html_e('Total:', 'invoicing'); ?></td>
278
+                                    <td class="total"><?php wpinv_the_price($invoice->get_total(), $invoice->get_currency()); ?></td>
279 279
                                     <td class="action"></td>
280 280
                                 </tr>
281 281
                             </table>
@@ -291,18 +291,18 @@  discard block
 block discarded – undo
291 291
                      <div class="modal-dialog modal-dialog-centered" role="document">
292 292
                         <div class="modal-content">
293 293
                             <div class="modal-header">
294
-                                <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e( 'Refund Payment', 'invoicing' ); ?></h5>
295
-                                <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>">
296
-                                    <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
294
+                                <h5 class="modal-title" id="getpaid-refund-invoice-modal-label"><?php esc_html_e('Refund Payment', 'invoicing'); ?></h5>
295
+                                <button type="button" class="close btn-close" data-bs-dismiss="modal" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>">
296
+                                    <?php if (empty($GLOBALS['aui_bs5'])) : ?>
297 297
                                         <span aria-hidden="true">×</span>
298 298
                                     <?php endif; ?>
299 299
                                 </button>
300 300
                             </div>
301 301
                             <div class="modal-body">
302 302
 								<p>
303
-									<?php esc_html_e( 'Are you sure you want to refund this payment?', 'invoicing' ); ?>
303
+									<?php esc_html_e('Are you sure you want to refund this payment?', 'invoicing'); ?>
304 304
 								</p>
305
-								<?php if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) ) : ?>
305
+								<?php if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds')) : ?>
306 306
 									<?php
307 307
 										aui()->input(
308 308
 											array(
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 												'id'    => 'getpaid_refund_remote',
312 312
 												'label' => sprintf(
313 313
 													'Refund payment in %s',
314
-													wpinv_get_gateway_admin_label( $invoice->get_gateway() )
314
+													wpinv_get_gateway_admin_label($invoice->get_gateway())
315 315
 												),
316 316
 												'value' => 1,
317 317
 												'class' => 'getpaid-refund-field',
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 									?>
322 322
 								<?php endif; ?>
323 323
 
324
-								<?php if ( getpaid_get_invoice_subscriptions( $invoice ) ) : ?>
324
+								<?php if (getpaid_get_invoice_subscriptions($invoice)) : ?>
325 325
 									<?php
326 326
 										aui()->input(
327 327
 											array(
328 328
 												'type'  => 'checkbox',
329 329
 												'name'  => 'getpaid_cancel_subscription',
330 330
 												'id'    => 'getpaid_cancel_subscription',
331
-												'label' => __( 'Cancel subscription', 'invoicing' ),
331
+												'label' => __('Cancel subscription', 'invoicing'),
332 332
 												'value' => 1,
333 333
 												'class' => 'getpaid-refund-field',
334 334
 											),
@@ -338,12 +338,12 @@  discard block
 block discarded – undo
338 338
 								<?php endif; ?>
339 339
                             </div>
340 340
                             <div class="modal-footer">
341
-                                <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
341
+                                <button type="button" class="btn btn-secondary getpaid-cancel" data-bs-dismiss="modal" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
342 342
                                 <a
343
-									href="<?php echo esc_url_raw( $refund_url ); ?>"
344
-									data-href="<?php echo esc_url_raw( $refund_url ); ?>"
343
+									href="<?php echo esc_url_raw($refund_url); ?>"
344
+									data-href="<?php echo esc_url_raw($refund_url); ?>"
345 345
 									class="btn btn-primary getpaid-refund-payment-button"
346
-								><?php esc_html_e( 'Refund', 'invoicing' ); ?></a>
346
+								><?php esc_html_e('Refund', 'invoicing'); ?></a>
347 347
 								<script>
348 348
 									// Update the refund URL when the user changes the refund options.
349 349
 									jQuery( function( $ ) {
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
             <div class="wpinv-actions">
371 371
                 <?php
372
-                    if ( $invoice->is_paid() ) {
372
+                    if ($invoice->is_paid()) {
373 373
 
374 374
 						printf(
375 375
 							'<span class="bsui"><button type="button" class="button button-primary" data-toggle="modal" data-bs-toggle="modal" data-bs-target="#getpaid-refund-invoice-modal" data-target="#getpaid-refund-invoice-modal">%s</button></span>',
376
-							esc_html__( 'Refund', 'invoicing' )
376
+							esc_html__('Refund', 'invoicing')
377 377
 						);
378
-                    } elseif ( ! $invoice->is_refunded() ) {
378
+                    } elseif (!$invoice->is_refunded()) {
379 379
 						wpinv_item_dropdown(
380 380
 							array(
381 381
 								'name'           => 'wpinv_invoice_item',
@@ -385,66 +385,66 @@  discard block
 block discarded – undo
385 385
 							)
386 386
 						);
387 387
 
388
-						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), esc_html( $invoice->get_label() ) ) . '</button>';
389
-						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
390
-						echo '&nbsp;' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
388
+						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), esc_html($invoice->get_label())) . '</button>';
389
+						echo '&nbsp;' . '<button type="button" class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
390
+						echo '&nbsp;' . '<button type="button" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
391 391
 
392 392
                     }
393 393
                 ?>
394
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
394
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
395 395
             </div>
396 396
         </div>
397 397
         <?php
398 398
     }
399 399
 
400
-    public static function output_row( $columns, $item, $invoice, $class = 'even' ) {
400
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
401 401
 
402 402
     ?>
403
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
404
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
403
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
404
+            <?php foreach (array_keys($columns) as $column) : ?>
405 405
                 <td class="
406 406
 					<?php
407
-						echo esc_attr( $column );
407
+						echo esc_attr($column);
408 408
 						echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '';
409 409
 					?>
410 410
 				">
411 411
                     <?php
412
-                        switch ( $column ) {
412
+                        switch ($column) {
413 413
 						case 'id':
414 414
 							echo (int) $item->get_id();
415 415
 							break;
416 416
 						case 'title':
417 417
 							printf(
418 418
 								'<a href="%s" target="_blank">%s</a>',
419
-								esc_url( get_edit_post_link( $item->get_id() ) ),
420
-								esc_html( $item->get_raw_name() )
419
+								esc_url(get_edit_post_link($item->get_id())),
420
+								esc_html($item->get_raw_name())
421 421
 							);
422 422
 
423
-							$summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
424
-							if ( $summary !== '' ) {
423
+							$summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
424
+							if ($summary !== '') {
425 425
 								printf(
426 426
 									'<span class="meta">%s</span>',
427
-									wp_kses_post( wpautop( $summary ) )
427
+									wp_kses_post(wpautop($summary))
428 428
 								);
429 429
 							}
430 430
 
431 431
 							printf(
432 432
 								'<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
433
-								esc_attr( $item->get_raw_name() ),
433
+								esc_attr($item->get_raw_name()),
434 434
 								(int) $item->get_id()
435 435
 							);
436 436
 
437 437
 							printf(
438 438
 								'<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
439 439
 								(int) $item->get_id(),
440
-								esc_attr( $item->get_description() )
440
+								esc_attr($item->get_description())
441 441
 							);
442 442
 
443 443
 							break;
444 444
 						case 'price':
445 445
 							printf(
446 446
 								'<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
447
-								esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
447
+								esc_attr(getpaid_unstandardize_amount($item->get_price())),
448 448
 								(int) $item->get_id()
449 449
 							);
450 450
 
@@ -452,26 +452,26 @@  discard block
 block discarded – undo
452 452
 						case 'qty':
453 453
 							printf(
454 454
 								'<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
455
-								floatval( $item->get_quantity() ),
455
+								floatval($item->get_quantity()),
456 456
 								(int) $item->get_id()
457 457
 							);
458 458
 
459 459
 							break;
460 460
 						case 'total':
461
-							wpinv_the_price( $item->get_sub_total(), $invoice->get_currency() );
461
+							wpinv_the_price($item->get_sub_total(), $invoice->get_currency());
462 462
 
463 463
 							break;
464 464
 						case 'tax':
465
-							echo floatval( wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) ) . '%';
465
+							echo floatval(wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2)) . '%';
466 466
 
467 467
 							break;
468 468
 						case 'action':
469
-							if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
469
+							if (!$invoice->is_paid() && !$invoice->is_refunded()) {
470 470
 								echo '<i class="fa fa-trash wpinv-item-remove"></i>';
471 471
                                 }
472 472
 							break;
473 473
                         }
474
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
474
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
475 475
                     ?>
476 476
                 </td>
477 477
             <?php endforeach; ?>
@@ -484,10 +484,10 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @param WP_Post $post
486 486
 	 */
487
-    public static function output2( $post ) {
487
+    public static function output2($post) {
488 488
 
489 489
         // Prepare the invoice.
490
-        $invoice = new WPInv_Invoice( $post );
490
+        $invoice = new WPInv_Invoice($post);
491 491
 
492 492
         // Invoice items.
493 493
         $items = $invoice->get_items();
@@ -495,28 +495,28 @@  discard block
 block discarded – undo
495 495
         $totals = array(
496 496
 
497 497
             'subtotal' => array(
498
-                'label' => __( 'Items Subtotal', 'invoicing' ),
499
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
498
+                'label' => __('Items Subtotal', 'invoicing'),
499
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
500 500
             ),
501 501
 
502 502
             'discount' => array(
503
-                'label' => __( 'Total Discount', 'invoicing' ),
504
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
503
+                'label' => __('Total Discount', 'invoicing'),
504
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
505 505
             ),
506 506
 
507 507
             'tax'      => array(
508
-                'label' => __( 'Total Tax', 'invoicing' ),
509
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
508
+                'label' => __('Total Tax', 'invoicing'),
509
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
510 510
             ),
511 511
 
512 512
             'total'    => array(
513
-                'label' => __( 'Invoice Total', 'invoicing' ),
514
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
513
+                'label' => __('Invoice Total', 'invoicing'),
514
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
515 515
             ),
516 516
         );
517 517
 
518
-        if ( ! wpinv_use_taxes() ) {
519
-            unset( $totals['tax'] );
518
+        if (!wpinv_use_taxes()) {
519
+            unset($totals['tax']);
520 520
         }
521 521
 
522 522
         $item_args = array(
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
             'orderby'        => 'title',
525 525
             'order'          => 'ASC',
526 526
             'posts_per_page' => -1,
527
-            'post_status'    => array( 'publish' ),
527
+            'post_status'    => array('publish'),
528 528
             'meta_query'     => array(
529 529
                 array(
530 530
                     'key'     => '_wpinv_type',
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
             }
553 553
         </style>
554 554
 
555
-                <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
555
+                <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;">
556 556
 
557
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
558
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
557
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
558
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
559 559
 
560 560
                         <div class="row">
561 561
                             <div class="col-12 col-sm-6">
@@ -564,15 +564,15 @@  discard block
 block discarded – undo
564 564
                                         array(
565 565
                                             'id'          => 'wpinv_template',
566 566
                                             'name'        => 'wpinv_template',
567
-                                            'label'       => __( 'Template', 'invoicing' ),
567
+                                            'label'       => __('Template', 'invoicing'),
568 568
                                             'label_type'  => 'vertical',
569
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
569
+                                            'placeholder' => __('Choose a template', 'invoicing'),
570 570
                                             'class'       => 'form-control-sm',
571
-                                            'value'       => $invoice->get_template( 'edit' ),
571
+                                            'value'       => $invoice->get_template('edit'),
572 572
                                             'options'     => array(
573
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
574
-                                                'hours'    => __( 'Hours', 'invoicing' ),
575
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
573
+                                                'quantity' => __('Quantity', 'invoicing'),
574
+                                                'hours'    => __('Hours', 'invoicing'),
575
+                                                'amount'   => __('Amount Only', 'invoicing'),
576 576
                                             ),
577 577
                                             'data-allow-clear' => 'false',
578 578
                                             'select2'     => true,
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
                                         array(
590 590
                                             'id'          => 'wpinv_currency',
591 591
                                             'name'        => 'wpinv_currency',
592
-                                            'label'       => __( 'Currency', 'invoicing' ),
592
+                                            'label'       => __('Currency', 'invoicing'),
593 593
                                             'label_type'  => 'vertical',
594
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
594
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
595 595
                                             'class'       => 'form-control-sm',
596
-                                            'value'       => $invoice->get_currency( 'edit' ),
596
+                                            'value'       => $invoice->get_currency('edit'),
597 597
                                             'required'    => false,
598 598
                                             'data-allow-clear' => 'false',
599 599
                                             'select2'     => true,
@@ -606,24 +606,24 @@  discard block
 block discarded – undo
606 606
                             </div>
607 607
                         </div>
608 608
 
609
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
609
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
610 610
                     <?php endif; ?>
611 611
 
612 612
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
613 613
                         <thead>
614 614
                             <tr>
615
-                                <th class="getpaid-item" colspan="2"><?php esc_html_e( 'Item', 'invoicing' ); ?></th>
615
+                                <th class="getpaid-item" colspan="2"><?php esc_html_e('Item', 'invoicing'); ?></th>
616 616
                                 <th class="getpaid-quantity hide-if-amount text-right">
617
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
618
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span>
617
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span>
618
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span>
619 619
                                 </th>
620 620
                                 <th class="getpaid-price hide-if-amount text-right">
621
-                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
622
-                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Rate', 'invoicing' ); ?></span>
621
+                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Price', 'invoicing'); ?></span>
622
+                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Rate', 'invoicing'); ?></span>
623 623
                                 </th>
624 624
                                 <th class="getpaid-item-subtotal text-right">
625
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
626
-                                    <span class="hide-if-amount"><?php esc_html_e( 'Total', 'invoicing' ); ?></span>
625
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php esc_html_e('Amount', 'invoicing'); ?></span>
626
+                                    <span class="hide-if-amount"><?php esc_html_e('Total', 'invoicing'); ?></span>
627 627
                                 </th>
628 628
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
629 629
                             </tr>
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
 		                <tbody class="getpaid_invoice_line_items">
632 632
                             <tr class="hide-if-has-items hide-if-not-editable">
633 633
                                 <td colspan="2" class="pt-4 pb-4">
634
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Items', 'invoicing' ); ?></button>
635
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button>
634
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Items', 'invoicing'); ?></button>
635
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button>
636 636
                                 </td>
637 637
                                 <td class="hide-if-amount">&nbsp;</th>
638 638
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -664,11 +664,11 @@  discard block
 block discarded – undo
664 664
                             <div class="col-12 col-sm-6 offset-sm-6">
665 665
                                 <table class="getpaid-invoice-totals text-right w-100">
666 666
                                     <tbody>
667
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
668
-                                            <tr class="getpaid-totals-<?php echo esc_attr( $key ); ?>">
669
-                                                <td class="label"><?php echo esc_html( $data['label'] ); ?>:</td>
667
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
668
+                                            <tr class="getpaid-totals-<?php echo esc_attr($key); ?>">
669
+                                                <td class="label"><?php echo esc_html($data['label']); ?>:</td>
670 670
                                                 <td width="1%"></td>
671
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ); ?></td>
671
+                                                <td class="value"><?php echo wp_kses_post($data['value']); ?></td>
672 672
                                             </tr>
673 673
                                         <?php endforeach; ?>
674 674
                                     </tbody>
@@ -681,18 +681,18 @@  discard block
 block discarded – undo
681 681
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
682 682
                         <div class="row">
683 683
                             <div class="text-left col-12 col-sm-8">
684
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e( 'Add Existing Item', 'invoicing' ); ?></button>
685
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e( 'Create New Item', 'invoicing' ); ?></button>
686
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
684
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php esc_html_e('Add Existing Item', 'invoicing'); ?></button>
685
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php esc_html_e('Create New Item', 'invoicing'); ?></button>
686
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
687 687
                             </div>
688 688
                             <div class="text-right col-12 col-sm-4">
689
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e( 'Recalculate Totals', 'invoicing' ); ?></button>
689
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php esc_html_e('Recalculate Totals', 'invoicing'); ?></button>
690 690
                             </div>
691 691
                         </div>
692 692
                     </div>
693 693
 
694 694
                     <div class="getpaid-invoice-item-actions hide-if-editable">
695
-                        <p class="description m-2 text-right text-muted"><?php esc_html_e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
695
+                        <p class="description m-2 text-right text-muted"><?php esc_html_e('This invoice is no longer editable', 'invoicing'); ?></p>
696 696
                     </div>
697 697
 
698 698
                     <!-- Add items to an invoice -->
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
                         <div class="modal-dialog modal-dialog-centered" role="document">
701 701
                             <div class="modal-content">
702 702
                                 <div class="modal-header">
703
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e( 'Add Item(s)', 'invoicing' ); ?></h5>
704
-                                    <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>">
705
-                                        <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
703
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php esc_html_e('Add Item(s)', 'invoicing'); ?></h5>
704
+                                    <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>">
705
+                                        <?php if (empty($GLOBALS['aui_bs5'])) : ?>
706 706
                                             <span aria-hidden="true">×</span>
707 707
                                         <?php endif; ?>
708 708
                                     </button>
@@ -711,10 +711,10 @@  discard block
 block discarded – undo
711 711
                                     <table class="widefat">
712 712
                                         <thead>
713 713
                                             <tr>
714
-                                                <th class="pl-0 text-left"><?php esc_html_e( 'Item', 'invoicing' ); ?></th>
714
+                                                <th class="pl-0 text-left"><?php esc_html_e('Item', 'invoicing'); ?></th>
715 715
                                                 <th class="pr-0 text-right hide-if-amount">
716
-                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
717
-                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e( 'Hours', 'invoicing' ); ?></span>
716
+                                                    <span class="getpaid-hide-if-hours"><?php esc_html_e('Quantity', 'invoicing'); ?></span>
717
+                                                    <span class="getpaid-hide-if-quantity"><?php esc_html_e('Hours', 'invoicing'); ?></span>
718 718
                                                 </th>
719 719
                                             </tr>
720 720
                                         </thead>
@@ -722,9 +722,9 @@  discard block
 block discarded – undo
722 722
 								            <tr>
723 723
 									            <td class="pl-0 text-left">
724 724
                                                     <select class="regular-text getpaid-add-invoice-item-select">
725
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
726
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
727
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html( $item->post_title ); ?></option>
725
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
726
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
727
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo esc_html($item->post_title); ?></option>
728 728
                                                         <?php endforeach; ?>
729 729
                                                     </select>
730 730
                                                 </td>
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 						            </table>
737 737
                                 </div>
738 738
                                 <div class="modal-footer">
739
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
740
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e( 'Add', 'invoicing' ); ?></button>
739
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
740
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php esc_html_e('Add', 'invoicing'); ?></button>
741 741
                                 </div>
742 742
                             </div>
743 743
                         </div>
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
                         <div class="modal-dialog modal-dialog-centered" role="document">
749 749
                             <div class="modal-content">
750 750
                                 <div class="modal-header">
751
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e( 'Create Item', 'invoicing' ); ?></h5>
752
-                                    <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>">
753
-                                        <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
751
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php esc_html_e('Create Item', 'invoicing'); ?></h5>
752
+                                    <button type="button" class="close btn-close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>">
753
+                                        <?php if (empty($GLOBALS['aui_bs5'])) : ?>
754 754
                                             <span aria-hidden="true">×</span>
755 755
                                         <?php endif; ?>
756 756
                                     </button>
@@ -759,27 +759,27 @@  discard block
 block discarded – undo
759 759
                                     <div class="getpaid-create-item-div">
760 760
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
761 761
                                         <label class="form-group mb-3 w-100">
762
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
763
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
762
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
763
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
764 764
                                         </label>
765 765
                                         <label class="form-group mb-3 w-100">
766
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
767
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
768
-                                            <input type="text" name="price" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control form-control-sm item-price">
766
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
767
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
768
+                                            <input type="text" name="price" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control form-control-sm item-price">
769 769
                                         </label>
770 770
                                         <label class="form-group mb-3 w-100 hide-if-amount">
771
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
771
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
772 772
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
773 773
                                         </label>
774 774
                                         <label class="form-group mb-3 w-100">
775
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
776
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
775
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
776
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
777 777
                                         </label>
778 778
                                     </div>
779 779
                                 </div>
780 780
                                 <div class="modal-footer">
781
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
782
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Create', 'invoicing' ); ?></button>
781
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
782
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Create', 'invoicing'); ?></button>
783 783
                                 </div>
784 784
                             </div>
785 785
                         </div>
@@ -790,9 +790,9 @@  discard block
 block discarded – undo
790 790
                         <div class="modal-dialog modal-dialog-centered" role="document">
791 791
                             <div class="modal-content">
792 792
                                 <div class="modal-header">
793
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e( 'Edit Item', 'invoicing' ); ?></h5>
794
-                                    <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'invoicing' ); ?>">
795
-                                        <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
793
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php esc_html_e('Edit Item', 'invoicing'); ?></h5>
794
+                                    <button type="button" class="close close" data-dismiss="modal" aria-label="<?php esc_html_e('Close', 'invoicing'); ?>">
795
+                                        <?php if (empty($GLOBALS['aui_bs5'])) : ?>
796 796
                                             <span aria-hidden="true">×</span>
797 797
                                         <?php endif; ?>
798 798
                                     </button>
@@ -801,27 +801,27 @@  discard block
 block discarded – undo
801 801
                                     <div class="getpaid-edit-item-div">
802 802
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
803 803
                                         <label class="form-group mb-3 w-100">
804
-                                            <span><?php esc_html_e( 'Name', 'invoicing' ); ?></span>
805
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
804
+                                            <span><?php esc_html_e('Name', 'invoicing'); ?></span>
805
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
806 806
                                         </label>
807 807
                                         <label class="form-group mb-3 w-100">
808
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e( 'Amount', 'invoicing' ); ?></span>
809
-                                            <span class="hide-if-amount"><?php esc_html_e( 'Price', 'invoicing' ); ?></span>
810
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
808
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php esc_html_e('Amount', 'invoicing'); ?></span>
809
+                                            <span class="hide-if-amount"><?php esc_html_e('Price', 'invoicing'); ?></span>
810
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
811 811
                                         </label>
812 812
                                         <label class="form-group mb-3 w-100 hide-if-amount">
813
-                                            <span><?php esc_html_e( 'Quantity', 'invoicing' ); ?></span>
813
+                                            <span><?php esc_html_e('Quantity', 'invoicing'); ?></span>
814 814
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
815 815
                                         </label>
816 816
                                         <label class="form-group mb-3 w-100">
817
-                                            <span><?php esc_html_e( 'Item Description', 'invoicing' ); ?></span>
818
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
817
+                                            <span><?php esc_html_e('Item Description', 'invoicing'); ?></span>
818
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
819 819
                                         </label>
820 820
                                     </div>
821 821
                                 </div>
822 822
                                 <div class="modal-footer">
823
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e( 'Cancel', 'invoicing' ); ?></button>
824
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e( 'Save', 'invoicing' ); ?></button>
823
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php esc_html_e('Cancel', 'invoicing'); ?></button>
824
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php esc_html_e('Save', 'invoicing'); ?></button>
825 825
                                 </div>
826 826
                             </div>
827 827
                         </div>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +620 added lines, -620 removed lines patch added patch discarded remove patch
@@ -14,94 +14,94 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
29
-
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29
+
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct() {
38
+     * Class constructor.
39
+     */
40
+    public function __construct() {
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
70 70
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
-		do_action( 'getpaid_init_admin_hooks', $this );
81
-
82
-		// Setup/welcome
83
-		if ( ! empty( $_GET['page'] ) ) {
84
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
85
-				case 'gp-setup':
86
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
87
-					break;
88
-			}
89
-		}
90
-
91
-    }
92
-
93
-    /**
94
-	 * Register admin scripts
95
-	 *
96
-	 */
97
-	public function enqeue_scripts() {
71
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
+        do_action( 'getpaid_init_admin_hooks', $this );
81
+
82
+        // Setup/welcome
83
+        if ( ! empty( $_GET['page'] ) ) {
84
+            switch ( sanitize_text_field( $_GET['page'] ) ) {
85
+                case 'gp-setup':
86
+                    include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
87
+                    break;
88
+            }
89
+        }
90
+
91
+    }
92
+
93
+    /**
94
+     * Register admin scripts
95
+     *
96
+     */
97
+    public function enqeue_scripts() {
98 98
         global $current_screen, $pagenow;
99 99
 
100
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
101
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
100
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
101
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
102 102
 
103 103
         if ( ! empty( $current_screen->post_type ) ) {
104
-			$page = $current_screen->post_type;
104
+            $page = $current_screen->post_type;
105 105
         }
106 106
 
107 107
         // General styles.
@@ -122,53 +122,53 @@  discard block
 block discarded – undo
122 122
         }
123 123
 
124 124
         // Payment form scripts.
125
-		if ( 'wpi_payment_form' == $page && $editing ) {
125
+        if ( 'wpi_payment_form' == $page && $editing ) {
126 126
             $this->load_payment_form_scripts();
127 127
         }
128 128
 
129
-		if ( $page == 'wpinv-subscriptions' ) {
130
-			wp_enqueue_script( 'postbox' );
131
-		}
129
+        if ( $page == 'wpinv-subscriptions' ) {
130
+            wp_enqueue_script( 'postbox' );
131
+        }
132 132
 
133 133
     }
134 134
 
135 135
     /**
136
-	 * Returns admin js translations.
137
-	 *
138
-	 */
139
-	protected function get_admin_i18() {
136
+     * Returns admin js translations.
137
+     *
138
+     */
139
+    protected function get_admin_i18() {
140 140
         global $post;
141 141
 
142
-		$date_range = array(
143
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
144
-		);
142
+        $date_range = array(
143
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
144
+        );
145 145
 
146
-		if ( $date_range['period'] == 'custom' ) {
146
+        if ( $date_range['period'] == 'custom' ) {
147 147
 
148
-			if ( isset( $_GET['from'] ) ) {
149
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
150
-			}
148
+            if ( isset( $_GET['from'] ) ) {
149
+                $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
150
+            }
151 151
 
152
-			if ( isset( $_GET['to'] ) ) {
153
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
154
-			}
152
+            if ( isset( $_GET['to'] ) ) {
153
+                $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
154
+            }
155 155
 }
156 156
 
157 157
         $i18n = array(
158 158
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
159 159
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
160
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
-			'rest_root'                 => esc_url_raw( rest_url() ),
163
-			'date_range'                => $date_range,
160
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
+            'rest_root'                 => esc_url_raw( rest_url() ),
163
+            'date_range'                => $date_range,
164 164
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
165 165
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
166 166
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
167 167
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
168 168
             'tax'                       => wpinv_tax_amount(),
169 169
             'discount'                  => 0,
170
-			'currency_symbol'           => wpinv_currency_symbol(),
171
-			'currency'                  => wpinv_get_currency(),
170
+            'currency_symbol'           => wpinv_currency_symbol(),
171
+            'currency'                  => wpinv_get_currency(),
172 172
             'currency_pos'              => wpinv_currency_position(),
173 173
             'thousand_sep'              => wpinv_thousands_separator(),
174 174
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -188,118 +188,118 @@  discard block
 block discarded – undo
188 188
             'item_description'          => __( 'Item Description', 'invoicing' ),
189 189
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
190 190
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
191
-			'searching'                 => __( 'Searching', 'invoicing' ),
192
-			'loading'                   => __( 'Loading...', 'invoicing' ),
193
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
195
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
191
+            'searching'                 => __( 'Searching', 'invoicing' ),
192
+            'loading'                   => __( 'Loading...', 'invoicing' ),
193
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
195
+            'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
196 196
         );
197 197
 
198
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
198
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
199 199
 
200
-			$invoice              = new WPInv_Invoice( $post );
201
-			$i18n['save_invoice'] = sprintf(
202
-				__( 'Save %s', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
204
-			);
200
+            $invoice              = new WPInv_Invoice( $post );
201
+            $i18n['save_invoice'] = sprintf(
202
+                __( 'Save %s', 'invoicing' ),
203
+                ucfirst( $invoice->get_invoice_quote_type() )
204
+            );
205 205
 
206
-			$i18n['invoice_description'] = sprintf(
207
-				__( '%s Description', 'invoicing' ),
208
-				ucfirst( $invoice->get_invoice_quote_type() )
209
-			);
206
+            $i18n['invoice_description'] = sprintf(
207
+                __( '%s Description', 'invoicing' ),
208
+                ucfirst( $invoice->get_invoice_quote_type() )
209
+            );
210 210
 
211
-		}
212
-		return $i18n;
213
-	}
211
+        }
212
+        return $i18n;
213
+    }
214 214
 
215
-	/**
216
-	 * Change the admin footer text on GetPaid admin pages.
217
-	 *
218
-	 * @since  2.0.0
219
-	 * @param  string $footer_text
220
-	 * @return string
221
-	 */
222
-	public function admin_footer_text( $footer_text ) {
223
-		global $current_screen;
215
+    /**
216
+     * Change the admin footer text on GetPaid admin pages.
217
+     *
218
+     * @since  2.0.0
219
+     * @param  string $footer_text
220
+     * @return string
221
+     */
222
+    public function admin_footer_text( $footer_text ) {
223
+        global $current_screen;
224 224
 
225
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
225
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
226 226
 
227 227
         if ( ! empty( $current_screen->post_type ) ) {
228
-			$page = $current_screen->post_type;
228
+            $page = $current_screen->post_type;
229 229
         }
230 230
 
231 231
         // General styles.
232 232
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
233 233
 
234
-			// Change the footer text
235
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
234
+            // Change the footer text
235
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
236 236
 
237
-				$rating_url  = esc_url(
238
-					wp_nonce_url(
239
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
240
-						'getpaid-nonce',
241
-						'getpaid-nonce'
237
+                $rating_url  = esc_url(
238
+                    wp_nonce_url(
239
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
240
+                        'getpaid-nonce',
241
+                        'getpaid-nonce'
242 242
                     )
243
-				);
243
+                );
244 244
 
245
-				$footer_text = sprintf(
246
-					/* translators: %s: five stars */
247
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
248
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249
-				);
245
+                $footer_text = sprintf(
246
+                    /* translators: %s: five stars */
247
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
248
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249
+                );
250 250
 
251
-			} else {
251
+            } else {
252 252
 
253
-				$footer_text = sprintf(
254
-					/* translators: %s: GetPaid */
255
-					__( 'Thank you for using %s!', 'invoicing' ),
256
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257
-				);
253
+                $footer_text = sprintf(
254
+                    /* translators: %s: GetPaid */
255
+                    __( 'Thank you for using %s!', 'invoicing' ),
256
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257
+                );
258 258
 
259
-			}
259
+            }
260 260
 }
261 261
 
262
-		return $footer_text;
263
-	}
264
-
265
-	/**
266
-	 * Redirects to wp.org to rate the plugin.
267
-	 *
268
-	 * @since  2.0.0
269
-	 */
270
-	public function redirect_to_wordpress_rating_page() {
271
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
273
-		exit;
274
-	}
275
-
276
-    /**
277
-	 * Loads payment form js.
278
-	 *
279
-	 */
280
-	protected function load_payment_form_scripts() {
262
+        return $footer_text;
263
+    }
264
+
265
+    /**
266
+     * Redirects to wp.org to rate the plugin.
267
+     *
268
+     * @since  2.0.0
269
+     */
270
+    public function redirect_to_wordpress_rating_page() {
271
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
273
+        exit;
274
+    }
275
+
276
+    /**
277
+     * Loads payment form js.
278
+     *
279
+     */
280
+    protected function load_payment_form_scripts() {
281 281
         global $post;
282 282
 
283 283
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
284
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
286 286
 
287
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
288
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
287
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
288
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
289 289
 
290
-		wp_localize_script(
290
+        wp_localize_script(
291 291
             'wpinv-admin-payment-form-script',
292 292
             'wpinvPaymentFormAdmin',
293 293
             array(
294
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
295
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
296
-				'currency'      => wpinv_currency_symbol(),
297
-				'position'      => wpinv_currency_position(),
298
-				'decimals'      => (int) wpinv_decimals(),
299
-				'thousands_sep' => wpinv_thousands_separator(),
300
-				'decimals_sep'  => wpinv_decimal_separator(),
301
-				'form_items'    => gepaid_get_form_items( $post->ID ),
302
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
294
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
295
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
296
+                'currency'      => wpinv_currency_symbol(),
297
+                'position'      => wpinv_currency_position(),
298
+                'decimals'      => (int) wpinv_decimals(),
299
+                'thousands_sep' => wpinv_thousands_separator(),
300
+                'decimals_sep'  => wpinv_decimal_separator(),
301
+                'form_items'    => gepaid_get_form_items( $post->ID ),
302
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
303 303
             )
304 304
         );
305 305
 
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
     }
309 309
 
310 310
     /**
311
-	 * Add our classes to admin pages.
311
+     * Add our classes to admin pages.
312 312
      *
313 313
      * @param string $classes
314 314
      * @return string
315
-	 *
316
-	 */
315
+     *
316
+     */
317 317
     public function admin_body_class( $classes ) {
318
-		global $pagenow, $post, $current_screen;
318
+        global $pagenow, $post, $current_screen;
319 319
 
320 320
         $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
321 321
 
322 322
         if ( ! empty( $current_screen->post_type ) ) {
323
-			$page = $current_screen->post_type;
323
+            $page = $current_screen->post_type;
324 324
         }
325 325
 
326 326
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -329,70 +329,70 @@  discard block
 block discarded – undo
329 329
 
330 330
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
331 331
             $classes .= ' wpinv-cpt wpinv';
332
-		}
332
+        }
333 333
 
334
-		if ( getpaid_is_invoice_post_type( $page ) ) {
334
+        if ( getpaid_is_invoice_post_type( $page ) ) {
335 335
             $classes .= ' getpaid-is-invoice-cpt';
336 336
         }
337 337
 
338
-		return $classes;
338
+        return $classes;
339 339
     }
340 340
 
341 341
     /**
342
-	 * Maybe show the AyeCode Connect Notice.
343
-	 */
344
-	public function init_ayecode_connect_helper() {
342
+     * Maybe show the AyeCode Connect Notice.
343
+     */
344
+    public function init_ayecode_connect_helper() {
345 345
 
346
-		// Register with the deactivation survey class.
347
-		AyeCode_Deactivation_Survey::instance(
346
+        // Register with the deactivation survey class.
347
+        AyeCode_Deactivation_Survey::instance(
348 348
             array(
349
-				'slug'              => 'invoicing',
350
-				'version'           => WPINV_VERSION,
351
-				'support_url'       => 'https://wpgetpaid.com/support/',
352
-				'documentation_url' => 'https://docs.wpgetpaid.com/',
353
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
349
+                'slug'              => 'invoicing',
350
+                'version'           => WPINV_VERSION,
351
+                'support_url'       => 'https://wpgetpaid.com/support/',
352
+                'documentation_url' => 'https://docs.wpgetpaid.com/',
353
+                'activated'         => (int) get_option( 'gepaid_installed_on' ),
354 354
             )
355 355
         );
356 356
 
357 357
         new AyeCode_Connect_Helper(
358 358
             array(
359
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
360
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
361
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
362
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
363
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
364
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
365
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
359
+                'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
360
+                'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
361
+                'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
362
+                'connect_button'    => __( 'Connect Site', 'invoicing' ),
363
+                'connecting_button' => __( 'Connecting...', 'invoicing' ),
364
+                'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
365
+                'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
366 366
             ),
367 367
             array( 'wpi-addons' )
368 368
         );
369 369
 
370 370
     }
371 371
 
372
-	/**
373
-	 * Redirect users to settings on activation.
374
-	 *
375
-	 * @return void
376
-	 */
377
-	public function activation_redirect() {
372
+    /**
373
+     * Redirect users to settings on activation.
374
+     *
375
+     * @return void
376
+     */
377
+    public function activation_redirect() {
378 378
 
379
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
379
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
380 380
 
381
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
382
-			return;
383
-		}
381
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
382
+            return;
383
+        }
384 384
 
385
-		// Bail if activating from network, or bulk
386
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
387
-			return;
388
-		}
385
+        // Bail if activating from network, or bulk
386
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
387
+            return;
388
+        }
389 389
 
390
-	    update_option( 'wpinv_redirected_to_settings', 1 );
390
+        update_option( 'wpinv_redirected_to_settings', 1 );
391 391
 
392 392
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
393 393
         exit;
394 394
 
395
-	}
395
+    }
396 396
 
397 397
     /**
398 398
      * Fires an admin action after verifying that a user can fire them.
@@ -405,555 +405,555 @@  discard block
 block discarded – undo
405 405
         }
406 406
     }
407 407
 
408
-	/**
408
+    /**
409 409
      * Duplicate invoice.
410
-	 *
411
-	 * @param array $args
410
+     *
411
+     * @param array $args
412 412
      */
413 413
     public function duplicate_invoice( $args ) {
414 414
 
415
-		if ( empty( $args['invoice_id'] ) ) {
416
-			return;
417
-		}
415
+        if ( empty( $args['invoice_id'] ) ) {
416
+            return;
417
+        }
418 418
 
419
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
419
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
420 420
 
421
-		if ( ! $invoice->exists() ) {
422
-			return;
423
-		}
421
+        if ( ! $invoice->exists() ) {
422
+            return;
423
+        }
424 424
 
425
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
426
-		$new_invoice->save();
425
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
426
+        $new_invoice->save();
427 427
 
428
-		if ( $new_invoice->exists() ) {
428
+        if ( $new_invoice->exists() ) {
429 429
 
430
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
430
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
431 431
 
432
-			wp_safe_redirect(
433
-				add_query_arg(
434
-					array(
435
-						'action' => 'edit',
436
-						'post'   => $new_invoice->get_id(),
437
-					),
438
-					admin_url( 'post.php' )
439
-				)
440
-			);
441
-			exit;
432
+            wp_safe_redirect(
433
+                add_query_arg(
434
+                    array(
435
+                        'action' => 'edit',
436
+                        'post'   => $new_invoice->get_id(),
437
+                    ),
438
+                    admin_url( 'post.php' )
439
+                )
440
+            );
441
+            exit;
442 442
 
443
-		}
443
+        }
444 444
 
445
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
445
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
446 446
 
447
-	}
447
+    }
448 448
 
449
-	/**
449
+    /**
450 450
      * Refund an invoice.
451
-	 *
452
-	 * @param array $args
451
+     *
452
+     * @param array $args
453 453
      */
454 454
     public function refund_invoice( $args ) {
455 455
 
456
-		if ( empty( $args['invoice_id'] ) ) {
457
-			return;
458
-		}
459
-
460
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
461
-
462
-		if ( ! $invoice->exists() || $invoice->is_refunded() ) {
463
-			return;
464
-		}
465
-
466
-		$invoice->refund();
467
-
468
-		// Refund remotely.
469
-		if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
470
-			do_action( 'getpaid_refund_invoice_remotely', $invoice );
471
-		}
472
-
473
-		// Cancel subscriptions.
474
-		if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
475
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
476
-
477
-			if ( ! empty( $subscriptions ) ) {
478
-				if ( ! is_array( $subscriptions ) ) {
479
-					$subscriptions = array( $subscriptions );
480
-				}
481
-
482
-				foreach ( $subscriptions as $subscription ) {
483
-					$subscription->cancel();
484
-					$invoice->add_system_note(
485
-						sprintf(
486
-							// translators: %s: subscription ID.
487
-							__( 'Subscription #%s cancelled', 'invoicing' ),
488
-							$subscription->get_id()
489
-						)
490
-					);
491
-				}
492
-			}
493
-		}
494
-
495
-		// Add notice.
496
-		$this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
497
-
498
-		// Redirect.
499
-		wp_safe_redirect(
500
-			remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
501
-		);
502
-	}
503
-
504
-	/**
456
+        if ( empty( $args['invoice_id'] ) ) {
457
+            return;
458
+        }
459
+
460
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
461
+
462
+        if ( ! $invoice->exists() || $invoice->is_refunded() ) {
463
+            return;
464
+        }
465
+
466
+        $invoice->refund();
467
+
468
+        // Refund remotely.
469
+        if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
470
+            do_action( 'getpaid_refund_invoice_remotely', $invoice );
471
+        }
472
+
473
+        // Cancel subscriptions.
474
+        if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
475
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
476
+
477
+            if ( ! empty( $subscriptions ) ) {
478
+                if ( ! is_array( $subscriptions ) ) {
479
+                    $subscriptions = array( $subscriptions );
480
+                }
481
+
482
+                foreach ( $subscriptions as $subscription ) {
483
+                    $subscription->cancel();
484
+                    $invoice->add_system_note(
485
+                        sprintf(
486
+                            // translators: %s: subscription ID.
487
+                            __( 'Subscription #%s cancelled', 'invoicing' ),
488
+                            $subscription->get_id()
489
+                        )
490
+                    );
491
+                }
492
+            }
493
+        }
494
+
495
+        // Add notice.
496
+        $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
497
+
498
+        // Redirect.
499
+        wp_safe_redirect(
500
+            remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
501
+        );
502
+    }
503
+
504
+    /**
505 505
      * Sends a payment reminder to a customer.
506
-	 *
507
-	 * @param array $args
506
+     *
507
+     * @param array $args
508 508
      */
509 509
     public function duplicate_payment_form( $args ) {
510 510
 
511
-		if ( empty( $args['form_id'] ) ) {
512
-			return;
513
-		}
514
-
515
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
511
+        if ( empty( $args['form_id'] ) ) {
512
+            return;
513
+        }
516 514
 
517
-		if ( ! $form->exists() ) {
518
-			return;
519
-		}
515
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
520 516
 
521
-		$new_form = new GetPaid_Payment_Form();
522
-		$new_form->set_author( $form->get_author( 'edit' ) );
523
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
524
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
525
-		$new_form->set_items( $form->get_items( 'edit' ) );
526
-		$new_form->save();
517
+        if ( ! $form->exists() ) {
518
+            return;
519
+        }
527 520
 
528
-		if ( $new_form->exists() ) {
529
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
530
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
531
-		} else {
532
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
533
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
534
-		}
521
+        $new_form = new GetPaid_Payment_Form();
522
+        $new_form->set_author( $form->get_author( 'edit' ) );
523
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
524
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
525
+        $new_form->set_items( $form->get_items( 'edit' ) );
526
+        $new_form->save();
527
+
528
+        if ( $new_form->exists() ) {
529
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
530
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
531
+        } else {
532
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
533
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
534
+        }
535 535
 
536
-		wp_redirect( $url );
537
-		exit;
538
-	}
536
+        wp_redirect( $url );
537
+        exit;
538
+    }
539 539
 
540
-	/**
540
+    /**
541 541
      * Resets form stats.
542
-	 *
543
-	 * @param array $args
542
+     *
543
+     * @param array $args
544 544
      */
545 545
     public function reset_form_stats( $args ) {
546 546
 
547
-		if ( empty( $args['form_id'] ) ) {
548
-			return;
549
-		}
547
+        if ( empty( $args['form_id'] ) ) {
548
+            return;
549
+        }
550 550
 
551
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
551
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
552 552
 
553
-		if ( ! $form->exists() ) {
554
-			return;
555
-		}
553
+        if ( ! $form->exists() ) {
554
+            return;
555
+        }
556 556
 
557
-		$form->set_earned( 0 );
558
-		$form->set_refunded( 0 );
559
-		$form->set_cancelled( 0 );
560
-		$form->set_failed( 0 );
561
-		$form->save();
557
+        $form->set_earned( 0 );
558
+        $form->set_refunded( 0 );
559
+        $form->set_cancelled( 0 );
560
+        $form->set_failed( 0 );
561
+        $form->save();
562 562
 
563
-		$this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
563
+        $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
564 564
 
565
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
566
-		exit;
567
-	}
565
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
566
+        exit;
567
+    }
568 568
 
569
-	/**
569
+    /**
570 570
      * Sends a payment reminder to a customer.
571
-	 *
572
-	 * @param array $args
571
+     *
572
+     * @param array $args
573 573
      */
574 574
     public function send_customer_invoice( $args ) {
575
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
576
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
577
-		exit;
578
-	}
575
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
576
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
577
+        exit;
578
+    }
579 579
 
580
-	/**
580
+    /**
581 581
      * Sends a payment reminder to a customer.
582
-	 *
583
-	 * @param array $args
582
+     *
583
+     * @param array $args
584 584
      */
585 585
     public function send_customer_payment_reminder( $args ) {
586
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
586
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
587 587
 
588
-		if ( $sent ) {
589
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
590
-		} else {
591
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
592
-		}
588
+        if ( $sent ) {
589
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
590
+        } else {
591
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
592
+        }
593 593
 
594
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
595
-		exit;
596
-	}
594
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
595
+        exit;
596
+    }
597 597
 
598
-	/**
598
+    /**
599 599
      * Resets tax rates.
600
-	 *
600
+     *
601 601
      */
602 602
     public function admin_reset_tax_rates() {
603 603
 
604
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
605
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
606
-		exit;
604
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
605
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
606
+        exit;
607 607
 
608
-	}
608
+    }
609 609
 
610
-	/**
610
+    /**
611 611
      * Resets admin pages.
612
-	 *
612
+     *
613 613
      */
614 614
     public function admin_create_missing_pages() {
615
-		$installer = new GetPaid_Installer();
616
-		$installer->create_pages();
617
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
618
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
619
-		exit;
620
-	}
621
-
622
-	/**
623
-	 * Refreshes the permalinks.
624
-	 */
625
-	public function admin_refresh_permalinks() {
626
-		flush_rewrite_rules();
627
-		$this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
628
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
629
-		exit;
630
-	}
631
-
632
-	/**
615
+        $installer = new GetPaid_Installer();
616
+        $installer->create_pages();
617
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
618
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
619
+        exit;
620
+    }
621
+
622
+    /**
623
+     * Refreshes the permalinks.
624
+     */
625
+    public function admin_refresh_permalinks() {
626
+        flush_rewrite_rules();
627
+        $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
628
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
629
+        exit;
630
+    }
631
+
632
+    /**
633 633
      * Creates missing admin tables.
634
-	 *
634
+     *
635 635
      */
636 636
     public function admin_create_missing_tables() {
637
-		global $wpdb;
637
+        global $wpdb;
638 638
 
639
-		GetPaid_Installer::create_db_tables();
640
-		GetPaid_Installer::migrate_old_customers();
639
+        GetPaid_Installer::create_db_tables();
640
+        GetPaid_Installer::migrate_old_customers();
641 641
 
642
-		if ( '' !== $wpdb->last_error ) {
643
-			$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
644
-		} else {
645
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
646
-		}
642
+        if ( '' !== $wpdb->last_error ) {
643
+            $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
644
+        } else {
645
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
646
+        }
647 647
 
648
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
649
-		exit;
650
-	}
648
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
649
+        exit;
650
+    }
651 651
 
652
-	/**
652
+    /**
653 653
      * Migrates old invoices to the new database tables.
654
-	 *
654
+     *
655 655
      */
656 656
     public function admin_migrate_old_invoices() {
657 657
 
658
-		// Migrate the invoices.
659
-		$installer = new GetPaid_Installer();
660
-		$installer->migrate_old_invoices();
658
+        // Migrate the invoices.
659
+        $installer = new GetPaid_Installer();
660
+        $installer->migrate_old_invoices();
661 661
 
662
-		// Show an admin message.
663
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
662
+        // Show an admin message.
663
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
664 664
 
665
-		// Redirect the admin.
666
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
667
-		exit;
665
+        // Redirect the admin.
666
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
667
+        exit;
668 668
 
669
-	}
669
+    }
670 670
 
671
-	/**
671
+    /**
672 672
      * Download customers.
673
-	 *
673
+     *
674 674
      */
675 675
     public function admin_download_customers() {
676 676
 
677
-		$output = fopen( 'php://output', 'w' );
677
+        $output = fopen( 'php://output', 'w' );
678 678
 
679
-		if ( false === $output ) {
680
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
681
-		}
679
+        if ( false === $output ) {
680
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
681
+        }
682 682
 
683
-		header( 'Content-Type:text/csv' );
684
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
683
+        header( 'Content-Type:text/csv' );
684
+        header( 'Content-Disposition:attachment;filename=customers.csv' );
685 685
 
686
-		/** @var GetPaid_Customer[] $customers */
687
-		$customers = getpaid_get_customers( array( 'number' => -1 ) );
688
-		$columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
686
+        /** @var GetPaid_Customer[] $customers */
687
+        $customers = getpaid_get_customers( array( 'number' => -1 ) );
688
+        $columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
689 689
 
690
-		// Output the csv column headers.
691
-		fputcsv( $output, $columns );
690
+        // Output the csv column headers.
691
+        fputcsv( $output, $columns );
692 692
 
693
-		// Loop through
694
-		foreach ( $customers as $customer ) {
693
+        // Loop through
694
+        foreach ( $customers as $customer ) {
695 695
 
696
-			$row  = array();
696
+            $row  = array();
697 697
 
698
-			foreach ( $columns as $column ) {
699
-				$row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
700
-			}
698
+            foreach ( $columns as $column ) {
699
+                $row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
700
+            }
701 701
 
702
-			fputcsv( $output, $row );
703
-		}
702
+            fputcsv( $output, $row );
703
+        }
704 704
 
705
-		fclose( $output );
706
-		exit;
705
+        fclose( $output );
706
+        exit;
707 707
 
708
-	}
708
+    }
709 709
 
710
-	/**
710
+    /**
711 711
      * Installs a plugin.
712
-	 *
713
-	 * @param array $data
712
+     *
713
+     * @param array $data
714 714
      */
715 715
     public function admin_install_plugin( $data ) {
716 716
 
717
-		if ( ! empty( $data['plugins'] ) ) {
718
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
719
-			wp_cache_flush();
717
+        if ( ! empty( $data['plugins'] ) ) {
718
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
719
+            wp_cache_flush();
720 720
 
721
-			foreach ( $data['plugins'] as $slug => $file ) {
722
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
723
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
724
-				$installed  = $upgrader->install( $plugin_zip );
721
+            foreach ( $data['plugins'] as $slug => $file ) {
722
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
723
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
724
+                $installed  = $upgrader->install( $plugin_zip );
725 725
 
726
-				if ( ! is_wp_error( $installed ) && $installed ) {
727
-					activate_plugin( $file, '', false, true );
728
-				} else {
729
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
730
-				}
726
+                if ( ! is_wp_error( $installed ) && $installed ) {
727
+                    activate_plugin( $file, '', false, true );
728
+                } else {
729
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
730
+                }
731 731
 }
732 732
 }
733 733
 
734
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
735
-		wp_safe_redirect( $redirect );
736
-		exit;
734
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
735
+        wp_safe_redirect( $redirect );
736
+        exit;
737 737
 
738
-	}
738
+    }
739 739
 
740
-	/**
740
+    /**
741 741
      * Connects a gateway.
742
-	 *
743
-	 * @param array $data
742
+     *
743
+     * @param array $data
744 744
      */
745 745
     public function admin_connect_gateway( $data ) {
746 746
 
747
-		if ( ! empty( $data['plugin'] ) ) {
747
+        if ( ! empty( $data['plugin'] ) ) {
748 748
 
749
-			$gateway     = sanitize_key( $data['plugin'] );
750
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
749
+            $gateway     = sanitize_key( $data['plugin'] );
750
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
751 751
 
752
-			if ( ! empty( $connect_url ) ) {
753
-				wp_redirect( $connect_url );
754
-				exit;
755
-			}
752
+            if ( ! empty( $connect_url ) ) {
753
+                wp_redirect( $connect_url );
754
+                exit;
755
+            }
756 756
 
757
-			if ( 'stripe' == $data['plugin'] ) {
758
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
759
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
760
-				wp_cache_flush();
757
+            if ( 'stripe' == $data['plugin'] ) {
758
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
759
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
760
+                wp_cache_flush();
761 761
 
762
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
763
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
764
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
765
-					$upgrader->install( $plugin_zip );
766
-				}
762
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
763
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
764
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
765
+                    $upgrader->install( $plugin_zip );
766
+                }
767 767
 
768
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
769
-			}
768
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
769
+            }
770 770
 
771
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
772
-			if ( ! empty( $connect_url ) ) {
773
-				wp_redirect( $connect_url );
774
-				exit;
775
-			}
771
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
772
+            if ( ! empty( $connect_url ) ) {
773
+                wp_redirect( $connect_url );
774
+                exit;
775
+            }
776 776
 }
777 777
 
778
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
779
-		wp_safe_redirect( $redirect );
780
-		exit;
778
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
779
+        wp_safe_redirect( $redirect );
780
+        exit;
781 781
 
782
-	}
782
+    }
783 783
 
784
-	/**
784
+    /**
785 785
      * Recalculates discounts.
786
-	 *
786
+     *
787 787
      */
788 788
     public function admin_recalculate_discounts() {
789
-		global $wpdb;
789
+        global $wpdb;
790 790
 
791
-		// Fetch all invoices that have discount codes.
792
-		$table    = $wpdb->prefix . 'getpaid_invoices';
793
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
791
+        // Fetch all invoices that have discount codes.
792
+        $table    = $wpdb->prefix . 'getpaid_invoices';
793
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
794 794
 
795
-		foreach ( $invoices as $invoice ) {
795
+        foreach ( $invoices as $invoice ) {
796 796
 
797
-			$invoice = new WPInv_Invoice( $invoice );
797
+            $invoice = new WPInv_Invoice( $invoice );
798 798
 
799
-			if ( ! $invoice->exists() ) {
800
-				continue;
801
-			}
799
+            if ( ! $invoice->exists() ) {
800
+                continue;
801
+            }
802 802
 
803
-			// Abort if the discount does not exist or does not apply here.
804
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
805
-			if ( ! $discount->exists() ) {
806
-				continue;
807
-			}
803
+            // Abort if the discount does not exist or does not apply here.
804
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
805
+            if ( ! $discount->exists() ) {
806
+                continue;
807
+            }
808 808
 
809
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
810
-			$invoice->recalculate_total();
809
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
810
+            $invoice->recalculate_total();
811 811
 
812
-			if ( $invoice->get_total_discount() > 0 ) {
813
-				$invoice->save();
814
-			}
812
+            if ( $invoice->get_total_discount() > 0 ) {
813
+                $invoice->save();
814
+            }
815 815
 }
816 816
 
817
-		// Show an admin message.
818
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
817
+        // Show an admin message.
818
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
819 819
 
820
-		// Redirect the admin.
821
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
822
-		exit;
820
+        // Redirect the admin.
821
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
822
+        exit;
823 823
 
824
-	}
824
+    }
825 825
 
826 826
     /**
827
-	 * Returns an array of admin notices.
828
-	 *
829
-	 * @since       1.0.19
827
+     * Returns an array of admin notices.
828
+     *
829
+     * @since       1.0.19
830 830
      * @return array
831
-	 */
832
-	public function get_notices() {
833
-		$notices = get_option( 'wpinv_admin_notices' );
831
+     */
832
+    public function get_notices() {
833
+        $notices = get_option( 'wpinv_admin_notices' );
834 834
         return is_array( $notices ) ? $notices : array();
835
-	}
835
+    }
836 836
 
837
-	/**
838
-	 * Checks if we have any admin notices.
839
-	 *
840
-	 * @since       2.0.4
837
+    /**
838
+     * Checks if we have any admin notices.
839
+     *
840
+     * @since       2.0.4
841 841
      * @return array
842
-	 */
843
-	public function has_notices() {
844
-		return count( $this->get_notices() ) > 0;
845
-	}
846
-
847
-	/**
848
-	 * Clears all admin notices
849
-	 *
850
-	 * @access      public
851
-	 * @since       1.0.19
852
-	 */
853
-	public function clear_notices() {
854
-		delete_option( 'wpinv_admin_notices' );
855
-	}
856
-
857
-	/**
858
-	 * Saves a new admin notice
859
-	 *
860
-	 * @access      public
861
-	 * @since       1.0.19
862
-	 */
863
-	public function save_notice( $type, $message ) {
864
-		$notices = $this->get_notices();
865
-
866
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
867
-			$notices[ $type ] = array();
868
-		}
869
-
870
-		$notices[ $type ][] = $message;
871
-
872
-		update_option( 'wpinv_admin_notices', $notices );
873
-	}
874
-
875
-	/**
876
-	 * Displays a success notice
877
-	 *
878
-	 * @param       string $msg The message to qeue.
879
-	 * @access      public
880
-	 * @since       1.0.19
881
-	 */
882
-	public function show_success( $msg ) {
883
-		$this->save_notice( 'success', $msg );
884
-	}
885
-
886
-	/**
887
-	 * Displays a error notice
888
-	 *
889
-	 * @access      public
890
-	 * @param       string $msg The message to qeue.
891
-	 * @since       1.0.19
892
-	 */
893
-	public function show_error( $msg ) {
894
-		$this->save_notice( 'error', $msg );
895
-	}
896
-
897
-	/**
898
-	 * Displays a warning notice
899
-	 *
900
-	 * @access      public
901
-	 * @param       string $msg The message to qeue.
902
-	 * @since       1.0.19
903
-	 */
904
-	public function show_warning( $msg ) {
905
-		$this->save_notice( 'warning', $msg );
906
-	}
907
-
908
-	/**
909
-	 * Displays a info notice
910
-	 *
911
-	 * @access      public
912
-	 * @param       string $msg The message to qeue.
913
-	 * @since       1.0.19
914
-	 */
915
-	public function show_info( $msg ) {
916
-		$this->save_notice( 'info', $msg );
917
-	}
918
-
919
-	/**
920
-	 * Show notices
921
-	 *
922
-	 * @access      public
923
-	 * @since       1.0.19
924
-	 */
925
-	public function show_notices() {
842
+     */
843
+    public function has_notices() {
844
+        return count( $this->get_notices() ) > 0;
845
+    }
846
+
847
+    /**
848
+     * Clears all admin notices
849
+     *
850
+     * @access      public
851
+     * @since       1.0.19
852
+     */
853
+    public function clear_notices() {
854
+        delete_option( 'wpinv_admin_notices' );
855
+    }
856
+
857
+    /**
858
+     * Saves a new admin notice
859
+     *
860
+     * @access      public
861
+     * @since       1.0.19
862
+     */
863
+    public function save_notice( $type, $message ) {
864
+        $notices = $this->get_notices();
865
+
866
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
867
+            $notices[ $type ] = array();
868
+        }
869
+
870
+        $notices[ $type ][] = $message;
871
+
872
+        update_option( 'wpinv_admin_notices', $notices );
873
+    }
874
+
875
+    /**
876
+     * Displays a success notice
877
+     *
878
+     * @param       string $msg The message to qeue.
879
+     * @access      public
880
+     * @since       1.0.19
881
+     */
882
+    public function show_success( $msg ) {
883
+        $this->save_notice( 'success', $msg );
884
+    }
885
+
886
+    /**
887
+     * Displays a error notice
888
+     *
889
+     * @access      public
890
+     * @param       string $msg The message to qeue.
891
+     * @since       1.0.19
892
+     */
893
+    public function show_error( $msg ) {
894
+        $this->save_notice( 'error', $msg );
895
+    }
896
+
897
+    /**
898
+     * Displays a warning notice
899
+     *
900
+     * @access      public
901
+     * @param       string $msg The message to qeue.
902
+     * @since       1.0.19
903
+     */
904
+    public function show_warning( $msg ) {
905
+        $this->save_notice( 'warning', $msg );
906
+    }
907
+
908
+    /**
909
+     * Displays a info notice
910
+     *
911
+     * @access      public
912
+     * @param       string $msg The message to qeue.
913
+     * @since       1.0.19
914
+     */
915
+    public function show_info( $msg ) {
916
+        $this->save_notice( 'info', $msg );
917
+    }
918
+
919
+    /**
920
+     * Show notices
921
+     *
922
+     * @access      public
923
+     * @since       1.0.19
924
+     */
925
+    public function show_notices() {
926 926
 
927 927
         $notices = $this->get_notices();
928 928
         $this->clear_notices();
929 929
 
930
-		foreach ( $notices as $type => $messages ) {
930
+        foreach ( $notices as $type => $messages ) {
931 931
 
932
-			if ( ! is_array( $messages ) ) {
933
-				continue;
934
-			}
932
+            if ( ! is_array( $messages ) ) {
933
+                continue;
934
+            }
935 935
 
936 936
             $type  = esc_attr( $type );
937
-			foreach ( $messages as $message ) {
938
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
937
+            foreach ( $messages as $message ) {
938
+                echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
939 939
             }
940 940
 }
941 941
 
942
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
943
-
944
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
945
-				$url     = wp_nonce_url(
946
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
947
-					'getpaid-nonce',
948
-					'getpaid-nonce'
949
-				);
950
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
951
-				$message2 = __( 'Generate Pages', 'invoicing' );
952
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
953
-				break;
954
-			}
942
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
943
+
944
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
945
+                $url     = wp_nonce_url(
946
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
947
+                    'getpaid-nonce',
948
+                    'getpaid-nonce'
949
+                );
950
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
951
+                $message2 = __( 'Generate Pages', 'invoicing' );
952
+                echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
953
+                break;
954
+            }
955 955
 }
956 956
 
957
-	}
957
+    }
958 958
 
959 959
 }
Please login to merge, or discard this patch.
Spacing   +279 added lines, -279 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
  * The main admin class.
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,36 +54,36 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
70
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
76
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
77
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
78
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
79
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
80
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_reset_form_stats', array($this, 'reset_form_stats'));
66
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_refund_invoice', array($this, 'refund_invoice'));
68
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
69
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
70
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
71
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
72
+		add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks'));
73
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
74
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
75
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
76
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
77
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
78
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
79
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
80
+		do_action('getpaid_init_admin_hooks', $this);
81 81
 
82 82
 		// Setup/welcome
83
-		if ( ! empty( $_GET['page'] ) ) {
84
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
83
+		if (!empty($_GET['page'])) {
84
+			switch (sanitize_text_field($_GET['page'])) {
85 85
 				case 'gp-setup':
86
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
86
+					include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php';
87 87
 					break;
88 88
 			}
89 89
 		}
@@ -97,37 +97,37 @@  discard block
 block discarded – undo
97 97
 	public function enqeue_scripts() {
98 98
         global $current_screen, $pagenow;
99 99
 
100
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
100
+		$page    = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
101 101
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
102 102
 
103
-        if ( ! empty( $current_screen->post_type ) ) {
103
+        if (!empty($current_screen->post_type)) {
104 104
 			$page = $current_screen->post_type;
105 105
         }
106 106
 
107 107
         // General styles.
108
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) {
108
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) {
109 109
 
110 110
             // Styles.
111
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
112
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
113
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
111
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
112
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
113
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
114 114
 
115 115
             // Scripts.
116
-            wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
116
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
117 117
 
118
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
119
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version );
120
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
118
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
119
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
120
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
121 121
 
122 122
         }
123 123
 
124 124
         // Payment form scripts.
125
-		if ( 'wpi_payment_form' == $page && $editing ) {
125
+		if ('wpi_payment_form' == $page && $editing) {
126 126
             $this->load_payment_form_scripts();
127 127
         }
128 128
 
129
-		if ( $page == 'wpinv-subscriptions' ) {
130
-			wp_enqueue_script( 'postbox' );
129
+		if ($page == 'wpinv-subscriptions') {
130
+			wp_enqueue_script('postbox');
131 131
 		}
132 132
 
133 133
     }
@@ -140,31 +140,31 @@  discard block
 block discarded – undo
140 140
         global $post;
141 141
 
142 142
 		$date_range = array(
143
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
143
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days',
144 144
 		);
145 145
 
146
-		if ( $date_range['period'] == 'custom' ) {
146
+		if ($date_range['period'] == 'custom') {
147 147
 
148
-			if ( isset( $_GET['from'] ) ) {
149
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
148
+			if (isset($_GET['from'])) {
149
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
150 150
 			}
151 151
 
152
-			if ( isset( $_GET['to'] ) ) {
153
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
152
+			if (isset($_GET['to'])) {
153
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
154 154
 			}
155 155
 }
156 156
 
157 157
         $i18n = array(
158
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
159
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
160
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
161
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
162
-			'rest_root'                 => esc_url_raw( rest_url() ),
158
+            'ajax_url'                  => admin_url('admin-ajax.php'),
159
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
160
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
161
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
162
+			'rest_root'                 => esc_url_raw(rest_url()),
163 163
 			'date_range'                => $date_range,
164
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
165
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
166
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
167
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
164
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
165
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
166
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
167
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
168 168
             'tax'                       => wpinv_tax_amount(),
169 169
             'discount'                  => 0,
170 170
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -173,39 +173,39 @@  discard block
 block discarded – undo
173 173
             'thousand_sep'              => wpinv_thousands_separator(),
174 174
             'decimal_sep'               => wpinv_decimal_separator(),
175 175
             'decimals'                  => wpinv_decimals(),
176
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
177
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
180
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
181
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
182
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
183
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
184
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
185
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
186
-            'action_edit'               => __( 'Edit', 'invoicing' ),
187
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
188
-            'item_description'          => __( 'Item Description', 'invoicing' ),
189
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
190
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
191
-			'searching'                 => __( 'Searching', 'invoicing' ),
192
-			'loading'                   => __( 'Loading...', 'invoicing' ),
193
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
194
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
195
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
176
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
177
+            'status_publish'            => wpinv_status_nicename('publish'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
180
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
181
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
182
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
183
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
184
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
185
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
186
+            'action_edit'               => __('Edit', 'invoicing'),
187
+            'action_cancel'             => __('Cancel', 'invoicing'),
188
+            'item_description'          => __('Item Description', 'invoicing'),
189
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
190
+            'discount_description'      => __('Discount Description', 'invoicing'),
191
+			'searching'                 => __('Searching', 'invoicing'),
192
+			'loading'                   => __('Loading...', 'invoicing'),
193
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
194
+			'search_items'              => __('Enter item name', 'invoicing'),
195
+			'graphs'                    => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())),
196 196
         );
197 197
 
198
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
198
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
199 199
 
200
-			$invoice              = new WPInv_Invoice( $post );
200
+			$invoice              = new WPInv_Invoice($post);
201 201
 			$i18n['save_invoice'] = sprintf(
202
-				__( 'Save %s', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
202
+				__('Save %s', 'invoicing'),
203
+				ucfirst($invoice->get_invoice_quote_type())
204 204
 			);
205 205
 
206 206
 			$i18n['invoice_description'] = sprintf(
207
-				__( '%s Description', 'invoicing' ),
208
-				ucfirst( $invoice->get_invoice_quote_type() )
207
+				__('%s Description', 'invoicing'),
208
+				ucfirst($invoice->get_invoice_quote_type())
209 209
 			);
210 210
 
211 211
 		}
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
 	 * @param  string $footer_text
220 220
 	 * @return string
221 221
 	 */
222
-	public function admin_footer_text( $footer_text ) {
222
+	public function admin_footer_text($footer_text) {
223 223
 		global $current_screen;
224 224
 
225
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
225
+		$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
226 226
 
227
-        if ( ! empty( $current_screen->post_type ) ) {
227
+        if (!empty($current_screen->post_type)) {
228 228
 			$page = $current_screen->post_type;
229 229
         }
230 230
 
231 231
         // General styles.
232
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
232
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
233 233
 
234 234
 			// Change the footer text
235
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
235
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
236 236
 
237
-				$rating_url  = esc_url(
237
+				$rating_url = esc_url(
238 238
 					wp_nonce_url(
239
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
239
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
240 240
 						'getpaid-nonce',
241 241
 						'getpaid-nonce'
242 242
                     )
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 				$footer_text = sprintf(
246 246
 					/* translators: %s: five stars */
247
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
247
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
248 248
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
249 249
 				);
250 250
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 				$footer_text = sprintf(
254 254
 					/* translators: %s: GetPaid */
255
-					__( 'Thank you for using %s!', 'invoicing' ),
255
+					__('Thank you for using %s!', 'invoicing'),
256 256
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
257 257
 				);
258 258
 
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @since  2.0.0
269 269
 	 */
270 270
 	public function redirect_to_wordpress_rating_page() {
271
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
272
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
272
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
273 273
 		exit;
274 274
 	}
275 275
 
@@ -280,30 +280,30 @@  discard block
 block discarded – undo
280 280
 	protected function load_payment_form_scripts() {
281 281
         global $post;
282 282
 
283
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
284
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
285
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
284
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
285
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
286 286
 
287
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
288
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
287
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
288
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version);
289 289
 
290 290
 		wp_localize_script(
291 291
             'wpinv-admin-payment-form-script',
292 292
             'wpinvPaymentFormAdmin',
293 293
             array(
294
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
295
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
+				'elements'      => wpinv_get_data('payment-form-elements'),
295
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
296 296
 				'currency'      => wpinv_currency_symbol(),
297 297
 				'position'      => wpinv_currency_position(),
298 298
 				'decimals'      => (int) wpinv_decimals(),
299 299
 				'thousands_sep' => wpinv_thousands_separator(),
300 300
 				'decimals_sep'  => wpinv_decimal_separator(),
301
-				'form_items'    => gepaid_get_form_items( $post->ID ),
301
+				'form_items'    => gepaid_get_form_items($post->ID),
302 302
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
303 303
             )
304 304
         );
305 305
 
306
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
306
+        wp_enqueue_script('wpinv-admin-payment-form-script');
307 307
 
308 308
     }
309 309
 
@@ -314,24 +314,24 @@  discard block
 block discarded – undo
314 314
      * @return string
315 315
 	 *
316 316
 	 */
317
-    public function admin_body_class( $classes ) {
317
+    public function admin_body_class($classes) {
318 318
 		global $pagenow, $post, $current_screen;
319 319
 
320
-        $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
320
+        $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
321 321
 
322
-        if ( ! empty( $current_screen->post_type ) ) {
322
+        if (!empty($current_screen->post_type)) {
323 323
 			$page = $current_screen->post_type;
324 324
         }
325 325
 
326
-        if ( false !== stripos( $page, 'wpi' ) ) {
327
-            $classes .= ' wpi-' . sanitize_key( $page );
326
+        if (false !== stripos($page, 'wpi')) {
327
+            $classes .= ' wpi-' . sanitize_key($page);
328 328
         }
329 329
 
330
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
331 331
             $classes .= ' wpinv-cpt wpinv';
332 332
 		}
333 333
 
334
-		if ( getpaid_is_invoice_post_type( $page ) ) {
334
+		if (getpaid_is_invoice_post_type($page)) {
335 335
             $classes .= ' getpaid-is-invoice-cpt';
336 336
         }
337 337
 
@@ -350,21 +350,21 @@  discard block
 block discarded – undo
350 350
 				'version'           => WPINV_VERSION,
351 351
 				'support_url'       => 'https://wpgetpaid.com/support/',
352 352
 				'documentation_url' => 'https://docs.wpgetpaid.com/',
353
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
353
+				'activated'         => (int) get_option('gepaid_installed_on'),
354 354
             )
355 355
         );
356 356
 
357 357
         new AyeCode_Connect_Helper(
358 358
             array(
359
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
360
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
361
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
362
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
363
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
364
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
365
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
359
+				'connect_title'     => __('WP Invoicing - an AyeCode product!', 'invoicing'),
360
+				'connect_external'  => __('Please confirm you wish to connect your site?', 'invoicing'),
361
+				'connect'           => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'),
362
+				'connect_button'    => __('Connect Site', 'invoicing'),
363
+				'connecting_button' => __('Connecting...', 'invoicing'),
364
+				'error_localhost'   => __('This service will only work with a live domain, not a localhost.', 'invoicing'),
365
+				'error'             => __('Something went wrong, please refresh and try again.', 'invoicing'),
366 366
             ),
367
-            array( 'wpi-addons' )
367
+            array('wpi-addons')
368 368
         );
369 369
 
370 370
     }
@@ -376,20 +376,20 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function activation_redirect() {
378 378
 
379
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
379
+		$redirected = get_option('wpinv_redirected_to_settings');
380 380
 
381
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
381
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
382 382
 			return;
383 383
 		}
384 384
 
385 385
 		// Bail if activating from network, or bulk
386
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
386
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
387 387
 			return;
388 388
 		}
389 389
 
390
-	    update_option( 'wpinv_redirected_to_settings', 1 );
390
+	    update_option('wpinv_redirected_to_settings', 1);
391 391
 
392
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
392
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
393 393
         exit;
394 394
 
395 395
 	}
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
      * Fires an admin action after verifying that a user can fire them.
399 399
      */
400 400
     public function maybe_do_admin_action() {
401
-        if ( isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) && wpinv_current_user_can( sanitize_text_field( $_REQUEST['getpaid-admin-action'] ), $_REQUEST ) ) {
402
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
+        if (isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce') && wpinv_current_user_can(sanitize_text_field($_REQUEST['getpaid-admin-action']), $_REQUEST)) {
402
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
403 403
 
404
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
404
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
405 405
         }
406 406
     }
407 407
 
@@ -410,24 +410,24 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @param array $args
412 412
      */
413
-    public function duplicate_invoice( $args ) {
413
+    public function duplicate_invoice($args) {
414 414
 
415
-		if ( empty( $args['invoice_id'] ) ) {
415
+		if (empty($args['invoice_id'])) {
416 416
 			return;
417 417
 		}
418 418
 
419
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
419
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
420 420
 
421
-		if ( ! $invoice->exists() ) {
421
+		if (!$invoice->exists()) {
422 422
 			return;
423 423
 		}
424 424
 
425
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
425
+		$new_invoice = getpaid_duplicate_invoice($invoice);
426 426
 		$new_invoice->save();
427 427
 
428
-		if ( $new_invoice->exists() ) {
428
+		if ($new_invoice->exists()) {
429 429
 
430
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) );
430
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'invoicing'));
431 431
 
432 432
 			wp_safe_redirect(
433 433
 				add_query_arg(
@@ -435,14 +435,14 @@  discard block
 block discarded – undo
435 435
 						'action' => 'edit',
436 436
 						'post'   => $new_invoice->get_id(),
437 437
 					),
438
-					admin_url( 'post.php' )
438
+					admin_url('post.php')
439 439
 				)
440 440
 			);
441 441
 			exit;
442 442
 
443 443
 		}
444 444
 
445
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) );
445
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'invoicing'));
446 446
 
447 447
 	}
448 448
 
@@ -451,40 +451,40 @@  discard block
 block discarded – undo
451 451
 	 *
452 452
 	 * @param array $args
453 453
      */
454
-    public function refund_invoice( $args ) {
454
+    public function refund_invoice($args) {
455 455
 
456
-		if ( empty( $args['invoice_id'] ) ) {
456
+		if (empty($args['invoice_id'])) {
457 457
 			return;
458 458
 		}
459 459
 
460
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
460
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
461 461
 
462
-		if ( ! $invoice->exists() || $invoice->is_refunded() ) {
462
+		if (!$invoice->exists() || $invoice->is_refunded()) {
463 463
 			return;
464 464
 		}
465 465
 
466 466
 		$invoice->refund();
467 467
 
468 468
 		// Refund remotely.
469
-		if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) {
470
-			do_action( 'getpaid_refund_invoice_remotely', $invoice );
469
+		if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds') && !empty($args['getpaid_refund_remote'])) {
470
+			do_action('getpaid_refund_invoice_remotely', $invoice);
471 471
 		}
472 472
 
473 473
 		// Cancel subscriptions.
474
-		if ( ! empty( $args['getpaid_cancel_subscription'] ) ) {
475
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
474
+		if (!empty($args['getpaid_cancel_subscription'])) {
475
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
476 476
 
477
-			if ( ! empty( $subscriptions ) ) {
478
-				if ( ! is_array( $subscriptions ) ) {
479
-					$subscriptions = array( $subscriptions );
477
+			if (!empty($subscriptions)) {
478
+				if (!is_array($subscriptions)) {
479
+					$subscriptions = array($subscriptions);
480 480
 				}
481 481
 
482
-				foreach ( $subscriptions as $subscription ) {
482
+				foreach ($subscriptions as $subscription) {
483 483
 					$subscription->cancel();
484 484
 					$invoice->add_system_note(
485 485
 						sprintf(
486 486
 							// translators: %s: subscription ID.
487
-							__( 'Subscription #%s cancelled', 'invoicing' ),
487
+							__('Subscription #%s cancelled', 'invoicing'),
488 488
 							$subscription->get_id()
489 489
 						)
490 490
 					);
@@ -493,11 +493,11 @@  discard block
 block discarded – undo
493 493
 		}
494 494
 
495 495
 		// Add notice.
496
-		$this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) );
496
+		$this->show_success(__('Invoice refunded successfully.', 'invoicing'));
497 497
 
498 498
 		// Redirect.
499 499
 		wp_safe_redirect(
500
-			remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) )
500
+			remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote'))
501 501
 		);
502 502
 	}
503 503
 
@@ -506,34 +506,34 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @param array $args
508 508
      */
509
-    public function duplicate_payment_form( $args ) {
509
+    public function duplicate_payment_form($args) {
510 510
 
511
-		if ( empty( $args['form_id'] ) ) {
511
+		if (empty($args['form_id'])) {
512 512
 			return;
513 513
 		}
514 514
 
515
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
515
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
516 516
 
517
-		if ( ! $form->exists() ) {
517
+		if (!$form->exists()) {
518 518
 			return;
519 519
 		}
520 520
 
521 521
 		$new_form = new GetPaid_Payment_Form();
522
-		$new_form->set_author( $form->get_author( 'edit' ) );
523
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
524
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
525
-		$new_form->set_items( $form->get_items( 'edit' ) );
522
+		$new_form->set_author($form->get_author('edit'));
523
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
524
+		$new_form->set_elements($form->get_elements('edit'));
525
+		$new_form->set_items($form->get_items('edit'));
526 526
 		$new_form->save();
527 527
 
528
-		if ( $new_form->exists() ) {
529
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
530
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
528
+		if ($new_form->exists()) {
529
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
530
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
531 531
 		} else {
532
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
533
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
532
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
533
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
534 534
 		}
535 535
 
536
-		wp_redirect( $url );
536
+		wp_redirect($url);
537 537
 		exit;
538 538
 	}
539 539
 
@@ -542,27 +542,27 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @param array $args
544 544
      */
545
-    public function reset_form_stats( $args ) {
545
+    public function reset_form_stats($args) {
546 546
 
547
-		if ( empty( $args['form_id'] ) ) {
547
+		if (empty($args['form_id'])) {
548 548
 			return;
549 549
 		}
550 550
 
551
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
551
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
552 552
 
553
-		if ( ! $form->exists() ) {
553
+		if (!$form->exists()) {
554 554
 			return;
555 555
 		}
556 556
 
557
-		$form->set_earned( 0 );
558
-		$form->set_refunded( 0 );
559
-		$form->set_cancelled( 0 );
560
-		$form->set_failed( 0 );
557
+		$form->set_earned(0);
558
+		$form->set_refunded(0);
559
+		$form->set_cancelled(0);
560
+		$form->set_failed(0);
561 561
 		$form->save();
562 562
 
563
-		$this->show_success( __( 'Form stats reset successfully', 'invoicing' ) );
563
+		$this->show_success(__('Form stats reset successfully', 'invoicing'));
564 564
 
565
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) );
565
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')));
566 566
 		exit;
567 567
 	}
568 568
 
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 	 *
572 572
 	 * @param array $args
573 573
      */
574
-    public function send_customer_invoice( $args ) {
575
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
576
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
574
+    public function send_customer_invoice($args) {
575
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
576
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
577 577
 		exit;
578 578
 	}
579 579
 
@@ -582,16 +582,16 @@  discard block
 block discarded – undo
582 582
 	 *
583 583
 	 * @param array $args
584 584
      */
585
-    public function send_customer_payment_reminder( $args ) {
586
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
585
+    public function send_customer_payment_reminder($args) {
586
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
587 587
 
588
-		if ( $sent ) {
589
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
588
+		if ($sent) {
589
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
590 590
 		} else {
591
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
591
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
592 592
 		}
593 593
 
594
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
594
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
595 595
 		exit;
596 596
 	}
597 597
 
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
      */
602 602
     public function admin_reset_tax_rates() {
603 603
 
604
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
605
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
604
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
605
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
606 606
 		exit;
607 607
 
608 608
 	}
@@ -614,8 +614,8 @@  discard block
 block discarded – undo
614 614
     public function admin_create_missing_pages() {
615 615
 		$installer = new GetPaid_Installer();
616 616
 		$installer->create_pages();
617
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
618
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
617
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
618
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
619 619
 		exit;
620 620
 	}
621 621
 
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public function admin_refresh_permalinks() {
626 626
 		flush_rewrite_rules();
627
-		$this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) );
628
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
627
+		$this->show_success(__('Permalinks refreshed.', 'invoicing'));
628
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
629 629
 		exit;
630 630
 	}
631 631
 
@@ -639,13 +639,13 @@  discard block
 block discarded – undo
639 639
 		GetPaid_Installer::create_db_tables();
640 640
 		GetPaid_Installer::migrate_old_customers();
641 641
 
642
-		if ( '' !== $wpdb->last_error ) {
643
-			$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
642
+		if ('' !== $wpdb->last_error) {
643
+			$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
644 644
 		} else {
645
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
645
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
646 646
 		}
647 647
 
648
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
648
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
649 649
 		exit;
650 650
 	}
651 651
 
@@ -660,10 +660,10 @@  discard block
 block discarded – undo
660 660
 		$installer->migrate_old_invoices();
661 661
 
662 662
 		// Show an admin message.
663
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
663
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
664 664
 
665 665
 		// Redirect the admin.
666
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
666
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
667 667
 		exit;
668 668
 
669 669
 	}
@@ -674,35 +674,35 @@  discard block
 block discarded – undo
674 674
      */
675 675
     public function admin_download_customers() {
676 676
 
677
-		$output = fopen( 'php://output', 'w' );
677
+		$output = fopen('php://output', 'w');
678 678
 
679
-		if ( false === $output ) {
680
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
679
+		if (false === $output) {
680
+			wp_die(esc_html__('Unsupported server', 'invoicing'), 500);
681 681
 		}
682 682
 
683
-		header( 'Content-Type:text/csv' );
684
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
683
+		header('Content-Type:text/csv');
684
+		header('Content-Disposition:attachment;filename=customers.csv');
685 685
 
686 686
 		/** @var GetPaid_Customer[] $customers */
687
-		$customers = getpaid_get_customers( array( 'number' => -1 ) );
688
-		$columns   = array_keys( GetPaid_Customer_Data_Store::get_database_fields() );
687
+		$customers = getpaid_get_customers(array('number' => -1));
688
+		$columns   = array_keys(GetPaid_Customer_Data_Store::get_database_fields());
689 689
 
690 690
 		// Output the csv column headers.
691
-		fputcsv( $output, $columns );
691
+		fputcsv($output, $columns);
692 692
 
693 693
 		// Loop through
694
-		foreach ( $customers as $customer ) {
694
+		foreach ($customers as $customer) {
695 695
 
696
-			$row  = array();
696
+			$row = array();
697 697
 
698
-			foreach ( $columns as $column ) {
699
-				$row[]  = (string) maybe_serialize( $customer->get( $column, 'edit' ) );
698
+			foreach ($columns as $column) {
699
+				$row[] = (string) maybe_serialize($customer->get($column, 'edit'));
700 700
 			}
701 701
 
702
-			fputcsv( $output, $row );
702
+			fputcsv($output, $row);
703 703
 		}
704 704
 
705
-		fclose( $output );
705
+		fclose($output);
706 706
 		exit;
707 707
 
708 708
 	}
@@ -712,27 +712,27 @@  discard block
 block discarded – undo
712 712
 	 *
713 713
 	 * @param array $data
714 714
      */
715
-    public function admin_install_plugin( $data ) {
715
+    public function admin_install_plugin($data) {
716 716
 
717
-		if ( ! empty( $data['plugins'] ) ) {
717
+		if (!empty($data['plugins'])) {
718 718
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
719 719
 			wp_cache_flush();
720 720
 
721
-			foreach ( $data['plugins'] as $slug => $file ) {
722
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
723
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
724
-				$installed  = $upgrader->install( $plugin_zip );
721
+			foreach ($data['plugins'] as $slug => $file) {
722
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
723
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
724
+				$installed  = $upgrader->install($plugin_zip);
725 725
 
726
-				if ( ! is_wp_error( $installed ) && $installed ) {
727
-					activate_plugin( $file, '', false, true );
726
+				if (!is_wp_error($installed) && $installed) {
727
+					activate_plugin($file, '', false, true);
728 728
 				} else {
729
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
729
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
730 730
 				}
731 731
 }
732 732
 }
733 733
 
734
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
735
-		wp_safe_redirect( $redirect );
734
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
735
+		wp_safe_redirect($redirect);
736 736
 		exit;
737 737
 
738 738
 	}
@@ -742,41 +742,41 @@  discard block
 block discarded – undo
742 742
 	 *
743 743
 	 * @param array $data
744 744
      */
745
-    public function admin_connect_gateway( $data ) {
745
+    public function admin_connect_gateway($data) {
746 746
 
747
-		if ( ! empty( $data['plugin'] ) ) {
747
+		if (!empty($data['plugin'])) {
748 748
 
749
-			$gateway     = sanitize_key( $data['plugin'] );
750
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
749
+			$gateway     = sanitize_key($data['plugin']);
750
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
751 751
 
752
-			if ( ! empty( $connect_url ) ) {
753
-				wp_redirect( $connect_url );
752
+			if (!empty($connect_url)) {
753
+				wp_redirect($connect_url);
754 754
 				exit;
755 755
 			}
756 756
 
757
-			if ( 'stripe' == $data['plugin'] ) {
757
+			if ('stripe' == $data['plugin']) {
758 758
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
759 759
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
760 760
 				wp_cache_flush();
761 761
 
762
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
763
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
764
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
765
-					$upgrader->install( $plugin_zip );
762
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
763
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
764
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
765
+					$upgrader->install($plugin_zip);
766 766
 				}
767 767
 
768
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
768
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
769 769
 			}
770 770
 
771
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
772
-			if ( ! empty( $connect_url ) ) {
773
-				wp_redirect( $connect_url );
771
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
772
+			if (!empty($connect_url)) {
773
+				wp_redirect($connect_url);
774 774
 				exit;
775 775
 			}
776 776
 }
777 777
 
778
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
779
-		wp_safe_redirect( $redirect );
778
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
779
+		wp_safe_redirect($redirect);
780 780
 		exit;
781 781
 
782 782
 	}
@@ -790,35 +790,35 @@  discard block
 block discarded – undo
790 790
 
791 791
 		// Fetch all invoices that have discount codes.
792 792
 		$table    = $wpdb->prefix . 'getpaid_invoices';
793
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
793
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
794 794
 
795
-		foreach ( $invoices as $invoice ) {
795
+		foreach ($invoices as $invoice) {
796 796
 
797
-			$invoice = new WPInv_Invoice( $invoice );
797
+			$invoice = new WPInv_Invoice($invoice);
798 798
 
799
-			if ( ! $invoice->exists() ) {
799
+			if (!$invoice->exists()) {
800 800
 				continue;
801 801
 			}
802 802
 
803 803
 			// Abort if the discount does not exist or does not apply here.
804
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
805
-			if ( ! $discount->exists() ) {
804
+			$discount = new WPInv_Discount($invoice->get_discount_code());
805
+			if (!$discount->exists()) {
806 806
 				continue;
807 807
 			}
808 808
 
809
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
809
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
810 810
 			$invoice->recalculate_total();
811 811
 
812
-			if ( $invoice->get_total_discount() > 0 ) {
812
+			if ($invoice->get_total_discount() > 0) {
813 813
 				$invoice->save();
814 814
 			}
815 815
 }
816 816
 
817 817
 		// Show an admin message.
818
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
818
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
819 819
 
820 820
 		// Redirect the admin.
821
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
821
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
822 822
 		exit;
823 823
 
824 824
 	}
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
      * @return array
831 831
 	 */
832 832
 	public function get_notices() {
833
-		$notices = get_option( 'wpinv_admin_notices' );
834
-        return is_array( $notices ) ? $notices : array();
833
+		$notices = get_option('wpinv_admin_notices');
834
+        return is_array($notices) ? $notices : array();
835 835
 	}
836 836
 
837 837
 	/**
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
      * @return array
842 842
 	 */
843 843
 	public function has_notices() {
844
-		return count( $this->get_notices() ) > 0;
844
+		return count($this->get_notices()) > 0;
845 845
 	}
846 846
 
847 847
 	/**
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 	 * @since       1.0.19
852 852
 	 */
853 853
 	public function clear_notices() {
854
-		delete_option( 'wpinv_admin_notices' );
854
+		delete_option('wpinv_admin_notices');
855 855
 	}
856 856
 
857 857
 	/**
@@ -860,16 +860,16 @@  discard block
 block discarded – undo
860 860
 	 * @access      public
861 861
 	 * @since       1.0.19
862 862
 	 */
863
-	public function save_notice( $type, $message ) {
863
+	public function save_notice($type, $message) {
864 864
 		$notices = $this->get_notices();
865 865
 
866
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
867
-			$notices[ $type ] = array();
866
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
867
+			$notices[$type] = array();
868 868
 		}
869 869
 
870
-		$notices[ $type ][] = $message;
870
+		$notices[$type][] = $message;
871 871
 
872
-		update_option( 'wpinv_admin_notices', $notices );
872
+		update_option('wpinv_admin_notices', $notices);
873 873
 	}
874 874
 
875 875
 	/**
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	 * @access      public
880 880
 	 * @since       1.0.19
881 881
 	 */
882
-	public function show_success( $msg ) {
883
-		$this->save_notice( 'success', $msg );
882
+	public function show_success($msg) {
883
+		$this->save_notice('success', $msg);
884 884
 	}
885 885
 
886 886
 	/**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 	 * @param       string $msg The message to qeue.
891 891
 	 * @since       1.0.19
892 892
 	 */
893
-	public function show_error( $msg ) {
894
-		$this->save_notice( 'error', $msg );
893
+	public function show_error($msg) {
894
+		$this->save_notice('error', $msg);
895 895
 	}
896 896
 
897 897
 	/**
@@ -901,8 +901,8 @@  discard block
 block discarded – undo
901 901
 	 * @param       string $msg The message to qeue.
902 902
 	 * @since       1.0.19
903 903
 	 */
904
-	public function show_warning( $msg ) {
905
-		$this->save_notice( 'warning', $msg );
904
+	public function show_warning($msg) {
905
+		$this->save_notice('warning', $msg);
906 906
 	}
907 907
 
908 908
 	/**
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
 	 * @param       string $msg The message to qeue.
913 913
 	 * @since       1.0.19
914 914
 	 */
915
-	public function show_info( $msg ) {
916
-		$this->save_notice( 'info', $msg );
915
+	public function show_info($msg) {
916
+		$this->save_notice('info', $msg);
917 917
 	}
918 918
 
919 919
 	/**
@@ -927,29 +927,29 @@  discard block
 block discarded – undo
927 927
         $notices = $this->get_notices();
928 928
         $this->clear_notices();
929 929
 
930
-		foreach ( $notices as $type => $messages ) {
930
+		foreach ($notices as $type => $messages) {
931 931
 
932
-			if ( ! is_array( $messages ) ) {
932
+			if (!is_array($messages)) {
933 933
 				continue;
934 934
 			}
935 935
 
936
-            $type  = esc_attr( $type );
937
-			foreach ( $messages as $message ) {
938
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
936
+            $type = esc_attr($type);
937
+			foreach ($messages as $message) {
938
+				echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>");
939 939
             }
940 940
 }
941 941
 
942
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
942
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
943 943
 
944
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
945
-				$url     = wp_nonce_url(
946
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
944
+			if (!is_numeric(wpinv_get_option($page, false))) {
945
+				$url = wp_nonce_url(
946
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
947 947
 					'getpaid-nonce',
948 948
 					'getpaid-nonce'
949 949
 				);
950
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
951
-				$message2 = __( 'Generate Pages', 'invoicing' );
952
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
950
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
951
+				$message2 = __('Generate Pages', 'invoicing');
952
+				echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>");
953 953
 				break;
954 954
 			}
955 955
 }
Please login to merge, or discard this patch.