Passed
Pull Request — master (#860)
by Kiran
08:35 queued 02:43
created
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
Indentation   +859 added lines, -859 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,414 +21,414 @@  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.10';
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.10';
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 enabled
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
-					$enqueue = false;
186
-
187
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
188
-						$enqueue = true;
189
-						add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
190
-					}
191
-
192
-					if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
193
-						$enqueue = true;
194
-						add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
195
-						add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
196
-					}
197
-
198
-					if ( $enqueue ) {
199
-						add_filter( 'script_loader_tag', array( $this, 'script_loader_tag' ), 20, 3 );
200
-					}
201
-				}
202
-
203
-				// remove font awesome if set to do so
204
-				if ( $this->settings['dequeue'] == '1' ) {
205
-					add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
206
-				}
207
-			}
208
-
209
-		}
210
-
211
-		/**
212
-		 * Add FA to the FSE.
213
-		 *
214
-		 * @param $editor_settings
215
-		 * @param $block_editor_context
216
-		 *
217
-		 * @return array
218
-		 */
219
-		public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
220
-
221
-			if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
222
-				$url = $this->get_url();
223
-				$editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
224
-			}
225
-
226
-			return $editor_settings;
227
-		}
228
-
229
-		/**
230
-		 * Add FA to the FSE.
231
-		 *
232
-		 * @param $editor_settings
233
-		 * @param $block_editor_context
234
-		 *
235
-		 * @return array
236
-		 */
237
-		public function enqueue_editor_scripts( $editor_settings, $block_editor_context ) {
238
-			$url = $this->get_url();
239
-
240
-			$editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js' defer crossorigin='anonymous'></script>";
241
-
242
-			return $editor_settings;
243
-		}
244
-
245
-		/**
246
-		 * Adds the Font Awesome styles.
247
-		 */
248
-		public function enqueue_style() {
249
-			// build url
250
-			$url = $this->get_url();
251
-			$version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
252
-
253
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
254
-			wp_register_style( 'font-awesome', $url, array(), $version );
255
-			wp_enqueue_style( 'font-awesome' );
256
-
257
-			// RTL language support CSS.
258
-			if ( is_rtl() ) {
259
-				wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
260
-			}
261
-
262
-			if ( $this->settings['shims'] ) {
263
-				$url = $this->get_url( true );
264
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
265
-				wp_register_style( 'font-awesome-shims', $url, array(), $version );
266
-				wp_enqueue_style( 'font-awesome-shims' );
267
-			}
268
-		}
269
-
270
-		/**
271
-		 * Adds the Font Awesome JS.
272
-		 */
273
-		public function enqueue_scripts() {
274
-			// build url
275
-			$url = $this->get_url();
276
-
277
-			$deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
278
-			call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
279
-			wp_register_script( 'font-awesome', $url, array(), null );
280
-			wp_enqueue_script( 'font-awesome' );
281
-
282
-			if ( $this->settings['shims'] ) {
283
-				$url = $this->get_url( true );
284
-				call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
285
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
286
-				wp_enqueue_script( 'font-awesome-shims' );
287
-			}
288
-		}
289
-
290
-		/**
291
-		 * Get the url of the Font Awesome files.
292
-		 *
293
-		 * @param bool $shims If this is a shim file or not.
294
-		 * @param bool $local Load locally if allowed.
295
-		 *
296
-		 * @return string The url to the file.
297
-		 */
298
-		public function get_url( $shims = false, $local = true ) {
299
-			$script  = $shims ? 'v4-shims' : 'all';
300
-			$sub     = $this->settings['pro'] ? 'pro' : 'use';
301
-			$type    = $this->settings['type'];
302
-			$version = $this->settings['version'];
303
-			$kit_url = $this->settings['kit-url'] ? sanitize_text_field( $this->settings['kit-url'] ) : '';
304
-			$url     = '';
305
-
306
-			if ( $type == 'KIT' && $kit_url ) {
307
-				if ( $shims ) {
308
-					// if its a kit then we don't add shims here
309
-					return '';
310
-				}
311
-				$url .= $kit_url; // CDN
312
-				$url .= "?wpfas=true"; // set our var so our version is not removed
313
-			} else {
314
-				$v = '';
315
-				// Check and load locally.
316
-				if ( $local && $this->has_local() ) {
317
-					$script .= ".min";
318
-					$v .= '&ver=' . strip_tags( $this->settings['local_version'] );
319
-					$url .= $this->get_fonts_url(); // Local fonts url.
320
-				} else {
321
-					$url .= "https://$sub.fontawesome.com/releases/"; // CDN
322
-					$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
323
-				}
324
-				$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
325
-				$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
326
-				$url .= "?wpfas=true" . $v; // set our var so our version is not removed
327
-			}
328
-
329
-			return $url;
330
-		}
331
-
332
-		/**
333
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
334
-		 *
335
-		 * 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.
336
-		 *
337
-		 * @param $url
338
-		 * @param $original_url
339
-		 * @param $_context
340
-		 *
341
-		 * @return string The filtered url.
342
-		 */
343
-		public function remove_font_awesome( $url, $original_url, $_context ) {
344
-
345
-			if ( $_context == 'display'
346
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
347
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
348
-			) {// it's a font-awesome-url (probably)
349
-
350
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
351
-					if ( $this->settings['type'] == 'JS' ) {
352
-						if ( $this->settings['js-pseudo'] ) {
353
-							$url .= "' data-search-pseudo-elements defer='defer";
354
-						} else {
355
-							$url .= "' defer='defer";
356
-						}
357
-					}
358
-				} else {
359
-					$url = ''; // removing the url removes the file
360
-				}
361
-
362
-			}
363
-
364
-			return $url;
365
-		}
366
-
367
-		/**
368
-		 * Register the database settings with WordPress.
369
-		 */
370
-		public function register_settings() {
371
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
372
-		}
373
-
374
-		/**
375
-		 * Add the WordPress settings menu item.
376
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
377
-		 */
378
-		public function menu_item() {
379
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
380
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
381
-				$this,
382
-				'settings_page'
383
-			) );
384
-		}
385
-
386
-		/**
387
-		 * Get the current Font Awesome output settings.
388
-		 *
389
-		 * @return array The array of settings.
390
-		 */
391
-		public function get_settings() {
392
-			$db_settings = get_option( 'wp-font-awesome-settings' );
393
-
394
-			$defaults = array(
395
-				'type'      => 'CSS', // type to use, CSS or JS or KIT
396
-				'version'   => '', // latest
397
-				'enqueue'   => '', // front and backend
398
-				'shims'     => '0', // default OFF now in 2020
399
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
400
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
401
-				'pro'       => '0', // if pro CDN url should be used
402
-				'local'     => '0', // Store fonts locally.
403
-				'local_version' => '', // Local fonts version.
404
-				'kit-url'   => '', // the kit url
405
-			);
406
-
407
-			$settings = wp_parse_args( $db_settings, $defaults );
408
-
409
-			/**
410
-			 * Filter the Font Awesome settings.
411
-			 *
412
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
413
-			 */
414
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
415
-		}
416
-
417
-		/**
418
-		 * The settings page html output.
419
-		 */
420
-		public function settings_page() {
421
-			if ( ! current_user_can( 'manage_options' ) ) {
422
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
423
-			}
424
-
425
-			// a hidden way to force the update of the version number via api instead of waiting the 48 hours
426
-			if ( isset( $_REQUEST['force-version-check'] ) ) {
427
-				$this->get_latest_version( $force_api = true );
428
-			}
429
-
430
-			if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
431
-				?>
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
+                    $enqueue = false;
186
+
187
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) {
188
+                        $enqueue = true;
189
+                        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
190
+                    }
191
+
192
+                    if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) {
193
+                        $enqueue = true;
194
+                        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
195
+                        add_filter( 'block_editor_settings_all', array( $this, 'enqueue_editor_scripts' ), 10, 2 );
196
+                    }
197
+
198
+                    if ( $enqueue ) {
199
+                        add_filter( 'script_loader_tag', array( $this, 'script_loader_tag' ), 20, 3 );
200
+                    }
201
+                }
202
+
203
+                // remove font awesome if set to do so
204
+                if ( $this->settings['dequeue'] == '1' ) {
205
+                    add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
206
+                }
207
+            }
208
+
209
+        }
210
+
211
+        /**
212
+         * Add FA to the FSE.
213
+         *
214
+         * @param $editor_settings
215
+         * @param $block_editor_context
216
+         *
217
+         * @return array
218
+         */
219
+        public function enqueue_editor_styles( $editor_settings, $block_editor_context ){
220
+
221
+            if ( ! empty( $editor_settings['__unstableResolvedAssets']['styles'] ) ) {
222
+                $url = $this->get_url();
223
+                $editor_settings['__unstableResolvedAssets']['styles'] .= "<link rel='stylesheet' id='font-awesome-css'  href='$url' media='all' />";
224
+            }
225
+
226
+            return $editor_settings;
227
+        }
228
+
229
+        /**
230
+         * Add FA to the FSE.
231
+         *
232
+         * @param $editor_settings
233
+         * @param $block_editor_context
234
+         *
235
+         * @return array
236
+         */
237
+        public function enqueue_editor_scripts( $editor_settings, $block_editor_context ) {
238
+            $url = $this->get_url();
239
+
240
+            $editor_settings['__unstableResolvedAssets']['scripts'] .= "<script src='$url' id='font-awesome-js' defer crossorigin='anonymous'></script>";
241
+
242
+            return $editor_settings;
243
+        }
244
+
245
+        /**
246
+         * Adds the Font Awesome styles.
247
+         */
248
+        public function enqueue_style() {
249
+            // build url
250
+            $url = $this->get_url();
251
+            $version = ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ? strip_tags( $this->settings['local_version'] ) : null;
252
+
253
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
254
+            wp_register_style( 'font-awesome', $url, array(), $version );
255
+            wp_enqueue_style( 'font-awesome' );
256
+
257
+            // RTL language support CSS.
258
+            if ( is_rtl() ) {
259
+                wp_add_inline_style( 'font-awesome', $this->rtl_inline_css() );
260
+            }
261
+
262
+            if ( $this->settings['shims'] ) {
263
+                $url = $this->get_url( true );
264
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
265
+                wp_register_style( 'font-awesome-shims', $url, array(), $version );
266
+                wp_enqueue_style( 'font-awesome-shims' );
267
+            }
268
+        }
269
+
270
+        /**
271
+         * Adds the Font Awesome JS.
272
+         */
273
+        public function enqueue_scripts() {
274
+            // build url
275
+            $url = $this->get_url();
276
+
277
+            $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script';
278
+            call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there
279
+            wp_register_script( 'font-awesome', $url, array(), null );
280
+            wp_enqueue_script( 'font-awesome' );
281
+
282
+            if ( $this->settings['shims'] ) {
283
+                $url = $this->get_url( true );
284
+                call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there
285
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
286
+                wp_enqueue_script( 'font-awesome-shims' );
287
+            }
288
+        }
289
+
290
+        /**
291
+         * Get the url of the Font Awesome files.
292
+         *
293
+         * @param bool $shims If this is a shim file or not.
294
+         * @param bool $local Load locally if allowed.
295
+         *
296
+         * @return string The url to the file.
297
+         */
298
+        public function get_url( $shims = false, $local = true ) {
299
+            $script  = $shims ? 'v4-shims' : 'all';
300
+            $sub     = $this->settings['pro'] ? 'pro' : 'use';
301
+            $type    = $this->settings['type'];
302
+            $version = $this->settings['version'];
303
+            $kit_url = $this->settings['kit-url'] ? sanitize_text_field( $this->settings['kit-url'] ) : '';
304
+            $url     = '';
305
+
306
+            if ( $type == 'KIT' && $kit_url ) {
307
+                if ( $shims ) {
308
+                    // if its a kit then we don't add shims here
309
+                    return '';
310
+                }
311
+                $url .= $kit_url; // CDN
312
+                $url .= "?wpfas=true"; // set our var so our version is not removed
313
+            } else {
314
+                $v = '';
315
+                // Check and load locally.
316
+                if ( $local && $this->has_local() ) {
317
+                    $script .= ".min";
318
+                    $v .= '&ver=' . strip_tags( $this->settings['local_version'] );
319
+                    $url .= $this->get_fonts_url(); // Local fonts url.
320
+                } else {
321
+                    $url .= "https://$sub.fontawesome.com/releases/"; // CDN
322
+                    $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
323
+                }
324
+                $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
325
+                $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
326
+                $url .= "?wpfas=true" . $v; // set our var so our version is not removed
327
+            }
328
+
329
+            return $url;
330
+        }
331
+
332
+        /**
333
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
334
+         *
335
+         * 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.
336
+         *
337
+         * @param $url
338
+         * @param $original_url
339
+         * @param $_context
340
+         *
341
+         * @return string The filtered url.
342
+         */
343
+        public function remove_font_awesome( $url, $original_url, $_context ) {
344
+
345
+            if ( $_context == 'display'
346
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
347
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
348
+            ) {// it's a font-awesome-url (probably)
349
+
350
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
351
+                    if ( $this->settings['type'] == 'JS' ) {
352
+                        if ( $this->settings['js-pseudo'] ) {
353
+                            $url .= "' data-search-pseudo-elements defer='defer";
354
+                        } else {
355
+                            $url .= "' defer='defer";
356
+                        }
357
+                    }
358
+                } else {
359
+                    $url = ''; // removing the url removes the file
360
+                }
361
+
362
+            }
363
+
364
+            return $url;
365
+        }
366
+
367
+        /**
368
+         * Register the database settings with WordPress.
369
+         */
370
+        public function register_settings() {
371
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
372
+        }
373
+
374
+        /**
375
+         * Add the WordPress settings menu item.
376
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
377
+         */
378
+        public function menu_item() {
379
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
380
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
381
+                $this,
382
+                'settings_page'
383
+            ) );
384
+        }
385
+
386
+        /**
387
+         * Get the current Font Awesome output settings.
388
+         *
389
+         * @return array The array of settings.
390
+         */
391
+        public function get_settings() {
392
+            $db_settings = get_option( 'wp-font-awesome-settings' );
393
+
394
+            $defaults = array(
395
+                'type'      => 'CSS', // type to use, CSS or JS or KIT
396
+                'version'   => '', // latest
397
+                'enqueue'   => '', // front and backend
398
+                'shims'     => '0', // default OFF now in 2020
399
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
400
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
401
+                'pro'       => '0', // if pro CDN url should be used
402
+                'local'     => '0', // Store fonts locally.
403
+                'local_version' => '', // Local fonts version.
404
+                'kit-url'   => '', // the kit url
405
+            );
406
+
407
+            $settings = wp_parse_args( $db_settings, $defaults );
408
+
409
+            /**
410
+             * Filter the Font Awesome settings.
411
+             *
412
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
413
+             */
414
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
415
+        }
416
+
417
+        /**
418
+         * The settings page html output.
419
+         */
420
+        public function settings_page() {
421
+            if ( ! current_user_can( 'manage_options' ) ) {
422
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'ayecode-connect' ) );
423
+            }
424
+
425
+            // a hidden way to force the update of the version number via api instead of waiting the 48 hours
426
+            if ( isset( $_REQUEST['force-version-check'] ) ) {
427
+                $this->get_latest_version( $force_api = true );
428
+            }
429
+
430
+            if ( ! defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
431
+                ?>
432 432
                 <style>
433 433
                     .wpfas-kit-show {
434 434
                         display: none;
@@ -454,16 +454,16 @@  discard block
 block discarded – undo
454 454
                     <h1><?php echo $this->name; ?></h1>
455 455
                     <form method="post" action="options.php" class="fas-settings-form">
456 456
 						<?php
457
-						settings_fields( 'wp-font-awesome-settings' );
458
-						do_settings_sections( 'wp-font-awesome-settings' );
459
-						$table_class = '';
460
-						if ( $this->settings['type'] ) {
461
-							$table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
462
-						}
463
-						if ( ! empty( $this->settings['pro'] ) ) {
464
-							$table_class .= ' wpfas-has-pro';
465
-						}
466
-						?>
457
+                        settings_fields( 'wp-font-awesome-settings' );
458
+                        do_settings_sections( 'wp-font-awesome-settings' );
459
+                        $table_class = '';
460
+                        if ( $this->settings['type'] ) {
461
+                            $table_class .= 'wpfas-' . sanitize_html_class( strtolower( $this->settings['type'] ) ) . '-set';
462
+                        }
463
+                        if ( ! empty( $this->settings['pro'] ) ) {
464
+                            $table_class .= ' wpfas-has-pro';
465
+                        }
466
+                        ?>
467 467
 						<?php if ( $this->settings['type'] != 'KIT' && ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) ) { ?>
468 468
 							<?php if ( $this->has_local() ) { ?>
469 469
                                 <div class="notice notice-info"><p><strong><?php _e( 'Font Awesome fonts are loading locally.', 'ayecode-connect' ); ?></strong></p></div>
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
                                 <td>
489 489
                                     <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 :(?>"/>
490 490
                                     <span><?php
491
-										echo wp_sprintf(
492
-											__( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
493
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i> ',
494
-											'</a>'
495
-										);
496
-										?></span>
491
+                                        echo wp_sprintf(
492
+                                            __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'ayecode-connect' ),
493
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i> ',
494
+                                            '</a>'
495
+                                        );
496
+                                        ?></span>
497 497
                                 </td>
498 498
                             </tr>
499 499
                             <tr valign="top" class="wpfas-kit-hide">
@@ -543,14 +543,14 @@  discard block
 block discarded – undo
543 543
                                     <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/>
544 544
                                     <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')}"/>
545 545
                                     <span><?php
546
-										echo wp_sprintf(
547
-											__( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
548
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
549
-											' <i class="fas fa-external-link-alt"></i></a>',
550
-											'<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
551
-											' <i class="fas fa-external-link-alt"></i></a>'
552
-										);
553
-										?></span>
546
+                                        echo wp_sprintf(
547
+                                            __( 'Requires a subscription. %sLearn more%s  %sManage my allowed domains%s', 'ayecode-connect' ),
548
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/referral?a=c9b89e1418">',
549
+                                            ' <i class="fas fa-external-link-alt"></i></a>',
550
+                                            '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn">',
551
+                                            ' <i class="fas fa-external-link-alt"></i></a>'
552
+                                        );
553
+                                        ?></span>
554 554
                                 </td>
555 555
                             </tr>
556 556
 
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
                         </table>
605 605
                         <div class="fas-buttons">
606 606
 							<?php
607
-							submit_button();
608
-							?>
607
+                            submit_button();
608
+                            ?>
609 609
                             <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>
610 610
 
611 611
                         </div>
@@ -614,444 +614,444 @@  discard block
 block discarded – undo
614 614
                     <div id="wpfas-version"><?php echo wp_sprintf(__( 'Version: %s (affiliate links provided)', 'ayecode-connect' ), $this->version ); ?></div>
615 615
                 </div>
616 616
 				<?php
617
-			}
618
-		}
619
-
620
-		/**
621
-		 * Check a version number is valid and if so return it or else return an empty string.
622
-		 *
623
-		 * @param $version string The version number to check.
624
-		 *
625
-		 * @since 1.0.6
626
-		 *
627
-		 * @return string Either a valid version number or an empty string.
628
-		 */
629
-		public function validate_version_number( $version ) {
630
-
631
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
632
-				// valid
633
-			} else {
634
-				$version = '';// not validated
635
-			}
636
-
637
-			return $version;
638
-		}
639
-
640
-
641
-		/**
642
-		 * Get the latest version of Font Awesome.
643
-		 *
644
-		 * 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.
645
-		 *
646
-		 * @since 1.0.7
647
-		 * @return mixed|string The latest version number found.
648
-		 */
649
-		public function get_latest_version( $force_api = false, $force_latest = false ) {
650
-			$latest_version = $this->latest;
651
-
652
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
653
-
654
-			if ( $cache === false || $force_api ) { // its not set
655
-				$api_ver = $this->get_latest_version_from_api();
656
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
657
-					$latest_version = $api_ver;
658
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
659
-				}
660
-			} elseif ( $this->validate_version_number( $cache ) ) {
661
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
662
-					$latest_version = $cache;
663
-				}
664
-			}
665
-
666
-			// @todo remove after FA7 compatibility
667
-			if ( ! $force_latest && version_compare( $cache, '7.0.0', '>=' ) >= 0 ) {
668
-				$latest_version = '6.7.2';
669
-			}
670
-
671
-			// Check and auto download fonts locally.
672
-			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 ) ) {
673
-				if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
674
-					$this->download_package( $latest_version );
675
-				}
676
-			}
677
-
678
-			return $latest_version;
679
-		}
680
-
681
-		/**
682
-		 * Get the latest Font Awesome version from the github API.
683
-		 *
684
-		 * @since 1.0.7
685
-		 * @return string The latest version number or `0` on API fail.
686
-		 */
687
-		public function get_latest_version_from_api() {
688
-			$version  = "0";
689
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
690
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
691
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
692
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
693
-					$version = $api_response['tag_name'];
694
-				}
695
-			}
696
-
697
-			return $version;
698
-		}
699
-
700
-		/**
701
-		 * Inline CSS for RTL language support.
702
-		 *
703
-		 * @since 1.0.13
704
-		 * @return string Inline CSS.
705
-		 */
706
-		public function rtl_inline_css() {
707
-			$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}';
708
-
709
-			return $inline_css;
710
-		}
711
-
712
-		/**
713
-		 * Show any warnings as an admin notice.
714
-		 *
715
-		 * @return void
716
-		 */
717
-		public function admin_notices() {
718
-			$settings = $this->settings;
719
-
720
-			if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
721
-				if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
722
-					?>
617
+            }
618
+        }
619
+
620
+        /**
621
+         * Check a version number is valid and if so return it or else return an empty string.
622
+         *
623
+         * @param $version string The version number to check.
624
+         *
625
+         * @since 1.0.6
626
+         *
627
+         * @return string Either a valid version number or an empty string.
628
+         */
629
+        public function validate_version_number( $version ) {
630
+
631
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
632
+                // valid
633
+            } else {
634
+                $version = '';// not validated
635
+            }
636
+
637
+            return $version;
638
+        }
639
+
640
+
641
+        /**
642
+         * Get the latest version of Font Awesome.
643
+         *
644
+         * 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.
645
+         *
646
+         * @since 1.0.7
647
+         * @return mixed|string The latest version number found.
648
+         */
649
+        public function get_latest_version( $force_api = false, $force_latest = false ) {
650
+            $latest_version = $this->latest;
651
+
652
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
653
+
654
+            if ( $cache === false || $force_api ) { // its not set
655
+                $api_ver = $this->get_latest_version_from_api();
656
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
657
+                    $latest_version = $api_ver;
658
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
659
+                }
660
+            } elseif ( $this->validate_version_number( $cache ) ) {
661
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
662
+                    $latest_version = $cache;
663
+                }
664
+            }
665
+
666
+            // @todo remove after FA7 compatibility
667
+            if ( ! $force_latest && version_compare( $cache, '7.0.0', '>=' ) >= 0 ) {
668
+                $latest_version = '6.7.2';
669
+            }
670
+
671
+            // Check and auto download fonts locally.
672
+            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 ) ) {
673
+                if ( version_compare( $latest_version, $this->settings['local_version'], '>' ) && is_admin() && ! wp_doing_ajax() ) {
674
+                    $this->download_package( $latest_version );
675
+                }
676
+            }
677
+
678
+            return $latest_version;
679
+        }
680
+
681
+        /**
682
+         * Get the latest Font Awesome version from the github API.
683
+         *
684
+         * @since 1.0.7
685
+         * @return string The latest version number or `0` on API fail.
686
+         */
687
+        public function get_latest_version_from_api() {
688
+            $version  = "0";
689
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
690
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
691
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
692
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
693
+                    $version = $api_response['tag_name'];
694
+                }
695
+            }
696
+
697
+            return $version;
698
+        }
699
+
700
+        /**
701
+         * Inline CSS for RTL language support.
702
+         *
703
+         * @since 1.0.13
704
+         * @return string Inline CSS.
705
+         */
706
+        public function rtl_inline_css() {
707
+            $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}';
708
+
709
+            return $inline_css;
710
+        }
711
+
712
+        /**
713
+         * Show any warnings as an admin notice.
714
+         *
715
+         * @return void
716
+         */
717
+        public function admin_notices() {
718
+            $settings = $this->settings;
719
+
720
+            if ( defined( 'FONTAWESOME_PLUGIN_FILE' ) ) {
721
+                if ( ! empty( $_REQUEST['page'] ) && $_REQUEST['page'] == 'wp-font-awesome-settings' ) {
722
+                    ?>
723 723
                     <div class="notice  notice-error is-dismissible">
724 724
                         <p><?php _e( 'The Official Font Awesome Plugin is active, please adjust your settings there.', 'ayecode-connect' ); ?></p>
725 725
                     </div>
726 726
 					<?php
727
-				}
728
-			} else {
729
-				if ( ! empty( $settings ) ) {
730
-					if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
731
-						$link = admin_url('options-general.php?page=wp-font-awesome-settings');
732
-						?>
727
+                }
728
+            } else {
729
+                if ( ! empty( $settings ) ) {
730
+                    if ( $settings['type'] != 'KIT' && $settings['pro'] && ( $settings['version'] == '' || version_compare( $settings['version'], '6', '>=' ) ) ) {
731
+                        $link = admin_url('options-general.php?page=wp-font-awesome-settings');
732
+                        ?>
733 733
                         <div class="notice  notice-error is-dismissible">
734 734
                             <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>
735 735
                         </div>
736 736
 						<?php
737
-					}
738
-				}
739
-			}
740
-		}
741
-
742
-		/**
743
-		 * Handle fontawesome add settings to download fontawesome to store locally.
744
-		 *
745
-		 * @since 1.1.1
746
-		 *
747
-		 * @param string $option The option name.
748
-		 * @param mixed  $value  The option value.
749
-		 */
750
-		public function add_option_wp_font_awesome_settings( $option, $value ) {
751
-			// Do nothing if WordPress is being installed.
752
-			if ( wp_installing() ) {
753
-				return;
754
-			}
755
-
756
-			if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
757
-				$version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
758
-
759
-				if ( ! empty( $version ) ) {
760
-					$response = $this->download_package( $version, $value );
761
-
762
-					if ( is_wp_error( $response ) ) {
763
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
764
-					}
765
-				}
766
-			}
767
-		}
768
-
769
-		/**
770
-		 * Handle fontawesome update settings to download fontawesome to store locally.
771
-		 *
772
-		 * @since 1.1.0
773
-		 *
774
-		 * @param mixed $old_value The old option value.
775
-		 * @param mixed $value     The new option value.
776
-		 */
777
-		public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
778
-			// Do nothing if WordPress is being installed.
779
-			if ( wp_installing() ) {
780
-				return;
781
-			}
782
-
783
-			if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
784
-				// Old values
785
-				$old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
786
-				$old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
787
-
788
-				// New values
789
-				$new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
790
-
791
-				if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
792
-					$response = $this->download_package( $new_version, $new_value );
793
-
794
-					if ( is_wp_error( $response ) ) {
795
-						add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
796
-					}
797
-				}
798
-			}
799
-		}
800
-
801
-		/**
802
-		 * Get the fonts directory local path.
803
-		 *
804
-		 * @since 1.1.0
805
-		 *
806
-		 * @param string Fonts directory local path.
807
-		 */
808
-		public function get_fonts_dir() {
809
-			$upload_dir = wp_upload_dir( null, false );
810
-
811
-			return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
812
-		}
813
-
814
-		/**
815
-		 * Get the fonts directory local url.
816
-		 *
817
-		 * @since 1.1.0
818
-		 *
819
-		 * @param string Fonts directory local url.
820
-		 */
821
-		public function get_fonts_url() {
822
-			$upload_dir = wp_upload_dir( null, false );
823
-
824
-			return $upload_dir['baseurl'] .  '/ayefonts/fa/';
825
-		}
826
-
827
-		/**
828
-		 * Check whether load locally active.
829
-		 *
830
-		 * @since 1.1.0
831
-		 *
832
-		 * @return bool True if active else false.
833
-		 */
834
-		public function has_local() {
835
-			if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
836
-				return true;
837
-			}
838
-
839
-			return false;
840
-		}
841
-
842
-		/**
843
-		 * Get the WP Filesystem access.
844
-		 *
845
-		 * @since 1.1.0
846
-		 *
847
-		 * @return object The WP Filesystem.
848
-		 */
849
-		public function get_wp_filesystem() {
850
-			if ( ! function_exists( 'get_filesystem_method' ) ) {
851
-				require_once( ABSPATH . "/wp-admin/includes/file.php" );
852
-			}
853
-
854
-			$access_type = get_filesystem_method();
855
-
856
-			if ( $access_type === 'direct' ) {
857
-				/* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
858
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
859
-
860
-				/* Initialize the API */
861
-				if ( ! WP_Filesystem( $creds ) ) {
862
-					/* Any problems and we exit */
863
-					return false;
864
-				}
865
-
866
-				global $wp_filesystem;
867
-
868
-				return $wp_filesystem;
869
-				/* Do our file manipulations below */
870
-			} else if ( defined( 'FTP_USER' ) ) {
871
-				$creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
872
-
873
-				/* Initialize the API */
874
-				if ( ! WP_Filesystem( $creds ) ) {
875
-					/* Any problems and we exit */
876
-					return false;
877
-				}
878
-
879
-				global $wp_filesystem;
880
-
881
-				return $wp_filesystem;
882
-			} else {
883
-				/* Don't have direct write access. Prompt user with our notice */
884
-				return false;
885
-			}
886
-		}
887
-
888
-		/**
889
-		 * Download the fontawesome package file.
890
-		 *
891
-		 * @since 1.1.0
892
-		 *
893
-		 * @param mixed $version The font awesome.
894
-		 * @param array $option Fontawesome settings.
895
-		 * @return WP_ERROR|bool Error on fail and true on success.
896
-		 */
897
-		public function download_package( $version, $option = array() ) {
898
-			$filename = 'fontawesome-free-' . $version . '-web';
899
-			$url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
900
-
901
-			if ( ! function_exists( 'wp_handle_upload' ) ) {
902
-				require_once ABSPATH . 'wp-admin/includes/file.php';
903
-			}
904
-
905
-			$download_file = download_url( esc_url_raw( $url ) );
906
-
907
-			if ( is_wp_error( $download_file ) ) {
908
-				return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
909
-			} else if ( empty( $download_file ) ) {
910
-				return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
911
-			}
912
-
913
-			$response = $this->extract_package( $download_file, $filename, true );
914
-
915
-			// Update local version.
916
-			if ( is_wp_error( $response ) ) {
917
-				return $response;
918
-			} else if ( $response ) {
919
-				if ( empty( $option ) ) {
920
-					$option = get_option( 'wp-font-awesome-settings' );
921
-				}
922
-
923
-				$option['local_version'] = $version;
924
-
925
-				// Remove action to prevent looping.
926
-				remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
927
-
928
-				update_option( 'wp-font-awesome-settings', $option );
929
-
930
-				return true;
931
-			}
932
-
933
-			return false;
934
-		}
935
-
936
-		/**
937
-		 * Extract the fontawesome package file.
938
-		 *
939
-		 * @since 1.1.0
940
-		 *
941
-		 * @param string $package The package file path.
942
-		 * @param string $dirname Package file name.
943
-		 * @param bool   $delete_package Delete temp file or not.
944
-		 * @return WP_Error|bool True on success WP_Error on fail.
945
-		 */
946
-		public function extract_package( $package, $dirname = '', $delete_package = false ) {
947
-			global $wp_filesystem;
948
-
949
-			$wp_filesystem = $this->get_wp_filesystem();
950
-
951
-			if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
952
-				return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
953
-			} else if ( empty( $wp_filesystem ) ) {
954
-				return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
955
-			}
956
-
957
-			$fonts_dir = $this->get_fonts_dir();
958
-			$fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
959
-
960
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
961
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
962
-			}
963
-
964
-			// Unzip package to working directory.
965
-			$result = unzip_file( $package, $fonts_tmp_dir );
966
-
967
-			if ( is_wp_error( $result ) ) {
968
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
969
-
970
-				if ( 'incompatible_archive' === $result->get_error_code() ) {
971
-					return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
972
-				}
973
-
974
-				return $result;
975
-			}
976
-
977
-			if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
978
-				$wp_filesystem->delete( $fonts_dir, true );
979
-			}
980
-
981
-			$extract_dir = $fonts_tmp_dir;
982
-
983
-			if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
984
-				$extract_dir .= $dirname . DIRECTORY_SEPARATOR;
985
-			}
986
-
987
-			try {
988
-				$return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
989
-			} catch ( Exception $e ) {
990
-				$return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
991
-			}
992
-
993
-			if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
994
-				$wp_filesystem->delete( $fonts_tmp_dir, true );
995
-			}
996
-
997
-			// Once extracted, delete the package if required.
998
-			if ( $delete_package ) {
999
-				unlink( $package );
1000
-			}
1001
-
1002
-			return $return;
1003
-		}
1004
-
1005
-		/**
1006
-		 * Output the version in the header.
1007
-		 */
1008
-		public function add_generator() {
1009
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
1010
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
1011
-
1012
-			// Find source plugin/theme.
1013
-			$source = array();
1014
-			if ( strpos( $file, $plugins_dir ) !== false ) {
1015
-				$source = explode( "/", plugin_basename( $file ) );
1016
-			} else if ( function_exists( 'get_theme_root' ) ) {
1017
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1018
-
1019
-				if ( strpos( $file, $themes_dir ) !== false ) {
1020
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1021
-				}
1022
-			}
1023
-
1024
-			echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1025
-		}
1026
-
1027
-		/**
1028
-		 * Add extra parameters to the script tag.
1029
-		 *
1030
-		 * Add crossorigin="anonymous" to prevent OpaqueResponseBlocking
1031
-		 * (NS_BINDING_ABORTED) http error.
1032
-		 *
1033
-		 * @since 1.1.8
1034
-		 *
1035
-		 * @param string $tag The script tag.
1036
-		 * @param string $handle The script handle.
1037
-		 * @param string $src The script url.
1038
-		 * @return string The script tag.
1039
-		 */
1040
-		public function script_loader_tag( $tag, $handle, $src ) {
1041
-			if ( ( $handle == 'font-awesome' || $handle == 'font-awesome-shims' ) && ( strpos( $src, "kit.fontawesome.com" ) !== false || strpos( $src, ".fontawesome.com/releases/" ) !== false ) ) {
1042
-				$tag = preg_replace(
1043
-					'/<script[\s]+(.*?)>/',
1044
-					'<script defer crossorigin="anonymous" \1>',
1045
-					$tag
1046
-				);
1047
-			}
1048
-
1049
-			return $tag;
1050
-		}
1051
-	}
1052
-
1053
-	/**
1054
-	 * Run the class if found.
1055
-	 */
1056
-	WP_Font_Awesome_Settings::instance();
737
+                    }
738
+                }
739
+            }
740
+        }
741
+
742
+        /**
743
+         * Handle fontawesome add settings to download fontawesome to store locally.
744
+         *
745
+         * @since 1.1.1
746
+         *
747
+         * @param string $option The option name.
748
+         * @param mixed  $value  The option value.
749
+         */
750
+        public function add_option_wp_font_awesome_settings( $option, $value ) {
751
+            // Do nothing if WordPress is being installed.
752
+            if ( wp_installing() ) {
753
+                return;
754
+            }
755
+
756
+            if ( ! empty( $value['local'] ) && empty( $value['pro'] ) && ! ( ! empty( $value['type'] ) && $value['type'] == 'KIT' ) ) {
757
+                $version = isset( $value['version'] ) && $value['version'] ? $value['version'] : $this->get_latest_version();
758
+
759
+                if ( ! empty( $version ) ) {
760
+                    $response = $this->download_package( $version, $value );
761
+
762
+                    if ( is_wp_error( $response ) ) {
763
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
764
+                    }
765
+                }
766
+            }
767
+        }
768
+
769
+        /**
770
+         * Handle fontawesome update settings to download fontawesome to store locally.
771
+         *
772
+         * @since 1.1.0
773
+         *
774
+         * @param mixed $old_value The old option value.
775
+         * @param mixed $value     The new option value.
776
+         */
777
+        public function update_option_wp_font_awesome_settings( $old_value, $new_value ) {
778
+            // Do nothing if WordPress is being installed.
779
+            if ( wp_installing() ) {
780
+                return;
781
+            }
782
+
783
+            if ( ! empty( $new_value['local'] ) && empty( $new_value['pro'] ) && ! ( ! empty( $new_value['type'] ) && $new_value['type'] == 'KIT' ) ) {
784
+                // Old values
785
+                $old_version = isset( $old_value['version'] ) && $old_value['version'] ? $old_value['version'] : ( isset( $old_value['local_version'] ) ? $old_value['local_version'] : '' );
786
+                $old_local = isset( $old_value['local'] ) ? (int) $old_value['local'] : 0;
787
+
788
+                // New values
789
+                $new_version = isset( $new_value['version'] ) && $new_value['version'] ? $new_value['version'] : $this->get_latest_version();
790
+
791
+                if ( empty( $old_local ) || $old_version !== $new_version || ! file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
792
+                    $response = $this->download_package( $new_version, $new_value );
793
+
794
+                    if ( is_wp_error( $response ) ) {
795
+                        add_settings_error( 'general', 'fontawesome_download', __( 'ERROR:', 'ayecode-connect' ) . ' ' . $response->get_error_message(), 'error' );
796
+                    }
797
+                }
798
+            }
799
+        }
800
+
801
+        /**
802
+         * Get the fonts directory local path.
803
+         *
804
+         * @since 1.1.0
805
+         *
806
+         * @param string Fonts directory local path.
807
+         */
808
+        public function get_fonts_dir() {
809
+            $upload_dir = wp_upload_dir( null, false );
810
+
811
+            return $upload_dir['basedir'] . DIRECTORY_SEPARATOR .  'ayefonts' . DIRECTORY_SEPARATOR . 'fa' . DIRECTORY_SEPARATOR;
812
+        }
813
+
814
+        /**
815
+         * Get the fonts directory local url.
816
+         *
817
+         * @since 1.1.0
818
+         *
819
+         * @param string Fonts directory local url.
820
+         */
821
+        public function get_fonts_url() {
822
+            $upload_dir = wp_upload_dir( null, false );
823
+
824
+            return $upload_dir['baseurl'] .  '/ayefonts/fa/';
825
+        }
826
+
827
+        /**
828
+         * Check whether load locally active.
829
+         *
830
+         * @since 1.1.0
831
+         *
832
+         * @return bool True if active else false.
833
+         */
834
+        public function has_local() {
835
+            if ( ! empty( $this->settings['local'] ) && empty( $this->settings['pro'] ) && file_exists( $this->get_fonts_dir() . 'css' . DIRECTORY_SEPARATOR . 'all.css' ) ) {
836
+                return true;
837
+            }
838
+
839
+            return false;
840
+        }
841
+
842
+        /**
843
+         * Get the WP Filesystem access.
844
+         *
845
+         * @since 1.1.0
846
+         *
847
+         * @return object The WP Filesystem.
848
+         */
849
+        public function get_wp_filesystem() {
850
+            if ( ! function_exists( 'get_filesystem_method' ) ) {
851
+                require_once( ABSPATH . "/wp-admin/includes/file.php" );
852
+            }
853
+
854
+            $access_type = get_filesystem_method();
855
+
856
+            if ( $access_type === 'direct' ) {
857
+                /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
858
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
859
+
860
+                /* Initialize the API */
861
+                if ( ! WP_Filesystem( $creds ) ) {
862
+                    /* Any problems and we exit */
863
+                    return false;
864
+                }
865
+
866
+                global $wp_filesystem;
867
+
868
+                return $wp_filesystem;
869
+                /* Do our file manipulations below */
870
+            } else if ( defined( 'FTP_USER' ) ) {
871
+                $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() );
872
+
873
+                /* Initialize the API */
874
+                if ( ! WP_Filesystem( $creds ) ) {
875
+                    /* Any problems and we exit */
876
+                    return false;
877
+                }
878
+
879
+                global $wp_filesystem;
880
+
881
+                return $wp_filesystem;
882
+            } else {
883
+                /* Don't have direct write access. Prompt user with our notice */
884
+                return false;
885
+            }
886
+        }
887
+
888
+        /**
889
+         * Download the fontawesome package file.
890
+         *
891
+         * @since 1.1.0
892
+         *
893
+         * @param mixed $version The font awesome.
894
+         * @param array $option Fontawesome settings.
895
+         * @return WP_ERROR|bool Error on fail and true on success.
896
+         */
897
+        public function download_package( $version, $option = array() ) {
898
+            $filename = 'fontawesome-free-' . $version . '-web';
899
+            $url = 'https://use.fontawesome.com/releases/v' . $version . '/' . $filename . '.zip';
900
+
901
+            if ( ! function_exists( 'wp_handle_upload' ) ) {
902
+                require_once ABSPATH . 'wp-admin/includes/file.php';
903
+            }
904
+
905
+            $download_file = download_url( esc_url_raw( $url ) );
906
+
907
+            if ( is_wp_error( $download_file ) ) {
908
+                return new WP_Error( 'fontawesome_download_failed', __( $download_file->get_error_message(), 'ayecode-connect' ) );
909
+            } else if ( empty( $download_file ) ) {
910
+                return new WP_Error( 'fontawesome_download_failed', __( 'Something went wrong in downloading the font awesome to store locally.', 'ayecode-connect' ) );
911
+            }
912
+
913
+            $response = $this->extract_package( $download_file, $filename, true );
914
+
915
+            // Update local version.
916
+            if ( is_wp_error( $response ) ) {
917
+                return $response;
918
+            } else if ( $response ) {
919
+                if ( empty( $option ) ) {
920
+                    $option = get_option( 'wp-font-awesome-settings' );
921
+                }
922
+
923
+                $option['local_version'] = $version;
924
+
925
+                // Remove action to prevent looping.
926
+                remove_action( 'update_option_wp-font-awesome-settings', array( $this, 'update_option_wp_font_awesome_settings' ), 10, 2 );
927
+
928
+                update_option( 'wp-font-awesome-settings', $option );
929
+
930
+                return true;
931
+            }
932
+
933
+            return false;
934
+        }
935
+
936
+        /**
937
+         * Extract the fontawesome package file.
938
+         *
939
+         * @since 1.1.0
940
+         *
941
+         * @param string $package The package file path.
942
+         * @param string $dirname Package file name.
943
+         * @param bool   $delete_package Delete temp file or not.
944
+         * @return WP_Error|bool True on success WP_Error on fail.
945
+         */
946
+        public function extract_package( $package, $dirname = '', $delete_package = false ) {
947
+            global $wp_filesystem;
948
+
949
+            $wp_filesystem = $this->get_wp_filesystem();
950
+
951
+            if ( empty( $wp_filesystem ) && isset( $wp_filesystem->errors ) && is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->get_error_code() ) {
952
+                return new WP_Error( 'fontawesome_filesystem_error', __( $wp_filesystem->errors->get_error_message(), 'ayecode-connect' ) );
953
+            } else if ( empty( $wp_filesystem ) ) {
954
+                return new WP_Error( 'fontawesome_filesystem_error', __( 'Failed to initialise WP_Filesystem while trying to download the Font Awesome package.', 'ayecode-connect' ) );
955
+            }
956
+
957
+            $fonts_dir = $this->get_fonts_dir();
958
+            $fonts_tmp_dir = dirname( $fonts_dir ) . DIRECTORY_SEPARATOR . 'fa-tmp' . DIRECTORY_SEPARATOR;
959
+
960
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
961
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
962
+            }
963
+
964
+            // Unzip package to working directory.
965
+            $result = unzip_file( $package, $fonts_tmp_dir );
966
+
967
+            if ( is_wp_error( $result ) ) {
968
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
969
+
970
+                if ( 'incompatible_archive' === $result->get_error_code() ) {
971
+                    return new WP_Error( 'fontawesome_incompatible_archive', __( $result->get_error_message(), 'ayecode-connect' ) );
972
+                }
973
+
974
+                return $result;
975
+            }
976
+
977
+            if ( $wp_filesystem->is_dir( $fonts_dir ) ) {
978
+                $wp_filesystem->delete( $fonts_dir, true );
979
+            }
980
+
981
+            $extract_dir = $fonts_tmp_dir;
982
+
983
+            if ( $dirname && $wp_filesystem->is_dir( $extract_dir . $dirname . DIRECTORY_SEPARATOR ) ) {
984
+                $extract_dir .= $dirname . DIRECTORY_SEPARATOR;
985
+            }
986
+
987
+            try {
988
+                $return = $wp_filesystem->move( $extract_dir, $fonts_dir, true );
989
+            } catch ( Exception $e ) {
990
+                $return = new WP_Error( 'fontawesome_move_package', __( 'Fail to move font awesome package!', 'ayecode-connect' ) );
991
+            }
992
+
993
+            if ( $wp_filesystem->is_dir( $fonts_tmp_dir ) ) {
994
+                $wp_filesystem->delete( $fonts_tmp_dir, true );
995
+            }
996
+
997
+            // Once extracted, delete the package if required.
998
+            if ( $delete_package ) {
999
+                unlink( $package );
1000
+            }
1001
+
1002
+            return $return;
1003
+        }
1004
+
1005
+        /**
1006
+         * Output the version in the header.
1007
+         */
1008
+        public function add_generator() {
1009
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
1010
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
1011
+
1012
+            // Find source plugin/theme.
1013
+            $source = array();
1014
+            if ( strpos( $file, $plugins_dir ) !== false ) {
1015
+                $source = explode( "/", plugin_basename( $file ) );
1016
+            } else if ( function_exists( 'get_theme_root' ) ) {
1017
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
1018
+
1019
+                if ( strpos( $file, $themes_dir ) !== false ) {
1020
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
1021
+                }
1022
+            }
1023
+
1024
+            echo '<meta name="generator" content="WP Font Awesome Settings v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-ac-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
1025
+        }
1026
+
1027
+        /**
1028
+         * Add extra parameters to the script tag.
1029
+         *
1030
+         * Add crossorigin="anonymous" to prevent OpaqueResponseBlocking
1031
+         * (NS_BINDING_ABORTED) http error.
1032
+         *
1033
+         * @since 1.1.8
1034
+         *
1035
+         * @param string $tag The script tag.
1036
+         * @param string $handle The script handle.
1037
+         * @param string $src The script url.
1038
+         * @return string The script tag.
1039
+         */
1040
+        public function script_loader_tag( $tag, $handle, $src ) {
1041
+            if ( ( $handle == 'font-awesome' || $handle == 'font-awesome-shims' ) && ( strpos( $src, "kit.fontawesome.com" ) !== false || strpos( $src, ".fontawesome.com/releases/" ) !== false ) ) {
1042
+                $tag = preg_replace(
1043
+                    '/<script[\s]+(.*?)>/',
1044
+                    '<script defer crossorigin="anonymous" \1>',
1045
+                    $tag
1046
+                );
1047
+            }
1048
+
1049
+            return $tag;
1050
+        }
1051
+    }
1052
+
1053
+    /**
1054
+     * Run the class if found.
1055
+     */
1056
+    WP_Font_Awesome_Settings::instance();
1057 1057
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 1 patch
Indentation   +2674 added lines, -2674 removed lines patch added patch discarded remove patch
@@ -1,148 +1,148 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.2.25' );
9
-
10
-	/**
11
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
-	 *
13
-	 * Should not be called direct but extended instead.
14
-	 *
15
-	 * Class WP_Super_Duper
16
-	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
-	 * @ver 1.1.1
18
-	 */
19
-	class WP_Super_Duper extends WP_Widget {
20
-
21
-		public $version = SUPER_DUPER_VER;
22
-		public $font_awesome_icon_version = "5.11.2";
23
-		public $block_code;
24
-		public $options;
25
-		public $base_id;
26
-		public $settings_hash;
27
-		public $arguments = array();
28
-		public $instance = array();
29
-		private $class_name;
30
-
31
-		/**
32
-		 * The relative url to the current folder.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $url = '';
37
-
38
-		/**
39
-		 * Take the array options and use them to build.
40
-		 */
41
-		public function __construct( $options ) {
42
-			global $sd_widgets;
43
-
44
-			$sd_widgets[ $options['base_id'] ] = array(
45
-				'name'       => $options['name'],
46
-				'class_name' => $options['class_name'],
47
-				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
-			);
49
-			$this->base_id                     = $options['base_id'];
50
-			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
54
-			$this->options = $options;
55
-
56
-			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
-
59
-			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
-					unset($this->options['output_types'][$key]);
65
-				}
66
-			}
8
+    define( 'SUPER_DUPER_VER', '1.2.25' );
9
+
10
+    /**
11
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
+     *
13
+     * Should not be called direct but extended instead.
14
+     *
15
+     * Class WP_Super_Duper
16
+     * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
+     * @ver 1.1.1
18
+     */
19
+    class WP_Super_Duper extends WP_Widget {
20
+
21
+        public $version = SUPER_DUPER_VER;
22
+        public $font_awesome_icon_version = "5.11.2";
23
+        public $block_code;
24
+        public $options;
25
+        public $base_id;
26
+        public $settings_hash;
27
+        public $arguments = array();
28
+        public $instance = array();
29
+        private $class_name;
67 30
 
68
-			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
-			}
31
+        /**
32
+         * The relative url to the current folder.
33
+         *
34
+         * @var string
35
+         */
36
+        public $url = '';
37
+
38
+        /**
39
+         * Take the array options and use them to build.
40
+         */
41
+        public function __construct( $options ) {
42
+            global $sd_widgets;
43
+
44
+            $sd_widgets[ $options['base_id'] ] = array(
45
+                'name'       => $options['name'],
46
+                'class_name' => $options['class_name'],
47
+                'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
+            );
49
+            $this->base_id                     = $options['base_id'];
50
+            // lets filter the options before we do anything
51
+            $options       = apply_filters( "wp_super_duper_options", $options );
52
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
+            $options       = $this->add_name_from_key( $options );
54
+            $this->options = $options;
55
+
56
+            $this->base_id   = $options['base_id'];
57
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
+
59
+            // nested blocks can't work as a widget
60
+            if(!empty($this->options['nested-block'])){
61
+                if(empty($this->options['output_types'])){
62
+                    $this->options['output_types'] = array('shortcode','block');
63
+                }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
+                    unset($this->options['output_types'][$key]);
65
+                }
66
+            }
72 67
 
68
+            // init parent
69
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
+                parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
+            }
73 72
 
74
-			if ( isset( $options['class_name'] ) ) {
75
-				// register widget
76
-				$this->class_name = $options['class_name'];
77 73
 
78
-				// register shortcode, this needs to be done even for blocks and widgets
79
-				$this->register_shortcode();
74
+            if ( isset( $options['class_name'] ) ) {
75
+                // register widget
76
+                $this->class_name = $options['class_name'];
80 77
 
78
+                // register shortcode, this needs to be done even for blocks and widgets
79
+                $this->register_shortcode();
81 80
 
82
-				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
85
-				}
81
+
82
+                // Fusion Builder (avada) support
83
+                if ( function_exists( 'fusion_builder_map' ) ) {
84
+                    add_action( 'init', array( $this, 'register_fusion_element' ) );
85
+                }
86 86
 
87 87
                 // maybe load the Bricks transformer class
88 88
                 if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
89
+                    add_action( 'init', array( $this, 'load_bricks_element_class' ) );
90 90
                 }
91 91
 
92
-				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
-				}
96
-			}
92
+                // register block
93
+                if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
+                    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
+                }
96
+            }
97 97
 
98
-			// add the CSS and JS we need ONCE
99
-			global $sd_widget_scripts;
98
+            // add the CSS and JS we need ONCE
99
+            global $sd_widget_scripts;
100 100
 
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
101
+            if ( ! $sd_widget_scripts ) {
102
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
+                wp_add_inline_style( 'widgets', $this->widget_css() );
105 105
 
106
-				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
106
+                // maybe add elementor editor styles
107
+                add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
108 108
 
109
-				$sd_widget_scripts = true;
109
+                $sd_widget_scripts = true;
110 110
 
111
-				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
-				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
-				}
111
+                // add shortcode insert button once
112
+                add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
+                // generatepress theme sections compatibility
115
+                if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
+                    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
+                }
118 118
 
119
-				/* Load script on Divi theme builder page */
120
-				if ( ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) || ( function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled() && isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] && et_pb_is_allowed( 'use_visual_builder' ) ) ) {
121
-					add_thickbox();
122
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
123
-				}
119
+                /* Load script on Divi theme builder page */
120
+                if ( ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) || ( function_exists( 'et_builder_d5_enabled' ) && et_builder_d5_enabled() && isset( $_GET['et_fb'] ) && '1' === $_GET['et_fb'] && et_pb_is_allowed( 'use_visual_builder' ) ) ) {
121
+                    add_thickbox();
122
+                    add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
123
+                }
124 124
 
125
-				if ( $this->is_preview() ) {
126
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
127
-					// this makes the insert button work for elementor
128
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
129
-						$this,
130
-						'shortcode_insert_button_script'
131
-					) ); // for elementor
132
-				}
133
-				// this makes the insert button work for cornerstone
134
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
125
+                if ( $this->is_preview() ) {
126
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
127
+                    // this makes the insert button work for elementor
128
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
129
+                        $this,
130
+                        'shortcode_insert_button_script'
131
+                    ) ); // for elementor
132
+                }
133
+                // this makes the insert button work for cornerstone
134
+                add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
135 135
 
136
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
137
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
136
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
137
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
138 138
 
139
-				// add generator text to head
140
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
141
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
142
-			}
139
+                // add generator text to head
140
+                add_action( 'admin_head', array( $this, 'generator' ), 99 );
141
+                add_action( 'wp_head', array( $this, 'generator' ), 99 );
142
+            }
143 143
 
144
-			do_action( 'wp_super_duper_widget_init', $options, $this );
145
-		}
144
+            do_action( 'wp_super_duper_widget_init', $options, $this );
145
+        }
146 146
 
147 147
         /**
148 148
          * Load the Bricks conversion class if we are running Bricks.
@@ -152,163 +152,163 @@  discard block
 block discarded – undo
152 152
                     include_once __DIR__ . '/includes/class-super-duper-bricks-element.php';
153 153
         }
154 154
 
155
-		/**
156
-		 * The register widget function
157
-		 * @return void
158
-		 */
159
-		public function _register() {
160
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
161
-				parent::_register();
162
-			}
163
-		}
164
-
165
-		/**
166
-		 * Add our widget CSS to elementor editor.
167
-		 */
168
-		public function elementor_editor_styles() {
169
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
170
-		}
171
-
172
-		public function register_fusion_element() {
173
-
174
-			$options = $this->options;
175
-
176
-			if ( $this->base_id ) {
177
-
178
-				$params = $this->get_fusion_params();
179
-
180
-				$args = array(
181
-					'name'            => $options['name'],
182
-					'shortcode'       => $this->base_id,
183
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
184
-					'allow_generator' => true,
185
-				);
186
-
187
-				if ( ! empty( $params ) ) {
188
-					$args['params'] = $params;
189
-				}
190
-
191
-				fusion_builder_map( $args );
192
-			}
155
+        /**
156
+         * The register widget function
157
+         * @return void
158
+         */
159
+        public function _register() {
160
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
161
+                parent::_register();
162
+            }
163
+        }
193 164
 
194
-		}
165
+        /**
166
+         * Add our widget CSS to elementor editor.
167
+         */
168
+        public function elementor_editor_styles() {
169
+            wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
170
+        }
195 171
 
196
-		public function get_fusion_params() {
197
-			$params    = array();
198
-			$arguments = $this->get_arguments();
199
-
200
-			if ( ! empty( $arguments ) ) {
201
-				foreach ( $arguments as $key => $val ) {
202
-					$param = array();
203
-					// type
204
-					$param['type'] = str_replace(
205
-						array(
206
-							"text",
207
-							"number",
208
-							"email",
209
-							"color",
210
-							"checkbox"
211
-						),
212
-						array(
213
-							"textfield",
214
-							"textfield",
215
-							"textfield",
216
-							"colorpicker",
217
-							"select",
172
+        public function register_fusion_element() {
218 173
 
219
-						),
220
-						$val['type'] );
174
+            $options = $this->options;
221 175
 
222
-					// multiselect
223
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
224
-						$param['type']     = 'multiple_select';
225
-						$param['multiple'] = true;
226
-					}
176
+            if ( $this->base_id ) {
227 177
 
228
-					// heading
229
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
178
+                $params = $this->get_fusion_params();
230 179
 
231
-					// description
232
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
180
+                $args = array(
181
+                    'name'            => $options['name'],
182
+                    'shortcode'       => $this->base_id,
183
+                    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
184
+                    'allow_generator' => true,
185
+                );
233 186
 
234
-					// param_name
235
-					$param['param_name'] = $key;
187
+                if ( ! empty( $params ) ) {
188
+                    $args['params'] = $params;
189
+                }
236 190
 
237
-					// Default
238
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
191
+                fusion_builder_map( $args );
192
+            }
239 193
 
240
-					// Group
241
-					if ( isset( $val['group'] ) ) {
242
-						$param['group'] = $val['group'];
243
-					}
194
+        }
244 195
 
245
-					// value
246
-					if ( $val['type'] == 'checkbox' ) {
247
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
248
-							unset( $param['default'] );
249
-						}
250
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
251
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
252
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
253
-					} else {
254
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
255
-					}
196
+        public function get_fusion_params() {
197
+            $params    = array();
198
+            $arguments = $this->get_arguments();
199
+
200
+            if ( ! empty( $arguments ) ) {
201
+                foreach ( $arguments as $key => $val ) {
202
+                    $param = array();
203
+                    // type
204
+                    $param['type'] = str_replace(
205
+                        array(
206
+                            "text",
207
+                            "number",
208
+                            "email",
209
+                            "color",
210
+                            "checkbox"
211
+                        ),
212
+                        array(
213
+                            "textfield",
214
+                            "textfield",
215
+                            "textfield",
216
+                            "colorpicker",
217
+                            "select",
218
+
219
+                        ),
220
+                        $val['type'] );
221
+
222
+                    // multiselect
223
+                    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
224
+                        $param['type']     = 'multiple_select';
225
+                        $param['multiple'] = true;
226
+                    }
227
+
228
+                    // heading
229
+                    $param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
230
+
231
+                    // description
232
+                    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
233
+
234
+                    // param_name
235
+                    $param['param_name'] = $key;
236
+
237
+                    // Default
238
+                    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
239
+
240
+                    // Group
241
+                    if ( isset( $val['group'] ) ) {
242
+                        $param['group'] = $val['group'];
243
+                    }
244
+
245
+                    // value
246
+                    if ( $val['type'] == 'checkbox' ) {
247
+                        if ( isset( $val['default'] ) && $val['default'] == '0' ) {
248
+                            unset( $param['default'] );
249
+                        }
250
+                        $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
251
+                    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
252
+                        $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
253
+                    } else {
254
+                        $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
255
+                    }
256
+
257
+                    // setup the param
258
+                    $params[] = $param;
256 259
 
257
-					// setup the param
258
-					$params[] = $param;
260
+                }
261
+            }
259 262
 
260
-				}
261
-			}
262 263
 
264
+            return $params;
265
+        }
263 266
 
264
-			return $params;
265
-		}
267
+        /**
268
+         * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
269
+         */
270
+        public static function maybe_cornerstone_builder() {
271
+            if ( did_action( 'cornerstone_before_boot_app' ) ) {
272
+                self::shortcode_insert_button_script();
273
+            }
274
+        }
266 275
 
267
-		/**
268
-		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
269
-		 */
270
-		public static function maybe_cornerstone_builder() {
271
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
272
-				self::shortcode_insert_button_script();
273
-			}
274
-		}
276
+        /**
277
+         * A function to ge the shortcode builder picker html.
278
+         *
279
+         * @param string $editor_id
280
+         *
281
+         * @return string
282
+         */
283
+        public static function get_picker( $editor_id = '' ) {
275 284
 
276
-		/**
277
-		 * A function to ge the shortcode builder picker html.
278
-		 *
279
-		 * @param string $editor_id
280
-		 *
281
-		 * @return string
282
-		 */
283
-		public static function get_picker( $editor_id = '' ) {
284
-
285
-			ob_start();
286
-			if ( isset( $_POST['editor_id'] ) ) {
287
-				$editor_id = esc_attr( $_POST['editor_id'] );
288
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
289
-				$editor_id = 'main_content_content_vb_tiny_mce';
290
-			}
285
+            ob_start();
286
+            if ( isset( $_POST['editor_id'] ) ) {
287
+                $editor_id = esc_attr( $_POST['editor_id'] );
288
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
289
+                $editor_id = 'main_content_content_vb_tiny_mce';
290
+            }
291 291
 
292
-			global $sd_widgets;
292
+            global $sd_widgets;
293 293
 
294 294
 //			print_r($sd_widgets);exit;
295
-			?>
295
+            ?>
296 296
 
297 297
 			<div class="sd-shortcode-left-wrap">
298 298
 				<?php
299
-				ksort( $sd_widgets );
300
-				//				print_r($sd_widgets);exit;
301
-				if ( ! empty( $sd_widgets ) ) {
302
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
303
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
304
-					foreach ( $sd_widgets as $shortcode => $class ) {
305
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
306
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
307
-					}
308
-					echo "</select>";
299
+                ksort( $sd_widgets );
300
+                //				print_r($sd_widgets);exit;
301
+                if ( ! empty( $sd_widgets ) ) {
302
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
303
+                    echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
304
+                    foreach ( $sd_widgets as $shortcode => $class ) {
305
+                        if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
306
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
307
+                    }
308
+                    echo "</select>";
309 309
 
310
-				}
311
-				?>
310
+                }
311
+                ?>
312 312
 				<div class="sd-shortcode-settings"></div>
313 313
 			</div>
314 314
 			<div class="sd-shortcode-right-wrap">
@@ -321,147 +321,147 @@  discard block
 block discarded – undo
321 321
 				</div>
322 322
 			</div>
323 323
 			<?php
324
-			$html = ob_get_clean();
325
-
326
-			if ( wp_doing_ajax() ) {
327
-				echo $html;
328
-				$should_die = true;
329
-
330
-				// some builder get the editor via ajax so we should not die on those occasions
331
-				$dont_die = array(
332
-					'parent_tag',// WP Bakery
333
-					'avia_request' // enfold
334
-				);
324
+            $html = ob_get_clean();
325
+
326
+            if ( wp_doing_ajax() ) {
327
+                echo $html;
328
+                $should_die = true;
329
+
330
+                // some builder get the editor via ajax so we should not die on those occasions
331
+                $dont_die = array(
332
+                    'parent_tag',// WP Bakery
333
+                    'avia_request' // enfold
334
+                );
335
+
336
+                foreach ( $dont_die as $request ) {
337
+                    if ( isset( $_REQUEST[ $request ] ) ) {
338
+                        $should_die = false;
339
+                    }
340
+                }
335 341
 
336
-				foreach ( $dont_die as $request ) {
337
-					if ( isset( $_REQUEST[ $request ] ) ) {
338
-						$should_die = false;
339
-					}
340
-				}
342
+                if ( $should_die ) {
343
+                    wp_die();
344
+                }
345
+            } else {
346
+                return $html;
347
+            }
341 348
 
342
-				if ( $should_die ) {
343
-					wp_die();
344
-				}
345
-			} else {
346
-				return $html;
347
-			}
349
+            return '';
350
+        }
348 351
 
349
-			return '';
350
-		}
352
+        /**
353
+         * Output the version in the header.
354
+         */
355
+        public function generator() {
356
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
357
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
358
+
359
+            // Find source plugin/theme of SD
360
+            $source = array();
361
+            if ( strpos( $file, $plugins_dir ) !== false ) {
362
+                $source = explode( "/", plugin_basename( $file ) );
363
+            } else if ( function_exists( 'get_theme_root' ) ) {
364
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
365
+
366
+                if ( strpos( $file, $themes_dir ) !== false ) {
367
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
368
+                }
369
+            }
351 370
 
352
-		/**
353
-		 * Output the version in the header.
354
-		 */
355
-		public function generator() {
356
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
357
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
358
-
359
-			// Find source plugin/theme of SD
360
-			$source = array();
361
-			if ( strpos( $file, $plugins_dir ) !== false ) {
362
-				$source = explode( "/", plugin_basename( $file ) );
363
-			} else if ( function_exists( 'get_theme_root' ) ) {
364
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
365
-
366
-				if ( strpos( $file, $themes_dir ) !== false ) {
367
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
368
-				}
369
-			}
371
+            echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
372
+        }
370 373
 
371
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
372
-		}
374
+        /**
375
+         * Get widget settings.
376
+         *
377
+         * @since 1.0.0
378
+         */
379
+        public static function get_widget_settings() {
380
+            global $sd_widgets;
373 381
 
374
-		/**
375
-		 * Get widget settings.
376
-		 *
377
-		 * @since 1.0.0
378
-		 */
379
-		public static function get_widget_settings() {
380
-			global $sd_widgets;
381
-
382
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
383
-			if ( ! $shortcode ) {
384
-				wp_die();
385
-			}
386
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
387
-			if ( ! $widget_args ) {
388
-				wp_die();
389
-			}
390
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
391
-			if ( ! $class_name ) {
392
-				wp_die();
393
-			}
382
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
383
+            if ( ! $shortcode ) {
384
+                wp_die();
385
+            }
386
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
387
+            if ( ! $widget_args ) {
388
+                wp_die();
389
+            }
390
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
391
+            if ( ! $class_name ) {
392
+                wp_die();
393
+            }
394 394
 
395
-			// invoke an instance method
396
-			$widget = new $class_name;
395
+            // invoke an instance method
396
+            $widget = new $class_name;
397 397
 
398
-			ob_start();
399
-			$widget->form( array() );
400
-			$form = ob_get_clean();
401
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
402
-			echo "<style>" . $widget->widget_css() . "</style>";
403
-			echo "<script>" . $widget->widget_js() . "</script>";
404
-			?>
398
+            ob_start();
399
+            $widget->form( array() );
400
+            $form = ob_get_clean();
401
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
402
+            echo "<style>" . $widget->widget_css() . "</style>";
403
+            echo "<script>" . $widget->widget_js() . "</script>";
404
+            ?>
405 405
 			<?php
406
-			wp_die();
407
-		}
408
-
409
-		/**
410
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
411
-		 *
412
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
413
-		 * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
414
-		 *
415
-		 *@since 1.0.0
416
-		 *
417
-		 */
418
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
419
-			global $sd_widgets, $shortcode_insert_button_once;
420
-			if ( $shortcode_insert_button_once ) {
421
-				return;
422
-			}
423
-			add_thickbox();
406
+            wp_die();
407
+        }
424 408
 
425
-			/**
426
-			 * Cornerstone makes us play dirty tricks :/
427
-			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
428
-			 */
429
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
430
-				echo '<span id="insert-media-button">';
431
-			}
409
+        /**
410
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
411
+         *
412
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
413
+         * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
414
+         *
415
+         *@since 1.0.0
416
+         *
417
+         */
418
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
419
+            global $sd_widgets, $shortcode_insert_button_once;
420
+            if ( $shortcode_insert_button_once ) {
421
+                return;
422
+            }
423
+            add_thickbox();
424
+
425
+            /**
426
+             * Cornerstone makes us play dirty tricks :/
427
+             * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
428
+             */
429
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
430
+                echo '<span id="insert-media-button">';
431
+            }
432 432
 
433
-			echo self::shortcode_button( 'this', 'true' );
433
+            echo self::shortcode_button( 'this', 'true' );
434 434
 
435
-			// see opening note
436
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
437
-				echo '</span>'; // end #insert-media-button
438
-			}
435
+            // see opening note
436
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
437
+                echo '</span>'; // end #insert-media-button
438
+            }
439 439
 
440
-			// Add separate script for generatepress theme sections
441
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
442
-			} else {
443
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
444
-			}
440
+            // Add separate script for generatepress theme sections
441
+            if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
442
+            } else {
443
+                self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
444
+            }
445 445
 
446
-			$shortcode_insert_button_once = true;
447
-		}
446
+            $shortcode_insert_button_once = true;
447
+        }
448 448
 
449
-		/**
450
-		 * Gets the shortcode insert button html.
451
-		 *
452
-		 * @param string $id
453
-		 * @param string $search_for_id
454
-		 *
455
-		 * @return mixed
456
-		 */
457
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
458
-			ob_start();
459
-			?>
449
+        /**
450
+         * Gets the shortcode insert button html.
451
+         *
452
+         * @param string $id
453
+         * @param string $search_for_id
454
+         *
455
+         * @return mixed
456
+         */
457
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
458
+            ob_start();
459
+            ?>
460 460
 			<span class="sd-lable-shortcode-inserter">
461 461
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
462
-				if ( $search_for_id ) {
463
-					echo "," . $search_for_id;
464
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
462
+                if ( $search_for_id ) {
463
+                    echo "," . $search_for_id;
464
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
465 465
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
466 466
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
467 467
 						  class="dashicons dashicons-screenoptions"></span>
@@ -472,21 +472,21 @@  discard block
 block discarded – undo
472 472
 			</span>
473 473
 
474 474
 			<?php
475
-			$html = ob_get_clean();
475
+            $html = ob_get_clean();
476 476
 
477
-			// remove line breaks so we can use it in js
478
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
479
-		}
477
+            // remove line breaks so we can use it in js
478
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
479
+        }
480 480
 
481
-		/**
482
-		 * Makes SD work with the siteOrigin page builder.
483
-		 *
484
-		 * @return mixed
485
-		 *@since 1.0.6
486
-		 */
487
-		public static function siteorigin_js() {
488
-			ob_start();
489
-			?>
481
+        /**
482
+         * Makes SD work with the siteOrigin page builder.
483
+         *
484
+         * @return mixed
485
+         *@since 1.0.6
486
+         */
487
+        public static function siteorigin_js() {
488
+            ob_start();
489
+            ?>
490 490
 			<script>
491 491
 				/**
492 492
 				 * Check a form to see what items should be shown or hidden.
@@ -560,29 +560,29 @@  discard block
 block discarded – undo
560 560
 				});
561 561
 			</script>
562 562
 			<?php
563
-			$output = ob_get_clean();
563
+            $output = ob_get_clean();
564 564
 
565
-			/*
565
+            /*
566 566
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
567 567
 			 */
568 568
 
569
-			return str_replace( array(
570
-				'<script>',
571
-				'</script>'
572
-			), '', $output );
573
-		}
569
+            return str_replace( array(
570
+                '<script>',
571
+                '</script>'
572
+            ), '', $output );
573
+        }
574 574
 
575
-		/**
576
-		 * Output the JS and CSS for the shortcode insert button.
577
-		 *
578
-		 * @param string $editor_id
579
-		 * @param string $insert_shortcode_function
580
-		 *
581
-		 *@since 1.0.6
582
-		 *
583
-		 */
584
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
585
-			?>
575
+        /**
576
+         * Output the JS and CSS for the shortcode insert button.
577
+         *
578
+         * @param string $editor_id
579
+         * @param string $insert_shortcode_function
580
+         *
581
+         *@since 1.0.6
582
+         *
583
+         */
584
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
585
+            ?>
586 586
 			<style>
587 587
 				.sd-shortcode-left-wrap {
588 588
 					float: left;
@@ -710,35 +710,35 @@  discard block
 block discarded – undo
710 710
 				<?php } ?>
711 711
 			</style>
712 712
 			<?php
713
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
714
-				echo "<script>" . self::siteorigin_js() . "</script>";
715
-			}
716
-			?>
713
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
714
+                echo "<script>" . self::siteorigin_js() . "</script>";
715
+            }
716
+            ?>
717 717
 			<script>
718 718
 				<?php
719
-				if(! empty( $insert_shortcode_function )){
720
-					echo $insert_shortcode_function;
721
-				}else{
722
-
723
-				/**
724
-				 * Function for super duper insert shortcode.
725
-				 *
726
-				 * @since 1.0.0
727
-				 */
728
-				?>
719
+                if(! empty( $insert_shortcode_function )){
720
+                    echo $insert_shortcode_function;
721
+                }else{
722
+
723
+                /**
724
+                 * Function for super duper insert shortcode.
725
+                 *
726
+                 * @since 1.0.0
727
+                 */
728
+                ?>
729 729
 				function sd_insert_shortcode($editor_id) {
730 730
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
731 731
 					if ($shortcode) {
732 732
 						if (!$editor_id) {
733 733
 							<?php
734
-							if ( isset( $_REQUEST['et_fb'] ) ) {
735
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
736
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
737
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
738
-							} else {
739
-								echo '$editor_id = "#wp-content-editor-container textarea";';
740
-							}
741
-							?>
734
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
735
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
736
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
737
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
738
+                            } else {
739
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
740
+                            }
741
+                            ?>
742 742
 						} else {
743 743
 							$editor_id = '#' + $editor_id;
744 744
 						}
@@ -1069,18 +1069,18 @@  discard block
 block discarded – undo
1069 1069
 				}
1070 1070
 			</script>
1071 1071
 			<?php
1072
-		}
1072
+        }
1073 1073
 
1074
-		/**
1075
-		 * Gets some CSS for the widgets screen.
1076
-		 *
1077
-		 * @param bool $advanced If we should include advanced CSS.
1078
-		 *
1079
-		 * @return mixed
1080
-		 */
1081
-		public function widget_css( $advanced = true ) {
1082
-			ob_start();
1083
-			?>
1074
+        /**
1075
+         * Gets some CSS for the widgets screen.
1076
+         *
1077
+         * @param bool $advanced If we should include advanced CSS.
1078
+         *
1079
+         * @return mixed
1080
+         */
1081
+        public function widget_css( $advanced = true ) {
1082
+            ob_start();
1083
+            ?>
1084 1084
 			<style>
1085 1085
 				<?php if( $advanced ){ ?>
1086 1086
 				.sd-advanced-setting {
@@ -1120,26 +1120,26 @@  discard block
 block discarded – undo
1120 1120
 				.elementor-control .sd-argument select[multiple] option{padding:3px}
1121 1121
 			</style>
1122 1122
 			<?php
1123
-			$output = ob_get_clean();
1123
+            $output = ob_get_clean();
1124 1124
 
1125
-			/*
1125
+            /*
1126 1126
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1127 1127
 			 */
1128 1128
 
1129
-			return str_replace( array(
1130
-				'<style>',
1131
-				'</style>'
1132
-			), '', $output );
1133
-		}
1129
+            return str_replace( array(
1130
+                '<style>',
1131
+                '</style>'
1132
+            ), '', $output );
1133
+        }
1134 1134
 
1135
-		/**
1136
-		 * Gets some JS for the widgets screen.
1137
-		 *
1138
-		 * @return mixed
1139
-		 */
1140
-		public function widget_js() {
1141
-			ob_start();
1142
-			?>
1135
+        /**
1136
+         * Gets some JS for the widgets screen.
1137
+         *
1138
+         * @return mixed
1139
+         */
1140
+        public function widget_js() {
1141
+            ob_start();
1142
+            ?>
1143 1143
 			<script>
1144 1144
 
1145 1145
 				/**
@@ -1290,517 +1290,517 @@  discard block
 block discarded – undo
1290 1290
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1291 1291
 			</script>
1292 1292
 			<?php
1293
-			$output = ob_get_clean();
1293
+            $output = ob_get_clean();
1294 1294
 
1295
-			/*
1295
+            /*
1296 1296
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1297 1297
 			 */
1298 1298
 
1299
-			return str_replace( array(
1300
-				'<script>',
1301
-				'</script>'
1302
-			), '', $output );
1303
-		}
1299
+            return str_replace( array(
1300
+                '<script>',
1301
+                '</script>'
1302
+            ), '', $output );
1303
+        }
1304 1304
 
1305 1305
 
1306
-		/**
1307
-		 * Set the name from the argument key.
1308
-		 *
1309
-		 * @param $options
1310
-		 *
1311
-		 * @return mixed
1312
-		 */
1313
-		private function add_name_from_key( $options, $arguments = false ) {
1314
-			if ( ! empty( $options['arguments'] ) ) {
1315
-				foreach ( $options['arguments'] as $key => $val ) {
1316
-					$options['arguments'][ $key ]['name'] = $key;
1317
-				}
1318
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1319
-				foreach ( $options as $key => $val ) {
1320
-					$options[ $key ]['name'] = $key;
1321
-				}
1322
-			}
1306
+        /**
1307
+         * Set the name from the argument key.
1308
+         *
1309
+         * @param $options
1310
+         *
1311
+         * @return mixed
1312
+         */
1313
+        private function add_name_from_key( $options, $arguments = false ) {
1314
+            if ( ! empty( $options['arguments'] ) ) {
1315
+                foreach ( $options['arguments'] as $key => $val ) {
1316
+                    $options['arguments'][ $key ]['name'] = $key;
1317
+                }
1318
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1319
+                foreach ( $options as $key => $val ) {
1320
+                    $options[ $key ]['name'] = $key;
1321
+                }
1322
+            }
1323 1323
 
1324
-			return $options;
1325
-		}
1324
+            return $options;
1325
+        }
1326 1326
 
1327
-		/**
1328
-		 * Register the parent shortcode.
1329
-		 *
1330
-		 * @since 1.0.0
1331
-		 */
1332
-		public function register_shortcode() {
1333
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1334
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1335
-		}
1327
+        /**
1328
+         * Register the parent shortcode.
1329
+         *
1330
+         * @since 1.0.0
1331
+         */
1332
+        public function register_shortcode() {
1333
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1334
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1335
+        }
1336 1336
 
1337
-		/**
1338
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1339
-		 *
1340
-		 * @since 1.0.0
1341
-		 */
1342
-		public function render_shortcode() {
1343
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1344
-			if ( ! current_user_can( 'manage_options' ) ) {
1345
-				wp_die();
1346
-			}
1337
+        /**
1338
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1339
+         *
1340
+         * @since 1.0.0
1341
+         */
1342
+        public function render_shortcode() {
1343
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1344
+            if ( ! current_user_can( 'manage_options' ) ) {
1345
+                wp_die();
1346
+            }
1347 1347
 
1348
-			// we might need the $post value here so lets set it.
1349
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1350
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1351
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1352
-					global $post;
1353
-					$post = $post_obj;
1354
-				}
1355
-			}
1348
+            // we might need the $post value here so lets set it.
1349
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1350
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1351
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1352
+                    global $post;
1353
+                    $post = $post_obj;
1354
+                }
1355
+            }
1356 1356
 
1357
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1358
-				$is_preview = $this->is_preview();
1359
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1360
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1361
-				$attributes       = '';
1362
-				if ( ! empty( $attributes_array ) ) {
1363
-					foreach ( $attributes_array as $key => $value ) {
1364
-						if ( is_array( $value ) ) {
1365
-							$value = implode( ",", $value );
1366
-						}
1357
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1358
+                $is_preview = $this->is_preview();
1359
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1360
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1361
+                $attributes       = '';
1362
+                if ( ! empty( $attributes_array ) ) {
1363
+                    foreach ( $attributes_array as $key => $value ) {
1364
+                        if ( is_array( $value ) ) {
1365
+                            $value = implode( ",", $value );
1366
+                        }
1367
+
1368
+                        if ( ! empty( $value ) ) {
1369
+                            $value = wp_unslash( $value );
1370
+
1371
+                            // Encode [ and ].
1372
+                            if ( $is_preview ) {
1373
+                                $value = $this->encode_shortcodes( $value );
1374
+                            }
1375
+                        }
1376
+                        $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1377
+                    }
1378
+                }
1367 1379
 
1368
-						if ( ! empty( $value ) ) {
1369
-							$value = wp_unslash( $value );
1380
+                $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1370 1381
 
1371
-							// Encode [ and ].
1372
-							if ( $is_preview ) {
1373
-								$value = $this->encode_shortcodes( $value );
1374
-							}
1375
-						}
1376
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1377
-					}
1378
-				}
1382
+                $content = do_shortcode( $shortcode );
1379 1383
 
1380
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1384
+                // Decode [ and ].
1385
+                if ( ! empty( $content ) && $is_preview ) {
1386
+                    $content = $this->decode_shortcodes( $content );
1387
+                }
1381 1388
 
1382
-				$content = do_shortcode( $shortcode );
1389
+                echo $content;
1390
+            }
1391
+            wp_die();
1392
+        }
1383 1393
 
1384
-				// Decode [ and ].
1385
-				if ( ! empty( $content ) && $is_preview ) {
1386
-					$content = $this->decode_shortcodes( $content );
1387
-				}
1394
+        /**
1395
+         * Output the shortcode.
1396
+         *
1397
+         * @param array $args
1398
+         * @param string $content
1399
+         *
1400
+         * @return string
1401
+         */
1402
+        public function shortcode_output( $args = array(), $content = '' ) {
1403
+            $_instance = $args;
1388 1404
 
1389
-				echo $content;
1390
-			}
1391
-			wp_die();
1392
-		}
1405
+            $args = $this->argument_values( $args );
1393 1406
 
1394
-		/**
1395
-		 * Output the shortcode.
1396
-		 *
1397
-		 * @param array $args
1398
-		 * @param string $content
1399
-		 *
1400
-		 * @return string
1401
-		 */
1402
-		public function shortcode_output( $args = array(), $content = '' ) {
1403
-			$_instance = $args;
1404
-
1405
-			$args = $this->argument_values( $args );
1406
-
1407
-			// add extra argument so we know its a output to gutenberg
1408
-			//$args
1409
-			$args = $this->string_to_bool( $args );
1410
-
1411
-			// if we have a enclosed shortcode we add it to the special `html` argument
1412
-			if ( ! empty( $content ) ) {
1413
-				$args['html'] = $content;
1414
-			}
1407
+            // add extra argument so we know its a output to gutenberg
1408
+            //$args
1409
+            $args = $this->string_to_bool( $args );
1415 1410
 
1416
-			if ( ! $this->is_preview() ) {
1417
-				/**
1418
-				 * Filters the settings for a particular widget args.
1419
-				 *
1420
-				 * @param array          $args      The current widget instance's settings.
1421
-				 * @param WP_Super_Duper $widget    The current widget settings.
1422
-				 * @param array          $_instance An array of default widget arguments.
1423
-				 *
1424
-				 *@since 1.0.28
1425
-				 *
1426
-				 */
1427
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1411
+            // if we have a enclosed shortcode we add it to the special `html` argument
1412
+            if ( ! empty( $content ) ) {
1413
+                $args['html'] = $content;
1414
+            }
1428 1415
 
1429
-				if ( ! is_array( $args ) ) {
1430
-					return $args;
1431
-				}
1432
-			}
1416
+            if ( ! $this->is_preview() ) {
1417
+                /**
1418
+                 * Filters the settings for a particular widget args.
1419
+                 *
1420
+                 * @param array          $args      The current widget instance's settings.
1421
+                 * @param WP_Super_Duper $widget    The current widget settings.
1422
+                 * @param array          $_instance An array of default widget arguments.
1423
+                 *
1424
+                 *@since 1.0.28
1425
+                 *
1426
+                 */
1427
+                $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1428
+
1429
+                if ( ! is_array( $args ) ) {
1430
+                    return $args;
1431
+                }
1432
+            }
1433 1433
 
1434
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1435
-			$class .= " sdel-".$this->get_instance_hash();
1434
+            $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1435
+            $class .= " sdel-".$this->get_instance_hash();
1436 1436
 
1437
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1438
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1437
+            $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1438
+            $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1439 1439
 
1440
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1441
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1440
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1441
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1442 1442
 
1443
-			$shortcode_args = array();
1444
-			$output         = '';
1445
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1446
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1447
-				$no_wrap = true;
1448
-			}
1449
-			$main_content = $this->output( $args, $shortcode_args, $content );
1450
-			if ( $main_content && ! $no_wrap ) {
1451
-				// wrap the shortcode in a div with the same class as the widget
1452
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1453
-				if ( ! empty( $args['title'] ) ) {
1454
-					// if its a shortcode and there is a title try to grab the title wrappers
1455
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1456
-					if ( empty( $instance ) ) {
1457
-						global $wp_registered_sidebars;
1458
-						if ( ! empty( $wp_registered_sidebars ) ) {
1459
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1460
-								if ( ! empty( $sidebar['before_title'] ) ) {
1461
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1462
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1463
-									break;
1464
-								}
1465
-							}
1466
-						}
1467
-					}
1468
-					$output .= $this->output_title( $shortcode_args, $args );
1469
-				}
1470
-				$output .= $main_content;
1471
-				$output .= '</div>';
1472
-			} elseif ( $main_content && $no_wrap ) {
1473
-				$output .= $main_content;
1474
-			}
1443
+            $shortcode_args = array();
1444
+            $output         = '';
1445
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1446
+            if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1447
+                $no_wrap = true;
1448
+            }
1449
+            $main_content = $this->output( $args, $shortcode_args, $content );
1450
+            if ( $main_content && ! $no_wrap ) {
1451
+                // wrap the shortcode in a div with the same class as the widget
1452
+                $output .= '<div class="' . $class . '" ' . $attrs . '>';
1453
+                if ( ! empty( $args['title'] ) ) {
1454
+                    // if its a shortcode and there is a title try to grab the title wrappers
1455
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1456
+                    if ( empty( $instance ) ) {
1457
+                        global $wp_registered_sidebars;
1458
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1459
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1460
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1461
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1462
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1463
+                                    break;
1464
+                                }
1465
+                            }
1466
+                        }
1467
+                    }
1468
+                    $output .= $this->output_title( $shortcode_args, $args );
1469
+                }
1470
+                $output .= $main_content;
1471
+                $output .= '</div>';
1472
+            } elseif ( $main_content && $no_wrap ) {
1473
+                $output .= $main_content;
1474
+            }
1475 1475
 
1476
-			// if preview show a placeholder if empty
1477
-			if ( $this->is_preview() && $output == '' ) {
1478
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1479
-			}
1476
+            // if preview show a placeholder if empty
1477
+            if ( $this->is_preview() && $output == '' ) {
1478
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1479
+            }
1480 1480
 
1481
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1482
-		}
1481
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1482
+        }
1483 1483
 
1484
-		/**
1485
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1486
-		 *
1487
-		 * @param string $name
1488
-		 *
1489
-		 * @return string
1490
-		 */
1491
-		public function preview_placeholder_text( $name = '' ) {
1492
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1493
-		}
1484
+        /**
1485
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1486
+         *
1487
+         * @param string $name
1488
+         *
1489
+         * @return string
1490
+         */
1491
+        public function preview_placeholder_text( $name = '' ) {
1492
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1493
+        }
1494 1494
 
1495
-		/**
1496
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1497
-		 *
1498
-		 * @param $options
1499
-		 *
1500
-		 * @return mixed
1501
-		 */
1502
-		public function string_to_bool( $options ) {
1503
-			// convert bool strings to booleans
1504
-			foreach ( $options as $key => $val ) {
1505
-				if ( $val == 'false' ) {
1506
-					$options[ $key ] = false;
1507
-				} elseif ( $val == 'true' ) {
1508
-					$options[ $key ] = true;
1509
-				}
1510
-			}
1495
+        /**
1496
+         * Sometimes booleans values can be turned to strings, so we fix that.
1497
+         *
1498
+         * @param $options
1499
+         *
1500
+         * @return mixed
1501
+         */
1502
+        public function string_to_bool( $options ) {
1503
+            // convert bool strings to booleans
1504
+            foreach ( $options as $key => $val ) {
1505
+                if ( $val == 'false' ) {
1506
+                    $options[ $key ] = false;
1507
+                } elseif ( $val == 'true' ) {
1508
+                    $options[ $key ] = true;
1509
+                }
1510
+            }
1511 1511
 
1512
-			return $options;
1513
-		}
1512
+            return $options;
1513
+        }
1514 1514
 
1515
-		/**
1516
-		 * Get the argument values that are also filterable.
1517
-		 *
1518
-		 * @param $instance
1519
-		 *
1520
-		 * @return array
1521
-		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1522
-		 *
1523
-		 */
1524
-		public function argument_values( $instance ) {
1525
-			$argument_values = array();
1526
-
1527
-			// set widget instance
1528
-			$this->instance = $instance;
1529
-
1530
-			if ( empty( $this->arguments ) ) {
1531
-				$this->arguments = $this->get_arguments();
1532
-			}
1515
+        /**
1516
+         * Get the argument values that are also filterable.
1517
+         *
1518
+         * @param $instance
1519
+         *
1520
+         * @return array
1521
+         *@since 1.0.12 Don't set checkbox default value if the value is empty.
1522
+         *
1523
+         */
1524
+        public function argument_values( $instance ) {
1525
+            $argument_values = array();
1533 1526
 
1534
-			if ( ! empty( $this->arguments ) ) {
1535
-				foreach ( $this->arguments as $key => $args ) {
1536
-					// set the input name from the key
1537
-					$args['name'] = $key;
1538
-					//
1539
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1540
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1541
-						// don't set default for an empty checkbox
1542
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1543
-						$argument_values[ $key ] = $args['default'];
1544
-					}
1545
-				}
1546
-			}
1527
+            // set widget instance
1528
+            $this->instance = $instance;
1547 1529
 
1548
-			return $argument_values;
1549
-		}
1530
+            if ( empty( $this->arguments ) ) {
1531
+                $this->arguments = $this->get_arguments();
1532
+            }
1550 1533
 
1551
-		/**
1552
-		 * Set arguments in super duper.
1553
-		 *
1554
-		 * @return array Set arguments.
1555
-		 *@since 1.0.0
1556
-		 *
1557
-		 */
1558
-		public function set_arguments() {
1559
-			return $this->arguments;
1560
-		}
1534
+            if ( ! empty( $this->arguments ) ) {
1535
+                foreach ( $this->arguments as $key => $args ) {
1536
+                    // set the input name from the key
1537
+                    $args['name'] = $key;
1538
+                    //
1539
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1540
+                    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1541
+                        // don't set default for an empty checkbox
1542
+                    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1543
+                        $argument_values[ $key ] = $args['default'];
1544
+                    }
1545
+                }
1546
+            }
1561 1547
 
1562
-		/**
1563
-		 * Get arguments in super duper.
1564
-		 *
1565
-		 * @return array Get arguments.
1566
-		 *@since 1.0.0
1567
-		 *
1568
-		 */
1569
-		public function get_arguments() {
1570
-			if ( empty( $this->arguments ) ) {
1571
-				$this->arguments = $this->set_arguments();
1572
-			}
1548
+            return $argument_values;
1549
+        }
1550
+
1551
+        /**
1552
+         * Set arguments in super duper.
1553
+         *
1554
+         * @return array Set arguments.
1555
+         *@since 1.0.0
1556
+         *
1557
+         */
1558
+        public function set_arguments() {
1559
+            return $this->arguments;
1560
+        }
1561
+
1562
+        /**
1563
+         * Get arguments in super duper.
1564
+         *
1565
+         * @return array Get arguments.
1566
+         *@since 1.0.0
1567
+         *
1568
+         */
1569
+        public function get_arguments() {
1570
+            if ( empty( $this->arguments ) ) {
1571
+                $this->arguments = $this->set_arguments();
1572
+            }
1573 1573
 
1574
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1575
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1574
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1575
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1576 1576
 
1577 1577
             if( !empty( $this->arguments['title']['value'] ) ){
1578 1578
                 $this->arguments['title']['value'] = wp_kses_post( $this->arguments['title']['value'] );
1579 1579
             }
1580 1580
 
1581
-			return $this->arguments;
1582
-		}
1581
+            return $this->arguments;
1582
+        }
1583 1583
 
1584
-		/**
1585
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1586
-		 *
1587
-		 * @param array $args
1588
-		 * @param array $widget_args
1589
-		 * @param string $content
1590
-		 */
1591
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1584
+        /**
1585
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1586
+         *
1587
+         * @param array $args
1588
+         * @param array $widget_args
1589
+         * @param string $content
1590
+         */
1591
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1592 1592
 
1593
-		}
1593
+        }
1594 1594
 
1595
-		/**
1596
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1597
-		 */
1598
-		public function register_block() {
1599
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1600
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1601
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1602
-			}
1603
-		}
1595
+        /**
1596
+         * Add the dynamic block code inline when the wp-block in enqueued.
1597
+         */
1598
+        public function register_block() {
1599
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1600
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1601
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1602
+            }
1603
+        }
1604 1604
 
1605
-		/**
1606
-		 * Check if we need to show advanced options.
1607
-		 *
1608
-		 * @return bool
1609
-		 */
1610
-		public function block_show_advanced() {
1611
-
1612
-			$show      = false;
1613
-			$arguments = $this->get_arguments();
1614
-
1615
-			if ( ! empty( $arguments ) ) {
1616
-				foreach ( $arguments as $argument ) {
1617
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1618
-						$show = true;
1619
-						break; // no need to continue if we know we have it
1620
-					}
1621
-				}
1622
-			}
1605
+        /**
1606
+         * Check if we need to show advanced options.
1607
+         *
1608
+         * @return bool
1609
+         */
1610
+        public function block_show_advanced() {
1623 1611
 
1624
-			return $show;
1625
-		}
1612
+            $show      = false;
1613
+            $arguments = $this->get_arguments();
1626 1614
 
1627
-		/**
1628
-		 * Get the url path to the current folder.
1629
-		 *
1630
-		 * @return string
1631
-		 */
1632
-		public function get_url() {
1633
-			$url = $this->url;
1634
-
1635
-			if ( ! $url ) {
1636
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1637
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1638
-
1639
-				// Replace http:// to https://.
1640
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1641
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1642
-				}
1615
+            if ( ! empty( $arguments ) ) {
1616
+                foreach ( $arguments as $argument ) {
1617
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1618
+                        $show = true;
1619
+                        break; // no need to continue if we know we have it
1620
+                    }
1621
+                }
1622
+            }
1643 1623
 
1644
-				// Check if we are inside a plugin
1645
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1646
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1647
-				$url = trailingslashit( $url );
1648
-				$this->url = $url;
1649
-			}
1624
+            return $show;
1625
+        }
1650 1626
 
1651
-			return $url;
1652
-		}
1627
+        /**
1628
+         * Get the url path to the current folder.
1629
+         *
1630
+         * @return string
1631
+         */
1632
+        public function get_url() {
1633
+            $url = $this->url;
1653 1634
 
1654
-		/**
1655
-		 * Get the url path to the current folder.
1656
-		 *
1657
-		 * @return string
1658
-		 */
1659
-		public function get_url_old() {
1635
+            if ( ! $url ) {
1636
+                $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1637
+                $content_url = untrailingslashit( WP_CONTENT_URL );
1660 1638
 
1661
-			$url = $this->url;
1639
+                // Replace http:// to https://.
1640
+                if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1641
+                    $content_url = str_replace( 'http://', 'https://', $content_url );
1642
+                }
1662 1643
 
1663
-			if ( ! $url ) {
1664
-				// check if we are inside a plugin
1665
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1644
+                // Check if we are inside a plugin
1645
+                $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1646
+                $url = str_replace( $content_dir, $content_url, $file_dir );
1647
+                $url = trailingslashit( $url );
1648
+                $this->url = $url;
1649
+            }
1666 1650
 
1667
-				$dir_parts = explode( "/wp-content/", $file_dir );
1668
-				$url_parts = explode( "/wp-content/", plugins_url() );
1651
+            return $url;
1652
+        }
1669 1653
 
1670
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1671
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1672
-					$this->url = $url;
1673
-				}
1674
-			}
1654
+        /**
1655
+         * Get the url path to the current folder.
1656
+         *
1657
+         * @return string
1658
+         */
1659
+        public function get_url_old() {
1675 1660
 
1661
+            $url = $this->url;
1676 1662
 
1677
-			return $url;
1678
-		}
1663
+            if ( ! $url ) {
1664
+                // check if we are inside a plugin
1665
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1679 1666
 
1680
-		/**
1681
-		 * Generate the block icon.
1682
-		 *
1683
-		 * Enables the use of Font Awesome icons.
1684
-		 *
1685
-		 * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1686
-		 *
1687
-		 * @param $icon
1688
-		 *
1689
-		 * @return string
1690
-		 *@since 1.1.0
1691
-		 */
1692
-		public function get_block_icon( $icon ) {
1693
-
1694
-			// check if we have a Font Awesome icon
1695
-			$fa_type = '';
1696
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1697
-				$fa_type = 'solid';
1698
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1699
-				$fa_type = 'regular';
1700
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1701
-				$fa_type = 'brands';
1702
-			} else {
1703
-				$icon = "'" . $icon . "'";
1704
-			}
1667
+                $dir_parts = explode( "/wp-content/", $file_dir );
1668
+                $url_parts = explode( "/wp-content/", plugins_url() );
1705 1669
 
1706
-			// set the icon if we found one
1707
-			if ( $fa_type ) {
1708
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1709
-				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1710
-			}
1670
+                if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1671
+                    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1672
+                    $this->url = $url;
1673
+                }
1674
+            }
1711 1675
 
1712
-			return $icon;
1713
-		}
1714 1676
 
1715
-		public function group_arguments( $arguments ) {
1716
-			if ( ! empty( $arguments ) ) {
1717
-				$temp_arguments = array();
1718
-				$general        = __( "General", 'ayecode-connect' );
1719
-				$add_sections   = false;
1720
-				foreach ( $arguments as $key => $args ) {
1721
-					if ( isset( $args['group'] ) ) {
1722
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1723
-						$add_sections                             = true;
1724
-					} else {
1725
-						$temp_arguments[ $general ][ $key ] = $args;
1726
-					}
1727
-				}
1677
+            return $url;
1678
+        }
1728 1679
 
1729
-				// only add sections if more than one
1730
-				if ( $add_sections ) {
1731
-					$arguments = $temp_arguments;
1732
-				}
1733
-			}
1680
+        /**
1681
+         * Generate the block icon.
1682
+         *
1683
+         * Enables the use of Font Awesome icons.
1684
+         *
1685
+         * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1686
+         *
1687
+         * @param $icon
1688
+         *
1689
+         * @return string
1690
+         *@since 1.1.0
1691
+         */
1692
+        public function get_block_icon( $icon ) {
1693
+
1694
+            // check if we have a Font Awesome icon
1695
+            $fa_type = '';
1696
+            if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1697
+                $fa_type = 'solid';
1698
+            } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1699
+                $fa_type = 'regular';
1700
+            } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1701
+                $fa_type = 'brands';
1702
+            } else {
1703
+                $icon = "'" . $icon . "'";
1704
+            }
1734 1705
 
1735
-			return $arguments;
1736
-		}
1706
+            // set the icon if we found one
1707
+            if ( $fa_type ) {
1708
+                $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1709
+                $icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1710
+            }
1737 1711
 
1738
-		/**
1739
-		 * Parse used group tabs.
1740
-		 *
1741
-		 * @since 1.1.17
1742
-		 */
1743
-		public function group_block_tabs( $tabs, $arguments ) {
1744
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1745
-				$has_sections = false;
1746
-
1747
-				foreach ( $this->arguments as $key => $args ) {
1748
-					if ( isset( $args['group'] ) ) {
1749
-						$has_sections = true;
1750
-						break;
1751
-					}
1752
-				}
1712
+            return $icon;
1713
+        }
1753 1714
 
1754
-				if ( ! $has_sections ) {
1755
-					return $tabs;
1756
-				}
1715
+        public function group_arguments( $arguments ) {
1716
+            if ( ! empty( $arguments ) ) {
1717
+                $temp_arguments = array();
1718
+                $general        = __( "General", 'ayecode-connect' );
1719
+                $add_sections   = false;
1720
+                foreach ( $arguments as $key => $args ) {
1721
+                    if ( isset( $args['group'] ) ) {
1722
+                        $temp_arguments[ $args['group'] ][ $key ] = $args;
1723
+                        $add_sections                             = true;
1724
+                    } else {
1725
+                        $temp_arguments[ $general ][ $key ] = $args;
1726
+                    }
1727
+                }
1757 1728
 
1758
-				$new_tabs = array();
1729
+                // only add sections if more than one
1730
+                if ( $add_sections ) {
1731
+                    $arguments = $temp_arguments;
1732
+                }
1733
+            }
1759 1734
 
1760
-				foreach ( $tabs as $tab_key => $tab ) {
1761
-					$new_groups = array();
1735
+            return $arguments;
1736
+        }
1762 1737
 
1763
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1764
-						foreach ( $tab['groups'] as $group ) {
1765
-							if ( isset( $arguments[ $group ] ) ) {
1766
-								$new_groups[] = $group;
1767
-							}
1768
-						}
1769
-					}
1738
+        /**
1739
+         * Parse used group tabs.
1740
+         *
1741
+         * @since 1.1.17
1742
+         */
1743
+        public function group_block_tabs( $tabs, $arguments ) {
1744
+            if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1745
+                $has_sections = false;
1746
+
1747
+                foreach ( $this->arguments as $key => $args ) {
1748
+                    if ( isset( $args['group'] ) ) {
1749
+                        $has_sections = true;
1750
+                        break;
1751
+                    }
1752
+                }
1770 1753
 
1771
-					if ( ! empty( $new_groups ) ) {
1772
-						$tab['groups'] = $new_groups;
1754
+                if ( ! $has_sections ) {
1755
+                    return $tabs;
1756
+                }
1773 1757
 
1774
-						$new_tabs[ $tab_key ] = $tab;
1775
-					}
1776
-				}
1758
+                $new_tabs = array();
1777 1759
 
1778
-				$tabs = $new_tabs;
1779
-			}
1760
+                foreach ( $tabs as $tab_key => $tab ) {
1761
+                    $new_groups = array();
1780 1762
 
1781
-			return $tabs;
1782
-		}
1763
+                    if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1764
+                        foreach ( $tab['groups'] as $group ) {
1765
+                            if ( isset( $arguments[ $group ] ) ) {
1766
+                                $new_groups[] = $group;
1767
+                            }
1768
+                        }
1769
+                    }
1770
+
1771
+                    if ( ! empty( $new_groups ) ) {
1772
+                        $tab['groups'] = $new_groups;
1773
+
1774
+                        $new_tabs[ $tab_key ] = $tab;
1775
+                    }
1776
+                }
1777
+
1778
+                $tabs = $new_tabs;
1779
+            }
1780
+
1781
+            return $tabs;
1782
+        }
1783 1783
 
1784
-		/**
1785
-		 * Output the JS for building the dynamic Guntenberg block.
1786
-		 *
1787
-		 * @return mixed
1788
-		 *@since 1.0.9 Save numbers as numbers and not strings.
1789
-		 * @since 1.1.0 Font Awesome classes can be used for icons.
1790
-		 * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1791
-		 */
1792
-		public function block() {
1793
-			global $sd_is_js_functions_loaded, $aui_bs5;
1794
-
1795
-			$show_advanced = $this->block_show_advanced();
1796
-
1797
-			ob_start();
1798
-			?>
1784
+        /**
1785
+         * Output the JS for building the dynamic Guntenberg block.
1786
+         *
1787
+         * @return mixed
1788
+         *@since 1.0.9 Save numbers as numbers and not strings.
1789
+         * @since 1.1.0 Font Awesome classes can be used for icons.
1790
+         * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1791
+         */
1792
+        public function block() {
1793
+            global $sd_is_js_functions_loaded, $aui_bs5;
1794
+
1795
+            $show_advanced = $this->block_show_advanced();
1796
+
1797
+            ob_start();
1798
+            ?>
1799 1799
 			<script>
1800 1800
 			<?php
1801
-			if ( ! $sd_is_js_functions_loaded ) {
1802
-				$sd_is_js_functions_loaded = true;
1803
-			?>
1801
+            if ( ! $sd_is_js_functions_loaded ) {
1802
+                $sd_is_js_functions_loaded = true;
1803
+            ?>
1804 1804
 function sd_show_view_options($this){
1805 1805
 	if(jQuery($this).html().length){
1806 1806
 		jQuery($this).html('');
@@ -2300,8 +2300,8 @@  discard block
 block discarded – undo
2300 2300
 				$classes = [];
2301 2301
 
2302 2302
 				<?php
2303
-				if($aui_bs5){
2304
-					?>
2303
+                if($aui_bs5){
2304
+                    ?>
2305 2305
 				$aui_bs5 = true;
2306 2306
 				$p_ml = 'ms-';
2307 2307
 				$p_mr = 'me-';
@@ -2309,8 +2309,8 @@  discard block
 block discarded – undo
2309 2309
 				$p_pl = 'ps-';
2310 2310
 				$p_pr = 'pe-';
2311 2311
 					<?php
2312
-				}else{
2313
-						?>
2312
+                }else{
2313
+                        ?>
2314 2314
 				$aui_bs5 = false;
2315 2315
 				$p_ml = 'ml-';
2316 2316
 				$p_mr = 'mr-';
@@ -2318,8 +2318,8 @@  discard block
 block discarded – undo
2318 2318
 				$p_pl = 'pl-';
2319 2319
 				$p_pr = 'pr-';
2320 2320
 					<?php
2321
-				}
2322
-				?>
2321
+                }
2322
+                ?>
2323 2323
 
2324 2324
 				// margins
2325 2325
 				if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] );  $mt = $args['mt']; }else{$mt = null;}
@@ -2503,12 +2503,12 @@  discard block
 block discarded – undo
2503 2503
 			<?php
2504 2504
 
2505 2505
 
2506
-			}
2506
+            }
2507 2507
 
2508
-			if(method_exists($this,'block_global_js')){
2509
-					echo $this->block_global_js();
2510
-			}
2511
-			?>
2508
+            if(method_exists($this,'block_global_js')){
2509
+                    echo $this->block_global_js();
2510
+            }
2511
+            ?>
2512 2512
 
2513 2513
 jQuery(function() {
2514 2514
 
@@ -2561,13 +2561,13 @@  discard block
 block discarded – undo
2561 2561
 						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2562 2562
 						supports: {
2563 2563
 							<?php
2564
-							if(!isset($this->options['block-supports']['renaming'])){
2565
-								$this->options['block-supports']['renaming'] = false;
2566
-							}
2567
-							if ( isset( $this->options['block-supports'] ) ) {
2568
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2569
-							}
2570
-							?>
2564
+                            if(!isset($this->options['block-supports']['renaming'])){
2565
+                                $this->options['block-supports']['renaming'] = false;
2566
+                            }
2567
+                            if ( isset( $this->options['block-supports'] ) ) {
2568
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
2569
+                            }
2570
+                            ?>
2571 2571
 						},
2572 2572
 						__experimentalLabel( attributes, { context } ) {
2573 2573
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
@@ -2577,155 +2577,155 @@  discard block
 block discarded – undo
2577 2577
 						},
2578 2578
 						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
2579 2579
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2580
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2581
-						}
2582
-
2583
-
2584
-						// block hover preview.
2585
-						$example_args = array();
2586
-						if(!empty($this->arguments)){
2587
-							foreach($this->arguments as $key => $a_args){
2588
-								if(isset($a_args['example'])){
2589
-									$example_args[$key] = $a_args['example'];
2590
-								}
2591
-							}
2592
-						}
2593
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2594
-						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2595
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2596
-							// no preview if set to false
2597
-						}elseif( !empty( $example_args ) ){
2598
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2599
-						}elseif( !empty( $this->options['example'] ) ){
2600
-							unset($this->options['example']['viewportWidth']);
2601
-							unset($this->options['example']['innerBlocks']);
2602
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2603
-							$example_parts = array();
2604
-							if($example_atts){
2605
-								$example_parts[] = rtrim($example_atts,",");
2606
-							}
2607
-							if($viewport_width){
2608
-								$example_parts[] = $viewport_width;
2609
-							}
2610
-							if($example_inner_blocks){
2611
-								$example_parts[] = $example_inner_blocks;
2612
-							}
2613
-							if(!empty($example_parts)){
2614
-								echo "example : {".implode(',', $example_parts)."},";
2615
-							}
2616
-						}else{
2617
-							echo 'example : {viewportWidth: 500},';
2618
-						}
2619
-
2620
-
2621
-
2622
-						// limit to parent
2623
-						if( !empty( $this->options['parent'] ) ){
2624
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2625
-						}
2626
-
2627
-						// limit allowed blocks
2628
-						if( !empty( $this->options['allowed-blocks'] ) ){
2629
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2630
-						}
2631
-
2632
-						// maybe set no_wrap
2633
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2634
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2635
-							$no_wrap = true;
2636
-						}
2637
-						if ( $no_wrap ) {
2638
-							$this->options['block-wrap'] = '';
2639
-						}
2640
-
2641
-						// Maybe load the drag/drop functions.
2642
-						$img_drag_drop = false;
2643
-						$show_alignment = false;
2580
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
2581
+                        }
2582
+
2583
+
2584
+                        // block hover preview.
2585
+                        $example_args = array();
2586
+                        if(!empty($this->arguments)){
2587
+                            foreach($this->arguments as $key => $a_args){
2588
+                                if(isset($a_args['example'])){
2589
+                                    $example_args[$key] = $a_args['example'];
2590
+                                }
2591
+                            }
2592
+                        }
2593
+                        $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2594
+                        $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2595
+                        if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2596
+                            // no preview if set to false
2597
+                        }elseif( !empty( $example_args ) ){
2598
+                            echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2599
+                        }elseif( !empty( $this->options['example'] ) ){
2600
+                            unset($this->options['example']['viewportWidth']);
2601
+                            unset($this->options['example']['innerBlocks']);
2602
+                            $example_atts = $this->array_to_attributes( $this->options['example'] );
2603
+                            $example_parts = array();
2604
+                            if($example_atts){
2605
+                                $example_parts[] = rtrim($example_atts,",");
2606
+                            }
2607
+                            if($viewport_width){
2608
+                                $example_parts[] = $viewport_width;
2609
+                            }
2610
+                            if($example_inner_blocks){
2611
+                                $example_parts[] = $example_inner_blocks;
2612
+                            }
2613
+                            if(!empty($example_parts)){
2614
+                                echo "example : {".implode(',', $example_parts)."},";
2615
+                            }
2616
+                        }else{
2617
+                            echo 'example : {viewportWidth: 500},';
2618
+                        }
2619
+
2620
+
2621
+
2622
+                        // limit to parent
2623
+                        if( !empty( $this->options['parent'] ) ){
2624
+                            echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2625
+                        }
2626
+
2627
+                        // limit allowed blocks
2628
+                        if( !empty( $this->options['allowed-blocks'] ) ){
2629
+                            echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2630
+                        }
2631
+
2632
+                        // maybe set no_wrap
2633
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2634
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2635
+                            $no_wrap = true;
2636
+                        }
2637
+                        if ( $no_wrap ) {
2638
+                            $this->options['block-wrap'] = '';
2639
+                        }
2640
+
2641
+                        // Maybe load the drag/drop functions.
2642
+                        $img_drag_drop = false;
2643
+                        $show_alignment = false;
2644 2644
 	
2645
-							echo "attributes : {";
2646
-
2647
-							if ( $show_advanced ) {
2648
-								echo "show_advanced: {";
2649
-								echo "  type: 'boolean',";
2650
-								echo "  default: false";
2651
-								echo "},";
2652
-							}
2653
-
2654
-							// Block wrap element
2655
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2656
-								echo "block_wrap: {";
2657
-								echo "  type: 'string',";
2658
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "'";
2659
-								echo "},";
2660
-							}
2661
-
2662
-							if ( ! empty( $this->arguments ) ) {
2663
-								foreach ( $this->arguments as $key => $args ) {
2664
-									if ( $args['type'] == 'image' ||  $args['type'] == 'images' ) {
2665
-										$img_drag_drop = true;
2666
-									}
2667
-
2668
-									// Set if we should show alignment.
2669
-									if ( $key == 'alignment' ) {
2670
-										$show_alignment = true;
2671
-									}
2672
-
2673
-									$extra = '';
2674
-									$_default = isset( $args['default'] ) && ! is_null( $args['default'] ) ? $args['default'] : '';
2675
-
2676
-									if ( ! empty( $_default ) ) {
2677
-										$_default = wp_slash( $_default );
2678
-									}
2679
-
2680
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2681
-										continue;
2682
-									} else if ( $args['type'] == 'checkbox' ) {
2683
-										$type    = 'boolean';
2684
-										$default = $_default ? 'true' : 'false';
2685
-									} else if ( $args['type'] == 'number' ) {
2686
-										$type    = 'number';
2687
-										$default = "'" . $_default . "'";
2688
-									} else if ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2689
-										$type = 'array';
2690
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2691
-											$default = ! empty( $_default ) ? "['" . implode( "','", $_default ) . "']" : "[]";
2692
-										} else {
2693
-											$default = "'" . $_default . "'";
2694
-										}
2695
-									} else if ( $args['type'] == 'tagselect' ) {
2696
-										$type    = 'array';
2697
-										$default = "'" . $_default . "'";
2698
-									} else if ( $args['type'] == 'multiselect' ) {
2699
-										$type    = 'array';
2700
-										$default = "'" . $_default . "'";
2701
-									} else if ( $args['type'] == 'image_xy' ) {
2702
-										$type    = 'object';
2703
-										$default = "'" . $_default . "'";
2704
-									} else if ( $args['type'] == 'image' ) {
2705
-										$type    = 'string';
2706
-										$default = "'" . $_default . "'";
2707
-									} else {
2708
-										$type    = ! empty( $args['hidden_type'] ) ? esc_attr( $args['hidden_type'] ) : 'string';
2709
-										$default = "'" . $_default . "'";
2710
-									}
2711
-
2712
-									echo $key . " : {";
2713
-									echo "type : '$type',";
2714
-									echo "default : $default";
2715
-									echo "},";
2716
-								}
2717
-							}
2718
-
2719
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2720
-							echo "sd_shortcode : {type : 'string',default: ''},";
2721
-
2722
-							if ( ! empty( $this->options['nested-block'] ) || ! empty( $this->arguments['html'] ) ) {
2723
-								echo "sd_shortcode_close : {type : 'string',default: ''},";
2724
-							}
2725
-
2726
-							echo "className: { type: 'string', default: '' }";
2727
-							echo "},";
2728
-						?>
2645
+                            echo "attributes : {";
2646
+
2647
+                            if ( $show_advanced ) {
2648
+                                echo "show_advanced: {";
2649
+                                echo "  type: 'boolean',";
2650
+                                echo "  default: false";
2651
+                                echo "},";
2652
+                            }
2653
+
2654
+                            // Block wrap element
2655
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2656
+                                echo "block_wrap: {";
2657
+                                echo "  type: 'string',";
2658
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "'";
2659
+                                echo "},";
2660
+                            }
2661
+
2662
+                            if ( ! empty( $this->arguments ) ) {
2663
+                                foreach ( $this->arguments as $key => $args ) {
2664
+                                    if ( $args['type'] == 'image' ||  $args['type'] == 'images' ) {
2665
+                                        $img_drag_drop = true;
2666
+                                    }
2667
+
2668
+                                    // Set if we should show alignment.
2669
+                                    if ( $key == 'alignment' ) {
2670
+                                        $show_alignment = true;
2671
+                                    }
2672
+
2673
+                                    $extra = '';
2674
+                                    $_default = isset( $args['default'] ) && ! is_null( $args['default'] ) ? $args['default'] : '';
2675
+
2676
+                                    if ( ! empty( $_default ) ) {
2677
+                                        $_default = wp_slash( $_default );
2678
+                                    }
2679
+
2680
+                                    if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2681
+                                        continue;
2682
+                                    } else if ( $args['type'] == 'checkbox' ) {
2683
+                                        $type    = 'boolean';
2684
+                                        $default = $_default ? 'true' : 'false';
2685
+                                    } else if ( $args['type'] == 'number' ) {
2686
+                                        $type    = 'number';
2687
+                                        $default = "'" . $_default . "'";
2688
+                                    } else if ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2689
+                                        $type = 'array';
2690
+                                        if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2691
+                                            $default = ! empty( $_default ) ? "['" . implode( "','", $_default ) . "']" : "[]";
2692
+                                        } else {
2693
+                                            $default = "'" . $_default . "'";
2694
+                                        }
2695
+                                    } else if ( $args['type'] == 'tagselect' ) {
2696
+                                        $type    = 'array';
2697
+                                        $default = "'" . $_default . "'";
2698
+                                    } else if ( $args['type'] == 'multiselect' ) {
2699
+                                        $type    = 'array';
2700
+                                        $default = "'" . $_default . "'";
2701
+                                    } else if ( $args['type'] == 'image_xy' ) {
2702
+                                        $type    = 'object';
2703
+                                        $default = "'" . $_default . "'";
2704
+                                    } else if ( $args['type'] == 'image' ) {
2705
+                                        $type    = 'string';
2706
+                                        $default = "'" . $_default . "'";
2707
+                                    } else {
2708
+                                        $type    = ! empty( $args['hidden_type'] ) ? esc_attr( $args['hidden_type'] ) : 'string';
2709
+                                        $default = "'" . $_default . "'";
2710
+                                    }
2711
+
2712
+                                    echo $key . " : {";
2713
+                                    echo "type : '$type',";
2714
+                                    echo "default : $default";
2715
+                                    echo "},";
2716
+                                }
2717
+                            }
2718
+
2719
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2720
+                            echo "sd_shortcode : {type : 'string',default: ''},";
2721
+
2722
+                            if ( ! empty( $this->options['nested-block'] ) || ! empty( $this->arguments['html'] ) ) {
2723
+                                echo "sd_shortcode_close : {type : 'string',default: ''},";
2724
+                            }
2725
+
2726
+                            echo "className: { type: 'string', default: '' }";
2727
+                            echo "},";
2728
+                        ?>
2729 2729
 						// The "edit" property must be a valid function.
2730 2730
 						edit: function (props) {
2731 2731
 							const selectedBlock = wp.data.select('core/block-editor').getSelectedBlock();
@@ -2796,10 +2796,10 @@  discard block
 block discarded – undo
2796 2796
 							}
2797 2797
 
2798 2798
 							<?php
2799
-							if(!empty($this->options['block-edit-raw'])) {
2800
-								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2801
-							}else{
2802
-							?>
2799
+                            if(!empty($this->options['block-edit-raw'])) {
2800
+                                echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2801
+                            }else{
2802
+                            ?>
2803 2803
 
2804 2804
 function hasSelectedInnerBlock(props) {
2805 2805
 	const select = wp.data.select('core/editor');
@@ -2821,9 +2821,9 @@  discard block
 block discarded – undo
2821 2821
 
2822 2822
 	var $value = '';
2823 2823
 	<?php
2824
-	// if we have a post_type and a category then link them
2825
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2826
-	?>
2824
+    // if we have a post_type and a category then link them
2825
+    if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2826
+    ?>
2827 2827
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2828 2828
 		$pt = props.attributes.post_type;
2829 2829
 		if(post_type_rest_slugs.length){
@@ -2836,11 +2836,11 @@  discard block
 block discarded – undo
2836 2836
 			term_query_type = $pt;
2837 2837
 		}
2838 2838
 <?php
2839
-	$cat_path = '';
2840
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2841
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2842
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2843
-	}
2839
+    $cat_path = '';
2840
+    if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2841
+        $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2842
+        $cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2843
+    }
2844 2844
 ?>
2845 2845
 		/* taxonomies */
2846 2846
 		if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
 <?php
2933 2933
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2934 2934
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2935
-	echo 'const { deviceType } = "";';
2935
+    echo 'const { deviceType } = "";';
2936 2936
 }else{
2937 2937
 ?>
2938 2938
 /** Get device type const. */
@@ -2986,8 +2986,8 @@  discard block
 block discarded – undo
2986 2986
 										'attributes': props.attributes,
2987 2987
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2988 2988
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2989
-										echo $post->ID;
2990
-									}else{echo '0';}?>,
2989
+                                        echo $post->ID;
2990
+                                    }else{echo '0';}?>,
2991 2991
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2992 2992
 									};
2993 2993
 
@@ -3000,20 +3000,20 @@  discard block
 block discarded – undo
3000 3000
 										}
3001 3001
 
3002 3002
 										 <?php
3003
-										if(!empty($this->options['nested-block'])){
3004
-											?>
3003
+                                        if(!empty($this->options['nested-block'])){
3004
+                                            ?>
3005 3005
 											// props.setAttributes({content: env});
3006 3006
 										is_fetching = false;
3007 3007
 										prev_attributes[props.clientId] = props.attributes;
3008 3008
 											 <?php
3009
-										}else{
3010
-										?>
3009
+                                        }else{
3010
+                                        ?>
3011 3011
 										props.setAttributes({content: env});
3012 3012
 										is_fetching = false;
3013 3013
 										prev_attributes[props.clientId] = props.attributes;
3014 3014
 										<?php
3015
-										}
3016
-										?>
3015
+                                        }
3016
+                                        ?>
3017 3017
 
3018 3018
 										// if AUI is active call the js init function
3019 3019
 										if (typeof aui_init === "function") {
@@ -3026,28 +3026,28 @@  discard block
 block discarded – undo
3026 3026
 							}
3027 3027
 
3028 3028
 							<?php
3029
-							if(!empty($this->options['block-edit-js'])) {
3030
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3031
-							}
3029
+                            if(!empty($this->options['block-edit-js'])) {
3030
+                                echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3031
+                            }
3032 3032
 
3033
-							if(empty($this->options['block-save-return'])){
3034
-							?>
3033
+                            if(empty($this->options['block-save-return'])){
3034
+                            ?>
3035 3035
 								///////////////////////////////////////////////////////////////////////
3036 3036
 
3037 3037
 								// build the shortcode.
3038 3038
 								shortcode = "[<?php echo $this->options['base_id'];?>";
3039 3039
 								<?php
3040 3040
 
3041
-								if(! empty( $this->arguments )){
3041
+                                if(! empty( $this->arguments )){
3042 3042
 
3043
-								foreach($this->arguments as $key => $args){
3044
-								   // if($args['type']=='tabs'){continue;}
3043
+                                foreach($this->arguments as $key => $args){
3044
+                                    // if($args['type']=='tabs'){continue;}
3045 3045
 
3046
-								   // don't add metadata arguments
3047
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3048
-									   continue;
3049
-								   }
3050
-								?>
3046
+                                    // don't add metadata arguments
3047
+                                    if (substr($key, 0, 9 ) === 'metadata_') {
3048
+                                        continue;
3049
+                                    }
3050
+                                ?>
3051 3051
 								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3052 3052
 									if ('<?php echo esc_attr( $key );?>' == 'html') {
3053 3053
 									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
@@ -3058,10 +3058,10 @@  discard block
 block discarded – undo
3058 3058
 									}
3059 3059
 								}
3060 3060
 								<?php
3061
-								}
3062
-								}
3061
+                                }
3062
+                                }
3063 3063
 
3064
-								?>
3064
+                                ?>
3065 3065
 								shortcode += "]";
3066 3066
 
3067 3067
 								if(shortcode){
@@ -3073,17 +3073,17 @@  discard block
 block discarded – undo
3073 3073
 
3074 3074
 
3075 3075
 									<?php
3076
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3077
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3078
-									}
3079
-									?>
3076
+                                    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3077
+                                        echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3078
+                                    }
3079
+                                    ?>
3080 3080
 								}
3081 3081
 
3082 3082
 
3083 3083
 							///////////////////////////////////////////////////////////////////////
3084 3084
 							<?php
3085
-							} // end nested block check
3086
-							?>
3085
+                            } // end nested block check
3086
+                            ?>
3087 3087
 
3088 3088
 							return [
3089 3089
 
@@ -3107,10 +3107,10 @@  discard block
 block discarded – undo
3107 3107
 
3108 3108
 									<?php
3109 3109
 
3110
-									if(! empty( $this->arguments )){
3110
+                                    if(! empty( $this->arguments )){
3111 3111
 
3112
-									if ( $show_advanced ) {
3113
-									?>
3112
+                                    if ( $show_advanced ) {
3113
+                                    ?>
3114 3114
 									el('div', {
3115 3115
 											style: {'padding-left': '16px','padding-right': '16px'}
3116 3116
 										},
@@ -3127,119 +3127,119 @@  discard block
 block discarded – undo
3127 3127
 									)
3128 3128
 									,
3129 3129
 									<?php
3130
-									}
3131
-
3132
-									$arguments = $this->group_arguments( $this->arguments );
3133
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3134
-
3135
-									// Do we have sections?
3136
-									$has_sections = $arguments == $this->arguments ? false : true;
3137
-
3138
-									if($has_sections){
3139
-									$panel_count = 0;
3140
-									$open_tab = '';
3141
-
3142
-									$open_tab_groups = array();
3143
-									$used_tabs = array();
3144
-
3145
-									foreach ( $arguments as $key => $args ) {
3146
-										$close_tab = false;
3147
-										$close_tabs = false;
3148
-
3149
-										 if ( ! empty( $block_group_tabs ) ) {
3150
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3151
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3152
-													$open_tab_groups[] = $key;
3153
-
3154
-													if ( $open_tab != $tab_name ) {
3155
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3156
-														$tab_args['tab']['open'] = true;
3157
-
3158
-														$this->block_tab_start( '', $tab_args );
3159
-														$open_tab = $tab_name;
3160
-														$used_tabs[] = $tab_name;
3161
-													}
3162
-
3163
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3164
-														$close_tab = true;
3165
-														$open_tab_groups = array();
3166
-
3167
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3168
-															$close_tabs = true;
3169
-														}
3170
-													}
3171
-												}
3172
-											}
3173
-										}
3174
-										?>
3130
+                                    }
3131
+
3132
+                                    $arguments = $this->group_arguments( $this->arguments );
3133
+                                    $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3134
+
3135
+                                    // Do we have sections?
3136
+                                    $has_sections = $arguments == $this->arguments ? false : true;
3137
+
3138
+                                    if($has_sections){
3139
+                                    $panel_count = 0;
3140
+                                    $open_tab = '';
3141
+
3142
+                                    $open_tab_groups = array();
3143
+                                    $used_tabs = array();
3144
+
3145
+                                    foreach ( $arguments as $key => $args ) {
3146
+                                        $close_tab = false;
3147
+                                        $close_tabs = false;
3148
+
3149
+                                            if ( ! empty( $block_group_tabs ) ) {
3150
+                                            foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3151
+                                                if ( in_array( $key, $tab_args['groups'] ) ) {
3152
+                                                    $open_tab_groups[] = $key;
3153
+
3154
+                                                    if ( $open_tab != $tab_name ) {
3155
+                                                        $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3156
+                                                        $tab_args['tab']['open'] = true;
3157
+
3158
+                                                        $this->block_tab_start( '', $tab_args );
3159
+                                                        $open_tab = $tab_name;
3160
+                                                        $used_tabs[] = $tab_name;
3161
+                                                    }
3162
+
3163
+                                                    if ( $open_tab_groups == $tab_args['groups'] ) {
3164
+                                                        $close_tab = true;
3165
+                                                        $open_tab_groups = array();
3166
+
3167
+                                                        if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3168
+                                                            $close_tabs = true;
3169
+                                                        }
3170
+                                                    }
3171
+                                                }
3172
+                                            }
3173
+                                        }
3174
+                                        ?>
3175 3175
 										el(wp.components.PanelBody, {
3176 3176
 												title: '<?php esc_attr_e( $key ); ?>',
3177 3177
 												initialOpen: <?php if ( $panel_count ) {
3178
-												echo "false";
3179
-											} else {
3180
-												echo "true";
3181
-											}?>
3178
+                                                echo "false";
3179
+                                            } else {
3180
+                                                echo "true";
3181
+                                            }?>
3182 3182
 											},
3183 3183
 											<?php
3184
-											foreach ( $args as $k => $a ) {
3185
-												$this->block_tab_start( $k, $a );
3186
-												$this->block_row_start( $k, $a );
3187
-												$this->build_block_arguments( $k, $a );
3188
-												$this->block_row_end( $k, $a );
3189
-												$this->block_tab_end( $k, $a );
3190
-											}
3191
-											?>
3184
+                                            foreach ( $args as $k => $a ) {
3185
+                                                $this->block_tab_start( $k, $a );
3186
+                                                $this->block_row_start( $k, $a );
3187
+                                                $this->build_block_arguments( $k, $a );
3188
+                                                $this->block_row_end( $k, $a );
3189
+                                                $this->block_tab_end( $k, $a );
3190
+                                            }
3191
+                                            ?>
3192 3192
 										),
3193 3193
 										<?php
3194
-										$panel_count ++;
3194
+                                        $panel_count ++;
3195 3195
 
3196
-										if($close_tab || $close_tabs){
3197
-											$tab_args = array(
3198
-												'tab'	=> array(
3199
-													'tabs_close' => $close_tabs,
3200
-												'close' => true,
3201
-												)
3196
+                                        if($close_tab || $close_tabs){
3197
+                                            $tab_args = array(
3198
+                                                'tab'	=> array(
3199
+                                                    'tabs_close' => $close_tabs,
3200
+                                                'close' => true,
3201
+                                                )
3202 3202
 
3203
-											);
3204
-											$this->block_tab_end( '', $tab_args );
3203
+                                            );
3204
+                                            $this->block_tab_end( '', $tab_args );
3205 3205
 //											echo '###close'; print_r($tab_args);
3206
-											$panel_count = 0;
3207
-										}
3206
+                                            $panel_count = 0;
3207
+                                        }
3208 3208
 //
3209 3209
 
3210
-									}
3211
-									}else {
3212
-									?>
3210
+                                    }
3211
+                                    }else {
3212
+                                    ?>
3213 3213
 									el(wp.components.PanelBody, {
3214 3214
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3215 3215
 											initialOpen: true
3216 3216
 										},
3217 3217
 										<?php
3218
-										foreach ( $this->arguments as $key => $args ) {
3219
-											$this->block_row_start( $key, $args );
3220
-											$this->build_block_arguments( $key, $args );
3221
-											$this->block_row_end( $key, $args );
3222
-										}
3223
-										?>
3218
+                                        foreach ( $this->arguments as $key => $args ) {
3219
+                                            $this->block_row_start( $key, $args );
3220
+                                            $this->build_block_arguments( $key, $args );
3221
+                                            $this->block_row_end( $key, $args );
3222
+                                        }
3223
+                                        ?>
3224 3224
 									),
3225 3225
 									<?php
3226
-									}
3226
+                                    }
3227 3227
 
3228
-									}
3229
-									?>
3228
+                                    }
3229
+                                    ?>
3230 3230
 
3231 3231
 								),
3232 3232
 
3233 3233
 								<?php
3234
-								// If the user sets block-output array then build it
3235
-								if ( ! empty( $this->options['block-output'] ) ) {
3236
-								$this->block_element( $this->options['block-output'] );
3237
-							}elseif(!empty($this->options['block-edit-return'])){
3238
-								   echo $this->options['block-edit-return'];
3239
-							}else{
3240
-								// if no block-output is set then we try and get the shortcode html output via ajax.
3241
-								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3242
-								?>
3234
+                                // If the user sets block-output array then build it
3235
+                                if ( ! empty( $this->options['block-output'] ) ) {
3236
+                                $this->block_element( $this->options['block-output'] );
3237
+                            }elseif(!empty($this->options['block-edit-return'])){
3238
+                                    echo $this->options['block-edit-return'];
3239
+                            }else{
3240
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
3241
+                                $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3242
+                                ?>
3243 3243
 								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3244 3244
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
3245 3245
 									className: props.className,
@@ -3247,13 +3247,13 @@  discard block
 block discarded – undo
3247 3247
 									style: {'minHeight': '30px'}
3248 3248
 								}))
3249 3249
 								<?php
3250
-								}
3251
-								?>
3250
+                                }
3251
+                                ?>
3252 3252
 							]; // end return
3253 3253
 
3254 3254
 							<?php
3255
-							} // end block-edit-raw else
3256
-							?>
3255
+                            } // end block-edit-raw else
3256
+                            ?>
3257 3257
 						},
3258 3258
 
3259 3259
 						// The "save" property must be specified and must be a valid function.
@@ -3267,16 +3267,16 @@  discard block
 block discarded – undo
3267 3267
 							$html = '';
3268 3268
 							<?php
3269 3269
 
3270
-							if(! empty( $this->arguments )){
3270
+                            if(! empty( $this->arguments )){
3271 3271
 
3272
-							foreach($this->arguments as $key => $args){
3273
-							   // if($args['type']=='tabs'){continue;}
3272
+                            foreach($this->arguments as $key => $args){
3273
+                                // if($args['type']=='tabs'){continue;}
3274 3274
 
3275
-							   // don't add metadata arguments
3276
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3277
-								   continue;
3278
-							   }
3279
-							?>
3275
+                                // don't add metadata arguments
3276
+                                if (substr($key, 0, 9 ) === 'metadata_') {
3277
+                                    continue;
3278
+                                }
3279
+                            ?>
3280 3280
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3281 3281
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
3282 3282
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -3287,10 +3287,10 @@  discard block
 block discarded – undo
3287 3287
 								}
3288 3288
 							}
3289 3289
 							<?php
3290
-							}
3291
-							}
3290
+                            }
3291
+                            }
3292 3292
 
3293
-							?>
3293
+                            ?>
3294 3294
 							content += "]";
3295 3295
 							 content = '';
3296 3296
 
@@ -3300,7 +3300,7 @@  discard block
 block discarded – undo
3300 3300
 //                                $html = 'el( InnerBlocks.Content )';
3301 3301
 //                                <?php
3302 3302
 //                            }
3303
-							?>
3303
+                            ?>
3304 3304
 							// if has html element
3305 3305
 							if ($html) {
3306 3306
 								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
@@ -3333,12 +3333,12 @@  discard block
 block discarded – undo
3333 3333
 //                                <x?php
3334 3334
 //							}else
3335 3335
 
3336
-							if(!empty($this->options['block-output'])){
3336
+                            if(!empty($this->options['block-output'])){
3337 3337
 //                               echo "return";
3338 3338
 //                               $this->block_element( $this->options['block-output'], true );
3339 3339
 //                               echo ";";
3340 3340
 
3341
-							   ?>
3341
+                                ?>
3342 3342
 							  return el(
3343 3343
 								   '',
3344 3344
 								   {},
@@ -3348,10 +3348,10 @@  discard block
 block discarded – undo
3348 3348
 							   );
3349 3349
 								<?php
3350 3350
 
3351
-							}elseif(!empty($this->options['block-save-return'])){
3352
-								   echo 'return ' . $this->options['block-save-return'];
3353
-							}elseif(!empty($this->options['nested-block'])){
3354
-								?>
3351
+                            }elseif(!empty($this->options['block-save-return'])){
3352
+                                    echo 'return ' . $this->options['block-save-return'];
3353
+                            }elseif(!empty($this->options['nested-block'])){
3354
+                                ?>
3355 3355
 							  return el(
3356 3356
 								   '',
3357 3357
 								   {},
@@ -3360,22 +3360,22 @@  discard block
 block discarded – undo
3360 3360
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3361 3361
 							   );
3362 3362
 								<?php
3363
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3364
-								echo "return ". $this->options['block-edit-return'].";";
3365
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3366
-							?>
3363
+                            }elseif(!empty( $this->options['block-save-return'] ) ){
3364
+                                echo "return ". $this->options['block-edit-return'].";";
3365
+                            }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3366
+                            ?>
3367 3367
 							return content;
3368 3368
 							<?php
3369
-							}else{
3370
-							?>
3369
+                            }else{
3370
+                            ?>
3371 3371
 							var block_wrap = 'div';
3372 3372
 							if (attr.hasOwnProperty("block_wrap")) {
3373 3373
 								block_wrap = attr.block_wrap;
3374 3374
 							}
3375 3375
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
3376 3376
 							<?php
3377
-							}
3378
-							?>
3377
+                            }
3378
+                            ?>
3379 3379
 
3380 3380
 
3381 3381
 						}
@@ -3389,43 +3389,43 @@  discard block
 block discarded – undo
3389 3389
 				});
3390 3390
 			</script>
3391 3391
 			<?php
3392
-			$output = ob_get_clean();
3392
+            $output = ob_get_clean();
3393 3393
 
3394
-			/*
3394
+            /*
3395 3395
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3396 3396
 			 */
3397 3397
 
3398
-			return str_replace( array(
3399
-				'<script>',
3400
-				'</script>'
3401
-			), '', $output );
3402
-		}
3398
+            return str_replace( array(
3399
+                '<script>',
3400
+                '</script>'
3401
+            ), '', $output );
3402
+        }
3403 3403
 
3404 3404
 
3405 3405
 
3406
-		public function block_row_start($key, $args){
3406
+        public function block_row_start($key, $args){
3407 3407
 
3408
-			// check for row
3409
-			if(!empty($args['row'])){
3408
+            // check for row
3409
+            if(!empty($args['row'])){
3410 3410
 
3411
-				if(!empty($args['row']['open'])){
3411
+                if(!empty($args['row']['open'])){
3412 3412
 
3413
-				// element require
3414
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3415
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3416
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3417
-				$device_type_icon = '';
3418
-				if($device_type=='Desktop'){
3419
-					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3420
-				}elseif($device_type=='Tablet'){
3421
-					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3422
-				}elseif($device_type=='Mobile'){
3423
-					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3424
-				}
3425
-				echo $element_require;
3426
-				echo $device_type_require;
3413
+                // element require
3414
+                $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3415
+                $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3416
+                $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3417
+                $device_type_icon = '';
3418
+                if($device_type=='Desktop'){
3419
+                    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3420
+                }elseif($device_type=='Tablet'){
3421
+                    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3422
+                }elseif($device_type=='Mobile'){
3423
+                    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3424
+                }
3425
+                echo $element_require;
3426
+                echo $device_type_require;
3427 3427
 
3428
-					if(false){?><script><?php }?>
3428
+                    if(false){?><script><?php }?>
3429 3429
 						el('div', {
3430 3430
 								className: 'bsui components-base-control',
3431 3431
 							},
@@ -3438,8 +3438,8 @@  discard block
 block discarded – undo
3438 3438
 								<?php if($device_type_icon){ ?>
3439 3439
 									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3440 3440
 								<?php
3441
-								}
3442
-								?>
3441
+                                }
3442
+                                ?>
3443 3443
 
3444 3444
 
3445 3445
 							),
@@ -3463,51 +3463,51 @@  discard block
 block discarded – undo
3463 3463
 									},
3464 3464
 
3465 3465
 					<?php
3466
-					if(false){?></script><?php }
3467
-				}elseif(!empty($args['row']['close'])){
3468
-					if(false){?><script><?php }?>
3466
+                    if(false){?></script><?php }
3467
+                }elseif(!empty($args['row']['close'])){
3468
+                    if(false){?><script><?php }?>
3469 3469
 						el(
3470 3470
 							'div',
3471 3471
 							{
3472 3472
 								className: 'col pl-0 ps-0',
3473 3473
 							},
3474 3474
 					<?php
3475
-					if(false){?></script><?php }
3476
-				}else{
3477
-					if(false){?><script><?php }?>
3475
+                    if(false){?></script><?php }
3476
+                }else{
3477
+                    if(false){?><script><?php }?>
3478 3478
 						el(
3479 3479
 							'div',
3480 3480
 							{
3481 3481
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3482 3482
 							},
3483 3483
 					<?php
3484
-					if(false){?></script><?php }
3485
-				}
3484
+                    if(false){?></script><?php }
3485
+                }
3486 3486
 
3487
-			}
3487
+            }
3488 3488
 
3489
-		}
3489
+        }
3490 3490
 
3491
-		public function block_row_end($key, $args){
3491
+        public function block_row_end($key, $args){
3492 3492
 
3493
-			if(!empty($args['row'])){
3494
-				// maybe close
3495
-				if(!empty($args['row']['close'])){
3496
-					echo "))";
3497
-				}
3493
+            if(!empty($args['row'])){
3494
+                // maybe close
3495
+                if(!empty($args['row']['close'])){
3496
+                    echo "))";
3497
+                }
3498 3498
 
3499
-				echo "),";
3500
-			}
3501
-		}
3499
+                echo "),";
3500
+            }
3501
+        }
3502 3502
 
3503
-		public function block_tab_start($key, $args){
3503
+        public function block_tab_start($key, $args){
3504 3504
 
3505
-			// check for row
3506
-			if(!empty($args['tab'])){
3505
+            // check for row
3506
+            if(!empty($args['tab'])){
3507 3507
 
3508
-				if(!empty($args['tab']['tabs_open'])){
3508
+                if(!empty($args['tab']['tabs_open'])){
3509 3509
 
3510
-					if(false){?><script><?php }?>
3510
+                    if(false){?><script><?php }?>
3511 3511
 
3512 3512
 el('div',{className: 'bsui'},
3513 3513
 
@@ -3520,12 +3520,12 @@  discard block
 block discarded – undo
3520 3520
 										tabs: [
3521 3521
 
3522 3522
 					<?php
3523
-					if(false){?></script><?php }
3524
-				}
3523
+                    if(false){?></script><?php }
3524
+                }
3525 3525
 
3526
-				if(!empty($args['tab']['open'])){
3526
+                if(!empty($args['tab']['open'])){
3527 3527
 
3528
-					if(false){?><script><?php }?>
3528
+                    if(false){?><script><?php }?>
3529 3529
 							{
3530 3530
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3531 3531
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3534,93 +3534,93 @@  discard block
 block discarded – undo
3534 3534
 									className: 'components-base-control__help mb-0',
3535 3535
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3536 3536
 								}),<?php }
3537
-					if(false){?></script><?php }
3538
-				}
3537
+                    if(false){?></script><?php }
3538
+                }
3539 3539
 
3540
-			}
3540
+            }
3541 3541
 
3542
-		}
3542
+        }
3543 3543
 
3544
-		public function block_tab_end($key, $args){
3544
+        public function block_tab_end($key, $args){
3545 3545
 
3546
-			if(!empty($args['tab'])){
3547
-				// maybe close
3548
-				if(!empty($args['tab']['close'])){
3549
-					echo ")}, /* tab close */";
3550
-				}
3546
+            if(!empty($args['tab'])){
3547
+                // maybe close
3548
+                if(!empty($args['tab']['close'])){
3549
+                    echo ")}, /* tab close */";
3550
+                }
3551 3551
 
3552
-				if(!empty($args['tab']['tabs_close'])){
3553
-					if(false){?><script><?php }?>
3552
+                if(!empty($args['tab']['tabs_close'])){
3553
+                    if(false){?><script><?php }?>
3554 3554
 						]}, ( tab ) => {
3555 3555
 								return tab.content;
3556 3556
 							}
3557 3557
 						)), /* tabs close */
3558 3558
 					<?php if(false){ ?></script><?php }
3559
-				}
3560
-			}
3561
-		}
3559
+                }
3560
+            }
3561
+        }
3562 3562
 
3563
-		public function build_block_arguments( $key, $args ) {
3564
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3565
-			$options           = '';
3566
-			$extra             = '';
3567
-			$require           = '';
3568
-			$inside_elements   = '';
3569
-			$after_elements	   = '';
3570
-
3571
-			// `content` is a protected and special argument
3572
-			if ( $key == 'content' ) {
3573
-				return;
3574
-			}
3563
+        public function build_block_arguments( $key, $args ) {
3564
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3565
+            $options           = '';
3566
+            $extra             = '';
3567
+            $require           = '';
3568
+            $inside_elements   = '';
3569
+            $after_elements	   = '';
3570
+
3571
+            // `content` is a protected and special argument
3572
+            if ( $key == 'content' ) {
3573
+                return;
3574
+            }
3575 3575
 
3576
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3577
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3578
-			$device_type_icon = '';
3579
-			if($device_type=='Desktop'){
3580
-				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3581
-			}elseif($device_type=='Tablet'){
3582
-				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3583
-			}elseif($device_type=='Mobile'){
3584
-				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3585
-			}
3576
+            $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3577
+            $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3578
+            $device_type_icon = '';
3579
+            if($device_type=='Desktop'){
3580
+                $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3581
+            }elseif($device_type=='Tablet'){
3582
+                $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3583
+            }elseif($device_type=='Mobile'){
3584
+                $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3585
+            }
3586 3586
 
3587
-			// icon
3588
-			$icon = '';
3589
-			if( !empty( $args['icon'] ) ){
3590
-				$icon .= "el('div', {";
3591
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3592
-									$icon .= "className: 'text-center',";
3593
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3594
-								$icon .= "}),";
3595
-
3596
-				// blank title as its added to the icon.
3597
-				$args['title'] = '';
3598
-			}
3587
+            // icon
3588
+            $icon = '';
3589
+            if( !empty( $args['icon'] ) ){
3590
+                $icon .= "el('div', {";
3591
+                                    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3592
+                                    $icon .= "className: 'text-center',";
3593
+                                    $icon .= "title: '".addslashes( $args['title'] )."',";
3594
+                                $icon .= "}),";
3595
+
3596
+                // blank title as its added to the icon.
3597
+                $args['title'] = '';
3598
+            }
3599 3599
 
3600
-			// require advanced
3601
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3600
+            // require advanced
3601
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3602 3602
 
3603
-			// element require
3604
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3603
+            // element require
3604
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3605 3605
 
3606 3606
 
3607
-			$onchange  = "props.setAttributes({ $key: $key } )";
3608
-			$onchangecomplete  = "";
3609
-			$value     = "props.attributes.$key";
3610
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3611
-			if ( in_array( $args['type'], $text_type ) ) {
3612
-				$type = 'TextControl';
3613
-				// Save numbers as numbers and not strings
3614
-				if ( $args['type'] == 'number' ) {
3615
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3616
-				}
3607
+            $onchange  = "props.setAttributes({ $key: $key } )";
3608
+            $onchangecomplete  = "";
3609
+            $value     = "props.attributes.$key";
3610
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3611
+            if ( in_array( $args['type'], $text_type ) ) {
3612
+                $type = 'TextControl';
3613
+                // Save numbers as numbers and not strings
3614
+                if ( $args['type'] == 'number' ) {
3615
+                    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3616
+                }
3617 3617
 
3618
-				if (substr($key, 0, 9 ) === 'metadata_') {
3619
-					$real_key = str_replace('metadata_','', $key );
3620
-					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3621
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3622
-				}
3623
-			}
3618
+                if (substr($key, 0, 9 ) === 'metadata_') {
3619
+                    $real_key = str_replace('metadata_','', $key );
3620
+                    $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3621
+                    $value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3622
+                }
3623
+            }
3624 3624
 //			else if ( $args['type'] == 'popup' ) {
3625 3625
 //				$type = 'TextControl';
3626 3626
 //				$args['type'] == 'text';
@@ -3638,21 +3638,21 @@  discard block
 block discarded – undo
3638 3638
 //
3639 3639
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3640 3640
 //			}
3641
-			else if ( $args['type'] == 'styleid' ) {
3642
-				$type = 'TextControl';
3643
-				$args['type'] == 'text';
3644
-				// Save numbers as numbers and not strings
3645
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3646
-			}else if ( $args['type'] == 'notice' ) {
3647
-
3648
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3649
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3650
-
3651
-				$notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3652
-				echo $notice_message ? $element_require . $notice : '';
3653
-				return;
3654
-			}
3655
-			/*
3641
+            else if ( $args['type'] == 'styleid' ) {
3642
+                $type = 'TextControl';
3643
+                $args['type'] == 'text';
3644
+                // Save numbers as numbers and not strings
3645
+                $value     = "props.attributes.$key ? props.attributes.$key : ''";
3646
+            }else if ( $args['type'] == 'notice' ) {
3647
+
3648
+                $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3649
+                $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3650
+
3651
+                $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3652
+                echo $notice_message ? $element_require . $notice : '';
3653
+                return;
3654
+            }
3655
+            /*
3656 3656
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3657 3657
 						elseif($args['type']=='tabs'){
3658 3658
 							?>
@@ -3705,22 +3705,22 @@  discard block
 block discarded – undo
3705 3705
 							return;
3706 3706
 						}
3707 3707
 */
3708
-			elseif ( $args['type'] == 'color' ) {
3709
-				$type = 'ColorPicker';
3710
-				$onchange = "";
3711
-				$extra = "color: $value,";
3712
-				if(!empty($args['disable_alpha'])){
3713
-					$extra .= "disableAlpha: true,";
3714
-				}
3715
-				$onchangecomplete = "onChangeComplete: function($key) {
3708
+            elseif ( $args['type'] == 'color' ) {
3709
+                $type = 'ColorPicker';
3710
+                $onchange = "";
3711
+                $extra = "color: $value,";
3712
+                if(!empty($args['disable_alpha'])){
3713
+                    $extra .= "disableAlpha: true,";
3714
+                }
3715
+                $onchangecomplete = "onChangeComplete: function($key) {
3716 3716
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3717 3717
 						props.setAttributes({
3718 3718
 							$key: value
3719 3719
 						});
3720 3720
 					},";
3721
-			}elseif ( $args['type'] == 'gradient' ) {
3722
-				$type = 'GradientPicker';
3723
-				$extra .= "gradients: [{
3721
+            }elseif ( $args['type'] == 'gradient' ) {
3722
+                $type = 'GradientPicker';
3723
+                $extra .= "gradients: [{
3724 3724
 			name: 'Vivid cyan blue to vivid purple',
3725 3725
 			gradient:
3726 3726
 				'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
@@ -3757,10 +3757,10 @@  discard block
 block discarded – undo
3757 3757
 			slug: 'cool-to-warm-spectrum',
3758 3758
 		}],";
3759 3759
 
3760
-			}elseif ( $args['type'] == 'image' ) {
3760
+            }elseif ( $args['type'] == 'image' ) {
3761 3761
 //                print_r($args);
3762 3762
 
3763
-				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3763
+                $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3764 3764
 							url:  props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4='  : props.attributes.$key,
3765 3765
 							value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3766 3766
 //                            value: props.attributes.{$key}_xy,
@@ -3781,16 +3781,16 @@  discard block
 block discarded – undo
3781 3781
 						}), ";
3782 3782
 
3783 3783
 
3784
-				$value = '""';
3785
-				$type = 'MediaUpload';
3786
-				$extra .= "onSelect: function(media){
3784
+                $value = '""';
3785
+                $type = 'MediaUpload';
3786
+                $extra .= "onSelect: function(media){
3787 3787
 					  return props.setAttributes({
3788 3788
 						  $key: media.url,
3789 3789
 						  {$key}_id: media.id
3790 3790
 						});
3791 3791
 					  },";
3792
-				   $extra .= "type: 'image',";
3793
-				   $extra .= "render: function (obj) {
3792
+                    $extra .= "type: 'image',";
3793
+                    $extra .= "render: function (obj) {
3794 3794
 						return el( 'div',{},
3795 3795
 						( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3796 3796
 						  className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3816,11 +3816,11 @@  discard block
 block discarded – undo
3816 3816
 
3817 3817
 
3818 3818
 					  }";
3819
-				$onchange = "";
3819
+                $onchange = "";
3820 3820
 
3821
-				//$inside_elements = ",el('div',{},'file upload')";
3822
-			} else if ( $args['type'] == 'images' ) {
3823
-				$img_preview = "props.attributes.$key && (function() {
3821
+                //$inside_elements = ",el('div',{},'file upload')";
3822
+            } else if ( $args['type'] == 'images' ) {
3823
+                $img_preview = "props.attributes.$key && (function() {
3824 3824
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3825 3825
 	let images = [];
3826 3826
 	uploads.map((upload, index) => (
@@ -3847,9 +3847,9 @@  discard block
 block discarded – undo
3847 3847
 })(),";
3848 3848
 
3849 3849
 
3850
-				$value = '""';
3851
-				$type = 'MediaUpload';
3852
-				$extra .= "onSelect: function(media){
3850
+                $value = '""';
3851
+                $type = 'MediaUpload';
3852
+                $extra .= "onSelect: function(media){
3853 3853
 	let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
3854 3854
 	if(media.length){
3855 3855
 		for (var i=0; i < media.length; i++) {
@@ -3862,9 +3862,9 @@  discard block
 block discarded – undo
3862 3862
 	}
3863 3863
 	return props.setAttributes({ $key: slimImagesV});
3864 3864
 },";
3865
-				$extra .= "type: 'image',";
3866
-				$extra .= "multiple: true,";
3867
-				$extra .= "render: function (obj) {
3865
+                $extra .= "type: 'image',";
3866
+                $extra .= "multiple: true,";
3867
+                $extra .= "render: function (obj) {
3868 3868
 	/* Init the sort */
3869 3869
 	enableDragSort('sd-sortable');
3870 3870
 	return el( 'div',{},
@@ -3891,40 +3891,40 @@  discard block
 block discarded – undo
3891 3891
 		)
3892 3892
 	)
3893 3893
 }";
3894
-				$onchange = "";
3894
+                $onchange = "";
3895 3895
 
3896
-				//$inside_elements = ",el('div',{},'file upload')";
3897
-			}
3898
-			elseif ( $args['type'] == 'checkbox' ) {
3899
-				$type = 'CheckboxControl';
3900
-				$extra .= "checked: props.attributes.$key,";
3901
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3902
-			} elseif ( $args['type'] == 'textarea' ) {
3903
-				$type = 'TextareaControl';
3904
-
3905
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3906
-				$type = 'SelectControl';
3907
-
3908
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3909
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3910
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3911
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3912
-				}else {
3913
-
3914
-					if ( ! empty( $args['options'] ) ) {
3915
-						$options .= "options: [";
3916
-						foreach ( $args['options'] as $option_val => $option_label ) {
3917
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3918
-						}
3919
-						$options .= "],";
3920
-					}
3921
-				}
3922
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3923
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3924
-				}
3896
+                //$inside_elements = ",el('div',{},'file upload')";
3897
+            }
3898
+            elseif ( $args['type'] == 'checkbox' ) {
3899
+                $type = 'CheckboxControl';
3900
+                $extra .= "checked: props.attributes.$key,";
3901
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3902
+            } elseif ( $args['type'] == 'textarea' ) {
3903
+                $type = 'TextareaControl';
3904
+
3905
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3906
+                $type = 'SelectControl';
3907
+
3908
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3909
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3910
+                }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3911
+                    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3912
+                }else {
3913
+
3914
+                    if ( ! empty( $args['options'] ) ) {
3915
+                        $options .= "options: [";
3916
+                        foreach ( $args['options'] as $option_val => $option_label ) {
3917
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3918
+                        }
3919
+                        $options .= "],";
3920
+                    }
3921
+                }
3922
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3923
+                    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3924
+                }
3925 3925
 
3926
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3927
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3926
+                if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3927
+                    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3928 3928
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3929 3929
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3930 3930
 									  onClick: function(){
@@ -3935,8 +3935,8 @@  discard block
 block discarded – undo
3935 3935
 									},
3936 3936
 									'Clear'
3937 3937
 							),";
3938
-				}
3939
-			} elseif ( $args['type'] == 'tagselect' ) {
3938
+                }
3939
+            } elseif ( $args['type'] == 'tagselect' ) {
3940 3940
 //				$type = 'FormTokenField';
3941 3941
 //
3942 3942
 //				if ( ! empty( $args['options'] ) ) {
@@ -3971,20 +3971,20 @@  discard block
 block discarded – undo
3971 3971
 //				$value     = "[]";
3972 3972
 //				$extra .= ' __experimentalExpandOnFocus: true,';
3973 3973
 
3974
-			} else if ( $args['type'] == 'alignment' ) {
3975
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3976
-			} else if ( $args['type'] == 'margins' ) {
3977
-
3978
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
3979
-				$type = 'TextControl';
3980
-				$value = "(props.attributes.$key ? props.attributes.$key : '')";
3981
-				$args['type'] = 'text';
3982
-				$options .= 'disabled:true,';
3983
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
3984
-				$bsvc_body = $this->block_visibility_fields( $args );
3985
-				// @TODO reset button
3986
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
3987
-				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3974
+            } else if ( $args['type'] == 'alignment' ) {
3975
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3976
+            } else if ( $args['type'] == 'margins' ) {
3977
+
3978
+            } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
3979
+                $type = 'TextControl';
3980
+                $value = "(props.attributes.$key ? props.attributes.$key : '')";
3981
+                $args['type'] = 'text';
3982
+                $options .= 'disabled:true,';
3983
+                $bsvc_title = esc_attr( addslashes( $args['title'] ) );
3984
+                $bsvc_body = $this->block_visibility_fields( $args );
3985
+                // @TODO reset button
3986
+                $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
3987
+                $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3988 3988
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
3989 3989
 						onClick: function() {
3990 3990
 							var sValue = props.attributes." . $key . ";
@@ -4010,39 +4010,39 @@  discard block
 block discarded – undo
4010 4010
 					},
4011 4011
 					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4012 4012
 				) ),";
4013
-			} else {
4014
-				return;// if we have not implemented the control then don't break the JS.
4015
-			}
4013
+            } else {
4014
+                return;// if we have not implemented the control then don't break the JS.
4015
+            }
4016 4016
 
4017
-			// color input does not show the labels so we add them
4018
-			if($args['type']=='color'){
4019
-				// add show only if advanced
4020
-				echo $require_advanced;
4021
-				// add setting require if defined
4022
-				echo $element_require;
4023
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4024
-			}
4017
+            // color input does not show the labels so we add them
4018
+            if($args['type']=='color'){
4019
+                // add show only if advanced
4020
+                echo $require_advanced;
4021
+                // add setting require if defined
4022
+                echo $element_require;
4023
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4024
+            }
4025 4025
 
4026
-			// add show only if advanced
4027
-			echo $require_advanced;
4028
-			// add setting require if defined
4029
-			echo $element_require;
4030
-			echo $device_type_require;
4026
+            // add show only if advanced
4027
+            echo $require_advanced;
4028
+            // add setting require if defined
4029
+            echo $element_require;
4030
+            echo $device_type_require;
4031 4031
 
4032
-			// icon
4033
-			echo $icon;
4034
-			?>
4032
+            // icon
4033
+            echo $icon;
4034
+            ?>
4035 4035
 			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4036 4036
 			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4037
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4037
+            } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4038 4038
 			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4039 4039
 			value: <?php echo $value; ?>,
4040 4040
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4041
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4042
-			} ?>
4041
+                echo "type: '" . addslashes( $args['type'] ) . "',";
4042
+            } ?>
4043 4043
 			<?php if ( ! empty( $args['placeholder'] ) ) {
4044
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4045
-			} ?>
4044
+                echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4045
+            } ?>
4046 4046
 			<?php echo $options; ?>
4047 4047
 			<?php echo $extra; ?>
4048 4048
 			<?php echo $custom_attributes; ?>
@@ -4054,1366 +4054,1366 @@  discard block
 block discarded – undo
4054 4054
 			<?php } ?>
4055 4055
 		} <?php echo $inside_elements; ?> ),
4056 4056
 			<?php
4057
-			echo $after_elements;
4058
-		}
4057
+            echo $after_elements;
4058
+        }
4059 4059
 
4060
-		/**
4061
-		 * Convert an array of attributes to block string.
4062
-		 *
4063
-		 * @param $custom_attributes
4064
-		 *
4065
-		 * @return string
4066
-		 *@todo there is prob a faster way to do this, also we could add some validation here.
4067
-		 *
4068
-		 */
4069
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4070
-			$attributes = '';
4071
-			if ( ! empty( $custom_attributes ) ) {
4072
-
4073
-				foreach ( $custom_attributes as $key => $val ) {
4074
-					if(is_array($val)){
4075
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4076
-					}else{
4077
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4078
-					}
4079
-				}
4060
+        /**
4061
+         * Convert an array of attributes to block string.
4062
+         *
4063
+         * @param $custom_attributes
4064
+         *
4065
+         * @return string
4066
+         *@todo there is prob a faster way to do this, also we could add some validation here.
4067
+         *
4068
+         */
4069
+        public function array_to_attributes( $custom_attributes, $html = false ) {
4070
+            $attributes = '';
4071
+            if ( ! empty( $custom_attributes ) ) {
4072
+
4073
+                foreach ( $custom_attributes as $key => $val ) {
4074
+                    if(is_array($val)){
4075
+                        $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4076
+                    }else{
4077
+                        $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4078
+                    }
4079
+                }
4080 4080
 
4081
-			}
4081
+            }
4082 4082
 
4083
-			return $attributes;
4084
-		}
4083
+            return $attributes;
4084
+        }
4085 4085
 
4086 4086
 
4087 4087
 
4088
-		/**
4089
-		 * A self looping function to create the output for JS block elements.
4090
-		 *
4091
-		 * This is what is output in the WP Editor visual view.
4092
-		 *
4093
-		 * @param $args
4094
-		 */
4095
-		public function block_element( $args, $save = false ) {
4088
+        /**
4089
+         * A self looping function to create the output for JS block elements.
4090
+         *
4091
+         * This is what is output in the WP Editor visual view.
4092
+         *
4093
+         * @param $args
4094
+         */
4095
+        public function block_element( $args, $save = false ) {
4096 4096
 
4097 4097
 //            print_r($args);echo '###';exit;
4098 4098
 
4099
-			if ( ! empty( $args ) ) {
4100
-				foreach ( $args as $element => $new_args ) {
4099
+            if ( ! empty( $args ) ) {
4100
+                foreach ( $args as $element => $new_args ) {
4101 4101
 
4102
-					if ( is_array( $new_args ) ) { // its an element
4102
+                    if ( is_array( $new_args ) ) { // its an element
4103 4103
 
4104 4104
 
4105
-						if ( isset( $new_args['element'] ) ) {
4105
+                        if ( isset( $new_args['element'] ) ) {
4106 4106
 
4107
-							if ( isset( $new_args['element_require'] ) ) {
4108
-								echo str_replace( array(
4109
-										"'+",
4110
-										"+'"
4111
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4112
-								unset( $new_args['element_require'] );
4113
-							}
4107
+                            if ( isset( $new_args['element_require'] ) ) {
4108
+                                echo str_replace( array(
4109
+                                        "'+",
4110
+                                        "+'"
4111
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4112
+                                unset( $new_args['element_require'] );
4113
+                            }
4114 4114
 
4115
-							if($new_args['element']=='InnerBlocks'){
4116
-								echo "\n el( InnerBlocks, {";
4117
-							}elseif($new_args['element']=='innerBlocksProps'){
4118
-								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4119
-							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4115
+                            if($new_args['element']=='InnerBlocks'){
4116
+                                echo "\n el( InnerBlocks, {";
4117
+                            }elseif($new_args['element']=='innerBlocksProps'){
4118
+                                $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4119
+                                //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4120 4120
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4121
-								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4122
-								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4123
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4124
-
4125
-								echo "} ), {";
4126
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4127
-							//    echo '###';
4121
+                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4122
+                                echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4123
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4124
+
4125
+                                echo "} ), {";
4126
+                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4127
+                            //    echo '###';
4128
+
4129
+                                //  echo '###';
4130
+                            }elseif($new_args['element']=='BlocksProps'){
4131
+
4132
+                                if ( isset($new_args['if_inner_element']) ) {
4133
+                                    $element = $new_args['if_inner_element'];
4134
+                                }else {
4135
+                                    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4136
+                                }
4137
+
4138
+                                unset($new_args['inner_element']);
4139
+                                echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4140
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4141
+
4142
+
4143
+                                // echo "} ),";
4144
+
4145
+                            }else{
4146
+                                echo "\n el( '" . $new_args['element'] . "', {";
4147
+                            }
4148
+
4149
+
4150
+                            // get the attributes
4151
+                            foreach ( $new_args as $new_key => $new_value ) {
4152
+
4153
+
4154
+                                if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4155
+                                    // do nothing
4156
+                                } else {
4157
+                                    echo $this->block_element( array( $new_key => $new_value ),$save );
4158
+                                }
4159
+                            }
4160
+
4161
+                            echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4162
+
4163
+                            // get the content
4164
+                            $first_item = 0;
4165
+                            foreach ( $new_args as $new_key => $new_value ) {
4166
+                                if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4167
+
4168
+                                    if ( $new_key === 'content' ) {
4169
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4170
+                                    }else if ( $new_key === 'if_content' ) {
4171
+                                        echo  $this->block_props_replace(  $new_value  );
4172
+                                    }
4173
+
4174
+                                    if ( is_array( $new_value ) ) {
4175
+
4176
+                                        if ( isset( $new_value['element_require'] ) ) {
4177
+                                            echo str_replace( array(
4178
+                                                    "'+",
4179
+                                                    "+'"
4180
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4181
+                                            unset( $new_value['element_require'] );
4182
+                                        }
4183
+
4184
+                                        if ( isset( $new_value['element_repeat'] ) ) {
4185
+                                            $x = 1;
4186
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
4187
+                                                $this->block_element( array( '' => $new_value ),$save );
4188
+                                                $x ++;
4189
+                                            }
4190
+                                        } else {
4191
+                                            $this->block_element( array( '' => $new_value ),$save );
4192
+                                        }
4193
+                                    }
4194
+                                    $first_item ++;
4195
+                                }
4196
+                            }
4197
+
4198
+                            if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4199
+                                echo "))";// end content
4200
+                            }else{
4201
+                                echo ")";// end content
4202
+                            }
4203
+
4204
+
4205
+                            echo ", \n";
4206
+
4207
+                        }
4208
+                    } else {
4209
+
4210
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
4211
+                            $extra = '';
4212
+                            if( strpos($new_args, '[%WrapClass%]') !== false ){
4213
+                                $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4214
+                                $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4215
+                            }
4216
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4217
+                        } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4218
+                            $new_args = str_replace('[%WrapStyle%]','',$new_args);
4219
+                            echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4220
+//                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4221
+                        } elseif ( $element == 'style' ) {
4222
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4223
+                        } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4224
+                            $new_args = str_replace('[%WrapClass%]','',$new_args);
4225
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4226
+                        } elseif ( $element == 'template' && $new_args ) {
4227
+                            echo $element . ": $new_args,";
4228
+                        } else {
4229
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4230
+                        }
4231
+
4232
+                    }
4233
+                }
4234
+            }
4235
+        }
4128 4236
 
4129
-							  //  echo '###';
4130
-							}elseif($new_args['element']=='BlocksProps'){
4131
-
4132
-								if ( isset($new_args['if_inner_element']) ) {
4133
-									$element = $new_args['if_inner_element'];
4134
-								}else {
4135
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4136
-								}
4137
-
4138
-								unset($new_args['inner_element']);
4139
-								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4140
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4141
-
4142
-
4143
-							   // echo "} ),";
4144
-
4145
-							}else{
4146
-								echo "\n el( '" . $new_args['element'] . "', {";
4147
-							}
4148
-
4149
-
4150
-							// get the attributes
4151
-							foreach ( $new_args as $new_key => $new_value ) {
4152
-
4153
-
4154
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4155
-									// do nothing
4156
-								} else {
4157
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4158
-								}
4159
-							}
4160
-
4161
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4162
-
4163
-							// get the content
4164
-							$first_item = 0;
4165
-							foreach ( $new_args as $new_key => $new_value ) {
4166
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4167
-
4168
-									if ( $new_key === 'content' ) {
4169
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4170
-									}else if ( $new_key === 'if_content' ) {
4171
-										echo  $this->block_props_replace(  $new_value  );
4172
-									}
4173
-
4174
-									if ( is_array( $new_value ) ) {
4175
-
4176
-										if ( isset( $new_value['element_require'] ) ) {
4177
-											echo str_replace( array(
4178
-													"'+",
4179
-													"+'"
4180
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4181
-											unset( $new_value['element_require'] );
4182
-										}
4183
-
4184
-										if ( isset( $new_value['element_repeat'] ) ) {
4185
-											$x = 1;
4186
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4187
-												$this->block_element( array( '' => $new_value ),$save );
4188
-												$x ++;
4189
-											}
4190
-										} else {
4191
-											$this->block_element( array( '' => $new_value ),$save );
4192
-										}
4193
-									}
4194
-									$first_item ++;
4195
-								}
4196
-							}
4197
-
4198
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4199
-								echo "))";// end content
4200
-							}else{
4201
-								echo ")";// end content
4202
-							}
4203
-
4204
-
4205
-							echo ", \n";
4206
-
4207
-						}
4208
-					} else {
4209
-
4210
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4211
-							$extra = '';
4212
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4213
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4214
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4215
-							}
4216
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4217
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4218
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4219
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4220
-//                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4221
-						} elseif ( $element == 'style' ) {
4222
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4223
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4224
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4225
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4226
-						} elseif ( $element == 'template' && $new_args ) {
4227
-							echo $element . ": $new_args,";
4228
-						} else {
4229
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4230
-						}
4231
-
4232
-					}
4233
-				}
4234
-			}
4235
-		}
4236
-
4237
-		/**
4238
-		 * Replace block attributes placeholders with the proper naming.
4239
-		 *
4240
-		 * @param $string
4241
-		 *
4242
-		 * @return mixed
4243
-		 */
4244
-		public function block_props_replace( $string, $no_wrap = false ) {
4245
-			if ( $no_wrap ) {
4246
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4247
-			} else {
4248
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4249
-			}
4237
+        /**
4238
+         * Replace block attributes placeholders with the proper naming.
4239
+         *
4240
+         * @param $string
4241
+         *
4242
+         * @return mixed
4243
+         */
4244
+        public function block_props_replace( $string, $no_wrap = false ) {
4245
+            if ( $no_wrap ) {
4246
+                $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4247
+            } else {
4248
+                $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4249
+            }
4250 4250
 
4251
-			return $string;
4252
-		}
4251
+            return $string;
4252
+        }
4253 4253
 
4254
-		/**
4255
-		 * Outputs the content of the widget
4256
-		 *
4257
-		 * @param array $args
4258
-		 * @param array $instance
4259
-		 */
4260
-		public function widget( $args, $instance ) {
4261
-			if ( ! is_array( $args ) ) {
4262
-				$args = array();
4263
-			}
4254
+        /**
4255
+         * Outputs the content of the widget
4256
+         *
4257
+         * @param array $args
4258
+         * @param array $instance
4259
+         */
4260
+        public function widget( $args, $instance ) {
4261
+            if ( ! is_array( $args ) ) {
4262
+                $args = array();
4263
+            }
4264 4264
 
4265
-			// Get the filtered values
4266
-			$argument_values = $this->argument_values( $instance );
4267
-			$argument_values = $this->string_to_bool( $argument_values );
4268
-			$output          = $this->output( $argument_values, $args );
4265
+            // Get the filtered values
4266
+            $argument_values = $this->argument_values( $instance );
4267
+            $argument_values = $this->string_to_bool( $argument_values );
4268
+            $output          = $this->output( $argument_values, $args );
4269 4269
 
4270
-			$no_wrap = false;
4271
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4272
-				$no_wrap = true;
4273
-			}
4270
+            $no_wrap = false;
4271
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4272
+                $no_wrap = true;
4273
+            }
4274 4274
 
4275
-			ob_start();
4276
-			if ( $output && ! $no_wrap ) {
4275
+            ob_start();
4276
+            if ( $output && ! $no_wrap ) {
4277 4277
 
4278
-				$class_original = $this->options['widget_ops']['classname'];
4279
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4278
+                $class_original = $this->options['widget_ops']['classname'];
4279
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4280 4280
 
4281
-				// Before widget
4282
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4283
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4284
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4285
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4281
+                // Before widget
4282
+                $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4283
+                $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4284
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4285
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4286 4286
 
4287
-				// After widget
4288
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4289
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4290
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4287
+                // After widget
4288
+                $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4289
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4290
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4291 4291
 
4292
-				echo $before_widget;
4293
-				// elementor strips the widget wrapping div so we check for and add it back if needed
4294
-				if ( $this->is_elementor_widget_output() ) {
4295
-					// Filter class & attrs for elementor widget output.
4296
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4297
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4292
+                echo $before_widget;
4293
+                // elementor strips the widget wrapping div so we check for and add it back if needed
4294
+                if ( $this->is_elementor_widget_output() ) {
4295
+                    // Filter class & attrs for elementor widget output.
4296
+                    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4297
+                    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4298 4298
 
4299
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4300
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4299
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4300
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4301 4301
 
4302
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4303
-				}
4304
-				echo $this->output_title( $args, $instance );
4305
-				echo $output;
4306
-				if ( $this->is_elementor_widget_output() ) {
4307
-					echo "</span>";
4308
-				}
4309
-				echo $after_widget;
4310
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4311
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4312
-				echo $output;
4313
-			} elseif ( $output && $no_wrap ) {
4314
-				echo $output;
4315
-			}
4316
-			$output = ob_get_clean();
4302
+                    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4303
+                }
4304
+                echo $this->output_title( $args, $instance );
4305
+                echo $output;
4306
+                if ( $this->is_elementor_widget_output() ) {
4307
+                    echo "</span>";
4308
+                }
4309
+                echo $after_widget;
4310
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4311
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4312
+                echo $output;
4313
+            } elseif ( $output && $no_wrap ) {
4314
+                echo $output;
4315
+            }
4316
+            $output = ob_get_clean();
4317 4317
 
4318
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4318
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4319 4319
 
4320
-			echo $output;
4321
-		}
4320
+            echo $output;
4321
+        }
4322 4322
 
4323
-		/**
4324
-		 * Tests if the current output is inside a elementor container.
4325
-		 *
4326
-		 * @return bool
4327
-		 *@since 1.0.4
4328
-		 */
4329
-		public function is_elementor_widget_output() {
4330
-			$result = false;
4331
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4332
-				$result = true;
4333
-			}
4323
+        /**
4324
+         * Tests if the current output is inside a elementor container.
4325
+         *
4326
+         * @return bool
4327
+         *@since 1.0.4
4328
+         */
4329
+        public function is_elementor_widget_output() {
4330
+            $result = false;
4331
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4332
+                $result = true;
4333
+            }
4334 4334
 
4335
-			return $result;
4336
-		}
4335
+            return $result;
4336
+        }
4337 4337
 
4338
-		/**
4339
-		 * Tests if the current output is inside a elementor preview.
4340
-		 *
4341
-		 * @return bool
4342
-		 *@since 1.0.4
4343
-		 */
4344
-		public function is_elementor_preview() {
4345
-			$result = false;
4346
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4347
-				$result = true;
4348
-			}
4338
+        /**
4339
+         * Tests if the current output is inside a elementor preview.
4340
+         *
4341
+         * @return bool
4342
+         *@since 1.0.4
4343
+         */
4344
+        public function is_elementor_preview() {
4345
+            $result = false;
4346
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4347
+                $result = true;
4348
+            }
4349 4349
 
4350
-			return $result;
4351
-		}
4350
+            return $result;
4351
+        }
4352 4352
 
4353
-		/**
4354
-		 * Tests if the current output is inside a Divi preview.
4355
-		 *
4356
-		 * @return bool
4357
-		 *@since 1.0.6
4358
-		 */
4359
-		public function is_divi_preview() {
4360
-			$result = false;
4361
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4362
-				$result = true;
4363
-			}
4353
+        /**
4354
+         * Tests if the current output is inside a Divi preview.
4355
+         *
4356
+         * @return bool
4357
+         *@since 1.0.6
4358
+         */
4359
+        public function is_divi_preview() {
4360
+            $result = false;
4361
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4362
+                $result = true;
4363
+            }
4364 4364
 
4365
-			return $result;
4366
-		}
4365
+            return $result;
4366
+        }
4367 4367
 
4368
-		/**
4369
-		 * Tests if the current output is inside a Beaver builder preview.
4370
-		 *
4371
-		 * @return bool
4372
-		 *@since 1.0.6
4373
-		 */
4374
-		public function is_beaver_preview() {
4375
-			$result = false;
4376
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4377
-				$result = true;
4378
-			}
4368
+        /**
4369
+         * Tests if the current output is inside a Beaver builder preview.
4370
+         *
4371
+         * @return bool
4372
+         *@since 1.0.6
4373
+         */
4374
+        public function is_beaver_preview() {
4375
+            $result = false;
4376
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
4377
+                $result = true;
4378
+            }
4379 4379
 
4380
-			return $result;
4381
-		}
4380
+            return $result;
4381
+        }
4382 4382
 
4383
-		/**
4384
-		 * Tests if the current output is inside a siteorigin builder preview.
4385
-		 *
4386
-		 * @return bool
4387
-		 *@since 1.0.6
4388
-		 */
4389
-		public function is_siteorigin_preview() {
4390
-			$result = false;
4391
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4392
-				$result = true;
4393
-			}
4383
+        /**
4384
+         * Tests if the current output is inside a siteorigin builder preview.
4385
+         *
4386
+         * @return bool
4387
+         *@since 1.0.6
4388
+         */
4389
+        public function is_siteorigin_preview() {
4390
+            $result = false;
4391
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4392
+                $result = true;
4393
+            }
4394 4394
 
4395
-			return $result;
4396
-		}
4395
+            return $result;
4396
+        }
4397 4397
 
4398
-		/**
4399
-		 * Tests if the current output is inside a cornerstone builder preview.
4400
-		 *
4401
-		 * @return bool
4402
-		 *@since 1.0.8
4403
-		 */
4404
-		public function is_cornerstone_preview() {
4405
-			$result = false;
4406
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4407
-				$result = true;
4408
-			}
4398
+        /**
4399
+         * Tests if the current output is inside a cornerstone builder preview.
4400
+         *
4401
+         * @return bool
4402
+         *@since 1.0.8
4403
+         */
4404
+        public function is_cornerstone_preview() {
4405
+            $result = false;
4406
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4407
+                $result = true;
4408
+            }
4409 4409
 
4410
-			return $result;
4411
-		}
4410
+            return $result;
4411
+        }
4412 4412
 
4413
-		/**
4414
-		 * Tests if the current output is inside a fusion builder preview.
4415
-		 *
4416
-		 * @return bool
4417
-		 *@since 1.1.0
4418
-		 */
4419
-		public function is_fusion_preview() {
4420
-			$result = false;
4421
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4422
-				$result = true;
4423
-			}
4413
+        /**
4414
+         * Tests if the current output is inside a fusion builder preview.
4415
+         *
4416
+         * @return bool
4417
+         *@since 1.1.0
4418
+         */
4419
+        public function is_fusion_preview() {
4420
+            $result = false;
4421
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4422
+                $result = true;
4423
+            }
4424 4424
 
4425
-			return $result;
4426
-		}
4425
+            return $result;
4426
+        }
4427 4427
 
4428
-		/**
4429
-		 * Tests if the current output is inside a Oxygen builder preview.
4430
-		 *
4431
-		 * @return bool
4432
-		 *@since 1.0.18
4433
-		 */
4434
-		public function is_oxygen_preview() {
4435
-			$result = false;
4436
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4437
-				$result = true;
4438
-			}
4428
+        /**
4429
+         * Tests if the current output is inside a Oxygen builder preview.
4430
+         *
4431
+         * @return bool
4432
+         *@since 1.0.18
4433
+         */
4434
+        public function is_oxygen_preview() {
4435
+            $result = false;
4436
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4437
+                $result = true;
4438
+            }
4439 4439
 
4440
-			return $result;
4441
-		}
4440
+            return $result;
4441
+        }
4442 4442
 
4443
-		/**
4444
-		 * Check for Kallyas theme Zion builder preview.
4445
-		 *
4446
-		 * @since 1.1.22
4447
-		 *
4448
-		 * @return bool True when preview page otherwise false.
4449
-		 */
4450
-		public function is_kallyas_zion_preview() {
4451
-			$result = false;
4452
-
4453
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4454
-				$result = true;
4455
-			}
4443
+        /**
4444
+         * Check for Kallyas theme Zion builder preview.
4445
+         *
4446
+         * @since 1.1.22
4447
+         *
4448
+         * @return bool True when preview page otherwise false.
4449
+         */
4450
+        public function is_kallyas_zion_preview() {
4451
+            $result = false;
4456 4452
 
4457
-			return $result;
4458
-		}
4453
+            if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4454
+                $result = true;
4455
+            }
4459 4456
 
4460
-		/**
4461
-		 * Check for Bricks theme builder preview.
4462
-		 *
4463
-		 * @since 1.1.31
4464
-		 *
4465
-		 * @return bool True when preview page otherwise false.
4466
-		 */
4467
-		public function is_bricks_preview() {
4468
-			$result = false;
4469
-
4470
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4471
-				$result = true;
4472
-			}
4457
+            return $result;
4458
+        }
4473 4459
 
4474
-			return $result;
4475
-		}
4460
+        /**
4461
+         * Check for Bricks theme builder preview.
4462
+         *
4463
+         * @since 1.1.31
4464
+         *
4465
+         * @return bool True when preview page otherwise false.
4466
+         */
4467
+        public function is_bricks_preview() {
4468
+            $result = false;
4476 4469
 
4477
-		/**
4478
-		 * General function to check if we are in a preview situation.
4479
-		 *
4480
-		 * @return bool
4481
-		 *@since 1.0.6
4482
-		 */
4483
-		public function is_preview() {
4484
-			$preview = false;
4485
-			if ( $this->is_divi_preview() ) {
4486
-				$preview = true;
4487
-			} elseif ( $this->is_elementor_preview() ) {
4488
-				$preview = true;
4489
-			} elseif ( $this->is_beaver_preview() ) {
4490
-				$preview = true;
4491
-			} elseif ( $this->is_siteorigin_preview() ) {
4492
-				$preview = true;
4493
-			} elseif ( $this->is_cornerstone_preview() ) {
4494
-				$preview = true;
4495
-			} elseif ( $this->is_fusion_preview() ) {
4496
-				$preview = true;
4497
-			} elseif ( $this->is_oxygen_preview() ) {
4498
-				$preview = true;
4499
-			} elseif( $this->is_kallyas_zion_preview() ) {
4500
-				$preview = true;
4501
-			} elseif( $this->is_block_content_call() ) {
4502
-				$preview = true;
4503
-			} elseif( $this->is_bricks_preview() ) {
4504
-				$preview = true;
4505
-			}
4470
+            if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4471
+                $result = true;
4472
+            }
4506 4473
 
4507
-			return $preview;
4508
-		}
4474
+            return $result;
4475
+        }
4509 4476
 
4510
-		/**
4511
-		 * Output the super title.
4512
-		 *
4513
-		 * @param $args
4514
-		 * @param array $instance
4515
-		 *
4516
-		 * @return string
4517
-		 */
4518
-		public function output_title( $args, $instance = array() ) {
4519
-			$output = '';
4520
-			if ( ! empty( $instance['title'] ) ) {
4521
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4522
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4523
-
4524
-				if ( empty( $instance['widget_title_tag'] ) ) {
4525
-					if ( ! isset( $args['before_title'] ) ) {
4526
-						$args['before_title'] = '';
4527
-					}
4477
+        /**
4478
+         * General function to check if we are in a preview situation.
4479
+         *
4480
+         * @return bool
4481
+         *@since 1.0.6
4482
+         */
4483
+        public function is_preview() {
4484
+            $preview = false;
4485
+            if ( $this->is_divi_preview() ) {
4486
+                $preview = true;
4487
+            } elseif ( $this->is_elementor_preview() ) {
4488
+                $preview = true;
4489
+            } elseif ( $this->is_beaver_preview() ) {
4490
+                $preview = true;
4491
+            } elseif ( $this->is_siteorigin_preview() ) {
4492
+                $preview = true;
4493
+            } elseif ( $this->is_cornerstone_preview() ) {
4494
+                $preview = true;
4495
+            } elseif ( $this->is_fusion_preview() ) {
4496
+                $preview = true;
4497
+            } elseif ( $this->is_oxygen_preview() ) {
4498
+                $preview = true;
4499
+            } elseif( $this->is_kallyas_zion_preview() ) {
4500
+                $preview = true;
4501
+            } elseif( $this->is_block_content_call() ) {
4502
+                $preview = true;
4503
+            } elseif( $this->is_bricks_preview() ) {
4504
+                $preview = true;
4505
+            }
4528 4506
 
4529
-					if ( ! isset( $args['after_title'] ) ) {
4530
-						$args['after_title'] = '';
4531
-					}
4507
+            return $preview;
4508
+        }
4532 4509
 
4533
-					$output = $args['before_title'] . $title . $args['after_title'];
4534
-				} else {
4535
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4536
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4537
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4538
-
4539
-					// classes
4540
-					$title_classes = array();
4541
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4542
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4543
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4544
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4545
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4546
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4547
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4548
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4549
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4550
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4551
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4552
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4553
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4554
-
4555
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4556
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
4557
-				}
4510
+        /**
4511
+         * Output the super title.
4512
+         *
4513
+         * @param $args
4514
+         * @param array $instance
4515
+         *
4516
+         * @return string
4517
+         */
4518
+        public function output_title( $args, $instance = array() ) {
4519
+            $output = '';
4520
+            if ( ! empty( $instance['title'] ) ) {
4521
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4522
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4523
+
4524
+                if ( empty( $instance['widget_title_tag'] ) ) {
4525
+                    if ( ! isset( $args['before_title'] ) ) {
4526
+                        $args['before_title'] = '';
4527
+                    }
4528
+
4529
+                    if ( ! isset( $args['after_title'] ) ) {
4530
+                        $args['after_title'] = '';
4531
+                    }
4532
+
4533
+                    $output = $args['before_title'] . $title . $args['after_title'];
4534
+                } else {
4535
+                    $tag 			= esc_attr( $instance['widget_title_tag'] );
4536
+                    $allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4537
+                    $title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4538
+
4539
+                    // classes
4540
+                    $title_classes = array();
4541
+                    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4542
+                    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4543
+                    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4544
+                    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4545
+                    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4546
+                    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4547
+                    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4548
+                    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4549
+                    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4550
+                    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4551
+                    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4552
+                    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4553
+                    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4554
+
4555
+                    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4556
+                    $output = "<$title_tag class='$class' >$title</$title_tag>";
4557
+                }
4558 4558
 
4559
-			}
4559
+            }
4560 4560
 
4561
-			return $output;
4562
-		}
4561
+            return $output;
4562
+        }
4563 4563
 
4564
-		/**
4565
-		 * Outputs the options form inputs for the widget.
4566
-		 *
4567
-		 * @param array $instance The widget options.
4568
-		 */
4569
-		public function form( $instance ) {
4564
+        /**
4565
+         * Outputs the options form inputs for the widget.
4566
+         *
4567
+         * @param array $instance The widget options.
4568
+         */
4569
+        public function form( $instance ) {
4570 4570
 
4571
-			// set widget instance
4572
-			$this->instance = $instance;
4571
+            // set widget instance
4572
+            $this->instance = $instance;
4573 4573
 
4574
-			// set it as a SD widget
4575
-			echo $this->widget_advanced_toggle();
4574
+            // set it as a SD widget
4575
+            echo $this->widget_advanced_toggle();
4576 4576
 
4577
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4578
-			$arguments_raw = $this->get_arguments();
4577
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4578
+            $arguments_raw = $this->get_arguments();
4579 4579
 
4580
-			if ( is_array( $arguments_raw ) ) {
4580
+            if ( is_array( $arguments_raw ) ) {
4581 4581
 
4582
-				$arguments = $this->group_arguments( $arguments_raw );
4582
+                $arguments = $this->group_arguments( $arguments_raw );
4583 4583
 
4584
-				// Do we have sections?
4585
-				$has_sections = $arguments == $arguments_raw ? false : true;
4584
+                // Do we have sections?
4585
+                $has_sections = $arguments == $arguments_raw ? false : true;
4586 4586
 
4587 4587
 
4588
-				if ( $has_sections ) {
4589
-					$panel_count = 0;
4590
-					foreach ( $arguments as $key => $args ) {
4588
+                if ( $has_sections ) {
4589
+                    $panel_count = 0;
4590
+                    foreach ( $arguments as $key => $args ) {
4591 4591
 
4592
-						?>
4592
+                        ?>
4593 4593
 						<script>
4594 4594
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
4595 4595
 						</script>
4596 4596
 						<?php
4597 4597
 
4598
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
4599
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4600
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4601
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4598
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
4599
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4600
+                        echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4601
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4602 4602
 
4603
-						foreach ( $args as $k => $a ) {
4603
+                        foreach ( $args as $k => $a ) {
4604 4604
 
4605
-							$this->widget_inputs_row_start($k, $a);
4606
-							$this->widget_inputs( $a, $instance );
4607
-							$this->widget_inputs_row_end($k, $a);
4605
+                            $this->widget_inputs_row_start($k, $a);
4606
+                            $this->widget_inputs( $a, $instance );
4607
+                            $this->widget_inputs_row_end($k, $a);
4608 4608
 
4609
-						}
4609
+                        }
4610 4610
 
4611
-						echo "</div>";
4611
+                        echo "</div>";
4612 4612
 
4613
-						$panel_count ++;
4613
+                        $panel_count ++;
4614 4614
 
4615
-					}
4616
-				} else {
4617
-					foreach ( $arguments as $key => $args ) {
4618
-						$this->widget_inputs_row_start($key, $args);
4619
-						$this->widget_inputs( $args, $instance );
4620
-						$this->widget_inputs_row_end($key, $args);
4621
-					}
4622
-				}
4615
+                    }
4616
+                } else {
4617
+                    foreach ( $arguments as $key => $args ) {
4618
+                        $this->widget_inputs_row_start($key, $args);
4619
+                        $this->widget_inputs( $args, $instance );
4620
+                        $this->widget_inputs_row_end($key, $args);
4621
+                    }
4622
+                }
4623 4623
 
4624
-			}
4625
-		}
4624
+            }
4625
+        }
4626 4626
 
4627
-		public function widget_inputs_row_start( $key, $args ) {
4628
-			if ( ! empty( $args['row'] ) ) {
4629
-				// Maybe open
4630
-				if ( ! empty( $args['row']['open'] ) ) {
4631
-					?>
4627
+        public function widget_inputs_row_start( $key, $args ) {
4628
+            if ( ! empty( $args['row'] ) ) {
4629
+                // Maybe open
4630
+                if ( ! empty( $args['row']['open'] ) ) {
4631
+                    ?>
4632 4632
 					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4633 4633
 					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4634 4634
 					<?php
4635
-						if ( isset( $args['row']['icon'] ) ) {
4636
-							$args['row']['icon'] = '';
4637
-						}
4638
-
4639
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4640
-							$args['row']['device_type'] = $args['device_type'];
4641
-						}
4642
-					?>
4635
+                        if ( isset( $args['row']['icon'] ) ) {
4636
+                            $args['row']['icon'] = '';
4637
+                        }
4638
+
4639
+                        if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4640
+                            $args['row']['device_type'] = $args['device_type'];
4641
+                        }
4642
+                    ?>
4643 4643
 					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4644 4644
 					<?php } ?>
4645 4645
 					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4646 4646
 					<div class='col pr-2'>
4647 4647
 					<?php
4648
-				} else if ( ! empty( $args['row']['close'] ) ) {
4649
-					echo "<div class='col pl-0 ps-0'>";
4650
-				} else {
4651
-					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4652
-				}
4653
-			}
4654
-		}
4648
+                } else if ( ! empty( $args['row']['close'] ) ) {
4649
+                    echo "<div class='col pl-0 ps-0'>";
4650
+                } else {
4651
+                    echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4652
+                }
4653
+            }
4654
+        }
4655 4655
 
4656
-		public function widget_inputs_row_end( $key, $args ) {
4657
-			if ( ! empty( $args['row'] ) ) {
4658
-				// Maybe close
4659
-				if ( ! empty( $args['row']['close'] ) ) {
4660
-					echo "</div></div>";
4661
-				}
4662
-				echo "</div>";
4663
-			}
4664
-		}
4656
+        public function widget_inputs_row_end( $key, $args ) {
4657
+            if ( ! empty( $args['row'] ) ) {
4658
+                // Maybe close
4659
+                if ( ! empty( $args['row']['close'] ) ) {
4660
+                    echo "</div></div>";
4661
+                }
4662
+                echo "</div>";
4663
+            }
4664
+        }
4665 4665
 
4666
-		/**
4667
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
4668
-		 *
4669
-		 * @return string
4670
-		 */
4671
-		public function widget_advanced_toggle() {
4666
+        /**
4667
+         * Get the hidden input that when added makes the advanced button show on widget settings.
4668
+         *
4669
+         * @return string
4670
+         */
4671
+        public function widget_advanced_toggle() {
4672 4672
 
4673
-			$output = '';
4674
-			if ( $this->block_show_advanced() ) {
4675
-				$val = 1;
4676
-			} else {
4677
-				$val = 0;
4678
-			}
4673
+            $output = '';
4674
+            if ( $this->block_show_advanced() ) {
4675
+                $val = 1;
4676
+            } else {
4677
+                $val = 0;
4678
+            }
4679 4679
 
4680
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4680
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4681 4681
 
4682
-			return $output;
4683
-		}
4682
+            return $output;
4683
+        }
4684 4684
 
4685
-		/**
4686
-		 * Convert require element.
4687
-		 *
4688
-		 * @param string $input Input element.
4689
-		 *
4690
-		 * @return string $output
4691
-		 *@since 1.0.0
4692
-		 *
4693
-		 */
4694
-		public function convert_element_require( $input ) {
4695
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4696
-
4697
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4698
-				"jQuery(form).find('[data-argument=\"",
4699
-				"\"]').find('input,select,textarea').val()",
4700
-				"\"]').find('input:checked').val()"
4701
-			), $input ) );
4702
-
4703
-			return $output;
4704
-		}
4685
+        /**
4686
+         * Convert require element.
4687
+         *
4688
+         * @param string $input Input element.
4689
+         *
4690
+         * @return string $output
4691
+         *@since 1.0.0
4692
+         *
4693
+         */
4694
+        public function convert_element_require( $input ) {
4695
+            $input = str_replace( "'", '"', $input );// we only want double quotes
4705 4696
 
4706
-		/**
4707
-		 * Builds the inputs for the widget options.
4708
-		 *
4709
-		 * @param $args
4710
-		 * @param $instance
4711
-		 */
4712
-		public function widget_inputs( $args, $instance ) {
4713
-
4714
-			$class             = "";
4715
-			$element_require   = "";
4716
-			$custom_attributes = "";
4717
-
4718
-			// get value
4719
-			if ( isset( $instance[ $args['name'] ] ) ) {
4720
-				$value = $instance[ $args['name'] ];
4721
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4722
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4723
-			} else {
4724
-				$value = '';
4725
-			}
4697
+            $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4698
+                "jQuery(form).find('[data-argument=\"",
4699
+                "\"]').find('input,select,textarea').val()",
4700
+                "\"]').find('input:checked').val()"
4701
+            ), $input ) );
4726 4702
 
4727
-			// get placeholder
4728
-			if ( ! empty( $args['placeholder'] ) ) {
4729
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4730
-			} else {
4731
-				$placeholder = '';
4732
-			}
4703
+            return $output;
4704
+        }
4733 4705
 
4734
-			// get if advanced
4735
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4736
-				$class .= " sd-advanced-setting ";
4737
-			}
4706
+        /**
4707
+         * Builds the inputs for the widget options.
4708
+         *
4709
+         * @param $args
4710
+         * @param $instance
4711
+         */
4712
+        public function widget_inputs( $args, $instance ) {
4713
+
4714
+            $class             = "";
4715
+            $element_require   = "";
4716
+            $custom_attributes = "";
4717
+
4718
+            // get value
4719
+            if ( isset( $instance[ $args['name'] ] ) ) {
4720
+                $value = $instance[ $args['name'] ];
4721
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4722
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4723
+            } else {
4724
+                $value = '';
4725
+            }
4738 4726
 
4739
-			// element_require
4740
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4741
-				$element_require = $args['element_require'];
4742
-			}
4727
+            // get placeholder
4728
+            if ( ! empty( $args['placeholder'] ) ) {
4729
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4730
+            } else {
4731
+                $placeholder = '';
4732
+            }
4743 4733
 
4744
-			// custom_attributes
4745
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4746
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4747
-			}
4734
+            // get if advanced
4735
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4736
+                $class .= " sd-advanced-setting ";
4737
+            }
4738
+
4739
+            // element_require
4740
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4741
+                $element_require = $args['element_require'];
4742
+            }
4743
+
4744
+            // custom_attributes
4745
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4746
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4747
+            }
4748 4748
 
4749
-			// before wrapper
4750
-			?>
4749
+            // before wrapper
4750
+            ?>
4751 4751
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4752 4752
 			<?php
4753
-			switch ( $args['type'] ) {
4754
-				//array('text','password','number','email','tel','url','color')
4755
-				case "text":
4756
-				case "password":
4757
-				case "number":
4758
-				case "email":
4759
-				case "tel":
4760
-				case "url":
4761
-				case "color":
4762
-					?>
4753
+            switch ( $args['type'] ) {
4754
+                //array('text','password','number','email','tel','url','color')
4755
+                case "text":
4756
+                case "password":
4757
+                case "number":
4758
+                case "email":
4759
+                case "tel":
4760
+                case "url":
4761
+                case "color":
4762
+                    ?>
4763 4763
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4764 4764
 					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>">
4765 4765
 					<?php
4766 4766
 
4767
-					break;
4768
-				case "select":
4769
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4770
-					if ( $multiple ) {
4771
-						if ( empty( $value ) ) {
4772
-							$value = array();
4773
-						}
4774
-					}
4775
-					?>
4767
+                    break;
4768
+                case "select":
4769
+                    $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4770
+                    if ( $multiple ) {
4771
+                        if ( empty( $value ) ) {
4772
+                            $value = array();
4773
+                        }
4774
+                    }
4775
+                    ?>
4776 4776
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4777 4777
 					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>"
4778 4778
 						<?php if ( $multiple ) {
4779
-							echo "multiple";
4780
-						} //@todo not implemented yet due to gutenberg not supporting it
4781
-						?>>
4779
+                            echo "multiple";
4780
+                        } //@todo not implemented yet due to gutenberg not supporting it
4781
+                        ?>>
4782 4782
 						<?php
4783 4783
 
4784
-						if ( ! empty( $args['options'] ) ) {
4785
-							foreach ( $args['options'] as $val => $label ) {
4786
-								if ( $multiple ) {
4787
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4788
-								} else {
4789
-									$selected = selected( $value, $val, false );
4790
-								}
4791
-								echo "<option value='$val' " . $selected . ">$label</option>";
4792
-							}
4793
-						}
4794
-						?>
4784
+                        if ( ! empty( $args['options'] ) ) {
4785
+                            foreach ( $args['options'] as $val => $label ) {
4786
+                                if ( $multiple ) {
4787
+                                    $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4788
+                                } else {
4789
+                                    $selected = selected( $value, $val, false );
4790
+                                }
4791
+                                echo "<option value='$val' " . $selected . ">$label</option>";
4792
+                            }
4793
+                        }
4794
+                        ?>
4795 4795
 					</select>
4796 4796
 					<?php
4797
-					break;
4798
-				case "checkbox":
4799
-					?>
4797
+                    break;
4798
+                case "checkbox":
4799
+                    ?>
4800 4800
 					<input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1">
4801 4801
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4802 4802
 					<?php
4803
-					break;
4804
-				case "textarea":
4805
-					?>
4803
+                    break;
4804
+                case "textarea":
4805
+                    ?>
4806 4806
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4807 4807
 					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea>
4808 4808
 					<?php
4809 4809
 
4810
-					break;
4811
-				case "hidden":
4812
-					?>
4810
+                    break;
4811
+                case "hidden":
4812
+                    ?>
4813 4813
 					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>">
4814 4814
 					<?php
4815
-					break;
4816
-				default:
4817
-					echo "No input type found!"; // @todo we need to add more input types.
4818
-			}
4819
-			// after wrapper
4820
-			?></p><?php
4821
-		}
4815
+                    break;
4816
+                default:
4817
+                    echo "No input type found!"; // @todo we need to add more input types.
4818
+            }
4819
+            // after wrapper
4820
+            ?></p><?php
4821
+        }
4822 4822
 
4823
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4824
-			if($icon=='box-top'){
4825
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4826
-			}elseif($icon=='box-right'){
4827
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4828
-			}elseif($icon=='box-bottom'){
4829
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4830
-			}elseif($icon=='box-left'){
4831
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4832
-			}
4833
-		}
4823
+        public function get_widget_icon($icon = 'box-top', $title = ''){
4824
+            if($icon=='box-top'){
4825
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4826
+            }elseif($icon=='box-right'){
4827
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4828
+            }elseif($icon=='box-bottom'){
4829
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4830
+            }elseif($icon=='box-left'){
4831
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4832
+            }
4833
+        }
4834 4834
 
4835
-		/**
4836
-		 * Get the widget input description html.
4837
-		 *
4838
-		 * @param $args
4839
-		 *
4840
-		 * @return string
4841
-		 * @todo, need to make its own tooltip script
4842
-		 */
4843
-		public function widget_field_desc( $args ) {
4844
-
4845
-			$description = '';
4846
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4847
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4848
-					$description = $this->desc_tip( $args['desc'] );
4849
-				} else {
4850
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4851
-				}
4852
-			}
4835
+        /**
4836
+         * Get the widget input description html.
4837
+         *
4838
+         * @param $args
4839
+         *
4840
+         * @return string
4841
+         * @todo, need to make its own tooltip script
4842
+         */
4843
+        public function widget_field_desc( $args ) {
4844
+
4845
+            $description = '';
4846
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
4847
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4848
+                    $description = $this->desc_tip( $args['desc'] );
4849
+                } else {
4850
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4851
+                }
4852
+            }
4853 4853
 
4854
-			return $description;
4855
-		}
4854
+            return $description;
4855
+        }
4856 4856
 
4857
-		/**
4858
-		 * Get the widget input title html.
4859
-		 *
4860
-		 * @param $args
4861
-		 *
4862
-		 * @return string
4863
-		 */
4864
-		public function widget_field_title( $args ) {
4865
-			$title = '';
4866
-
4867
-			if ( isset( $args['title'] ) && $args['title'] ) {
4868
-				if ( ! empty( $args['device_type'] ) ) {
4869
-					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4870
-				}
4857
+        /**
4858
+         * Get the widget input title html.
4859
+         *
4860
+         * @param $args
4861
+         *
4862
+         * @return string
4863
+         */
4864
+        public function widget_field_title( $args ) {
4865
+            $title = '';
4871 4866
 
4872
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4873
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4874
-				} else {
4875
-					$title = esc_attr( $args['title'] );
4876
-				}
4877
-			}
4867
+            if ( isset( $args['title'] ) && $args['title'] ) {
4868
+                if ( ! empty( $args['device_type'] ) ) {
4869
+                    $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4870
+                }
4878 4871
 
4879
-			return $title;
4880
-		}
4872
+                if ( isset( $args['icon'] ) && $args['icon'] ) {
4873
+                    $title = self::get_widget_icon( $args['icon'], $args['title']  );
4874
+                } else {
4875
+                    $title = esc_attr( $args['title'] );
4876
+                }
4877
+            }
4881 4878
 
4882
-		/**
4883
-		 * Get the tool tip html.
4884
-		 *
4885
-		 * @param $tip
4886
-		 * @param bool $allow_html
4887
-		 *
4888
-		 * @return string
4889
-		 */
4890
-		function desc_tip( $tip, $allow_html = false ) {
4891
-			if ( $allow_html ) {
4892
-				$tip = $this->sanitize_tooltip( $tip );
4893
-			} else {
4894
-				$tip = esc_attr( $tip );
4895
-			}
4879
+            return $title;
4880
+        }
4896 4881
 
4897
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4898
-		}
4882
+        /**
4883
+         * Get the tool tip html.
4884
+         *
4885
+         * @param $tip
4886
+         * @param bool $allow_html
4887
+         *
4888
+         * @return string
4889
+         */
4890
+        function desc_tip( $tip, $allow_html = false ) {
4891
+            if ( $allow_html ) {
4892
+                $tip = $this->sanitize_tooltip( $tip );
4893
+            } else {
4894
+                $tip = esc_attr( $tip );
4895
+            }
4899 4896
 
4900
-		/**
4901
-		 * Sanitize a string destined to be a tooltip.
4902
-		 *
4903
-		 * @param string $var
4904
-		 *
4905
-		 * @return string
4906
-		 */
4907
-		public function sanitize_tooltip( $var ) {
4908
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4909
-				'br'     => array(),
4910
-				'em'     => array(),
4911
-				'strong' => array(),
4912
-				'small'  => array(),
4913
-				'span'   => array(),
4914
-				'ul'     => array(),
4915
-				'li'     => array(),
4916
-				'ol'     => array(),
4917
-				'p'      => array(),
4918
-			) ) );
4919
-		}
4897
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4898
+        }
4920 4899
 
4921
-		/**
4922
-		 * Processing widget options on save
4923
-		 *
4924
-		 * @param array $new_instance The new options
4925
-		 * @param array $old_instance The previous options
4926
-		 *
4927
-		 * @return array
4928
-		 * @todo we should add some sanitation here.
4929
-		 */
4930
-		public function update( $new_instance, $old_instance ) {
4931
-
4932
-			//save the widget
4933
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4934
-
4935
-			// set widget instance
4936
-			$this->instance = $instance;
4937
-
4938
-			if ( empty( $this->arguments ) ) {
4939
-				$this->get_arguments();
4940
-			}
4900
+        /**
4901
+         * Sanitize a string destined to be a tooltip.
4902
+         *
4903
+         * @param string $var
4904
+         *
4905
+         * @return string
4906
+         */
4907
+        public function sanitize_tooltip( $var ) {
4908
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4909
+                'br'     => array(),
4910
+                'em'     => array(),
4911
+                'strong' => array(),
4912
+                'small'  => array(),
4913
+                'span'   => array(),
4914
+                'ul'     => array(),
4915
+                'li'     => array(),
4916
+                'ol'     => array(),
4917
+                'p'      => array(),
4918
+            ) ) );
4919
+        }
4941 4920
 
4942
-			// check for checkboxes
4943
-			if ( ! empty( $this->arguments ) ) {
4944
-				foreach ( $this->arguments as $argument ) {
4945
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4946
-						$instance[ $argument['name'] ] = '0';
4947
-					}
4948
-				}
4949
-			}
4921
+        /**
4922
+         * Processing widget options on save
4923
+         *
4924
+         * @param array $new_instance The new options
4925
+         * @param array $old_instance The previous options
4926
+         *
4927
+         * @return array
4928
+         * @todo we should add some sanitation here.
4929
+         */
4930
+        public function update( $new_instance, $old_instance ) {
4931
+
4932
+            //save the widget
4933
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
4934
+
4935
+            // set widget instance
4936
+            $this->instance = $instance;
4937
+
4938
+            if ( empty( $this->arguments ) ) {
4939
+                $this->get_arguments();
4940
+            }
4941
+
4942
+            // check for checkboxes
4943
+            if ( ! empty( $this->arguments ) ) {
4944
+                foreach ( $this->arguments as $argument ) {
4945
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4946
+                        $instance[ $argument['name'] ] = '0';
4947
+                    }
4948
+                }
4949
+            }
4950 4950
 
4951 4951
             // maybe sanitize widget title
4952 4952
             if(!empty($instance['title'])) {
4953 4953
                 $instance['title'] = wp_kses_post( $instance['title'] );
4954 4954
             }
4955 4955
 
4956
-			return $instance;
4957
-		}
4956
+            return $instance;
4957
+        }
4958 4958
 
4959
-		/**
4960
-		 * Checks if the current call is a ajax call to get the block content.
4961
-		 *
4962
-		 * This can be used in your widget to return different content as the block content.
4963
-		 *
4964
-		 * @return bool
4965
-		 *@since 1.0.3
4966
-		 */
4967
-		public function is_block_content_call() {
4968
-			$result = false;
4969
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4970
-				$result = true;
4971
-			}
4959
+        /**
4960
+         * Checks if the current call is a ajax call to get the block content.
4961
+         *
4962
+         * This can be used in your widget to return different content as the block content.
4963
+         *
4964
+         * @return bool
4965
+         *@since 1.0.3
4966
+         */
4967
+        public function is_block_content_call() {
4968
+            $result = false;
4969
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4970
+                $result = true;
4971
+            }
4972 4972
 
4973
-			return $result;
4974
-		}
4973
+            return $result;
4974
+        }
4975 4975
 
4976
-		/**
4977
-		 * Get an instance hash that will be unique to the type and settings.
4978
-		 *
4979
-		 * @return string
4980
-		 *@since 1.0.20
4981
-		 */
4982
-		public function get_instance_hash(){
4983
-			$instance_string = $this->base_id.serialize($this->instance);
4984
-			return hash('crc32b',$instance_string);
4985
-		}
4976
+        /**
4977
+         * Get an instance hash that will be unique to the type and settings.
4978
+         *
4979
+         * @return string
4980
+         *@since 1.0.20
4981
+         */
4982
+        public function get_instance_hash(){
4983
+            $instance_string = $this->base_id.serialize($this->instance);
4984
+            return hash('crc32b',$instance_string);
4985
+        }
4986 4986
 
4987
-		/**
4988
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4989
-		 *
4990
-		 * @param array $rules
4991
-		 *
4992
-		 * @return string
4993
-		 *@since 1.0.20
4994
-		 */
4995
-		public function get_instance_style($rules = array()){
4996
-			$css = '';
4997
-
4998
-			if(!empty($rules)){
4999
-				$rules = array_unique($rules);
5000
-				$instance_hash = $this->get_instance_hash();
5001
-				$css .= "<style>";
5002
-				foreach($rules as $rule){
5003
-					$css .= ".sdel-$instance_hash $rule";
5004
-				}
5005
-				$css .= "</style>";
5006
-			}
4987
+        /**
4988
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4989
+         *
4990
+         * @param array $rules
4991
+         *
4992
+         * @return string
4993
+         *@since 1.0.20
4994
+         */
4995
+        public function get_instance_style($rules = array()){
4996
+            $css = '';
4997
+
4998
+            if(!empty($rules)){
4999
+                $rules = array_unique($rules);
5000
+                $instance_hash = $this->get_instance_hash();
5001
+                $css .= "<style>";
5002
+                foreach($rules as $rule){
5003
+                    $css .= ".sdel-$instance_hash $rule";
5004
+                }
5005
+                $css .= "</style>";
5006
+            }
5007 5007
 
5008
-			return $css;
5009
-		}
5008
+            return $css;
5009
+        }
5010 5010
 
5011
-		/**
5012
-		 * Encode shortcodes tags.
5013
-		 *
5014
-		 * @param string $content Content to search for shortcode tags.
5015
-		 *
5011
+        /**
5012
+         * Encode shortcodes tags.
5013
+         *
5014
+         * @param string $content Content to search for shortcode tags.
5015
+         *
5016 5016
 *@return string Content with shortcode tags removed.
5017
-		 *@since 1.0.28
5018
-		 *
5019
-		 */
5020
-		public function encode_shortcodes( $content ) {
5021
-			// Avoids existing encoded tags.
5022
-			$trans   = array(
5023
-				'&#91;' => '&#091;',
5024
-				'&#93;' => '&#093;',
5025
-				'&amp;#91;' => '&#091;',
5026
-				'&amp;#93;' => '&#093;',
5027
-				'&lt;' => '&0lt;',
5028
-				'&gt;' => '&0gt;',
5029
-				'&amp;lt;' => '&0lt;',
5030
-				'&amp;gt;' => '&0gt;',
5031
-			);
5032
-
5033
-			$content = strtr( $content, $trans );
5034
-
5035
-			$trans   = array(
5036
-				'[' => '&#91;',
5037
-				']' => '&#93;',
5038
-				'<' => '&lt;',
5039
-				'>' => '&gt;',
5040
-				'"' => '&quot;',
5041
-				"'" => '&#39;',
5042
-			);
5043
-
5044
-			$content = strtr( $content, $trans );
5045
-
5046
-			return $content;
5047
-		}
5017
+         *@since 1.0.28
5018
+         *
5019
+         */
5020
+        public function encode_shortcodes( $content ) {
5021
+            // Avoids existing encoded tags.
5022
+            $trans   = array(
5023
+                '&#91;' => '&#091;',
5024
+                '&#93;' => '&#093;',
5025
+                '&amp;#91;' => '&#091;',
5026
+                '&amp;#93;' => '&#093;',
5027
+                '&lt;' => '&0lt;',
5028
+                '&gt;' => '&0gt;',
5029
+                '&amp;lt;' => '&0lt;',
5030
+                '&amp;gt;' => '&0gt;',
5031
+            );
5032
+
5033
+            $content = strtr( $content, $trans );
5034
+
5035
+            $trans   = array(
5036
+                '[' => '&#91;',
5037
+                ']' => '&#93;',
5038
+                '<' => '&lt;',
5039
+                '>' => '&gt;',
5040
+                '"' => '&quot;',
5041
+                "'" => '&#39;',
5042
+            );
5043
+
5044
+            $content = strtr( $content, $trans );
5045
+
5046
+            return $content;
5047
+        }
5048 5048
 
5049
-		/**
5050
-		 * Remove encoded shortcod tags.
5051
-		 *
5052
-		 * @param string $content Content to search for shortcode tags.
5053
-		 *
5049
+        /**
5050
+         * Remove encoded shortcod tags.
5051
+         *
5052
+         * @param string $content Content to search for shortcode tags.
5053
+         *
5054 5054
 *@return string Content with decoded shortcode tags.
5055
-		 *@since 1.0.28
5056
-		 *
5057
-		 */
5058
-		public function decode_shortcodes( $content ) {
5059
-			$trans   = array(
5060
-				'&#91;' => '[',
5061
-				'&#93;' => ']',
5062
-				'&amp;#91;' => '[',
5063
-				'&amp;#93;' => ']',
5064
-				'&lt;' => '<',
5065
-				'&gt;' => '>',
5066
-				'&amp;lt;' => '<',
5067
-				'&amp;gt;' => '>',
5068
-				'&quot;' => '"',
5069
-				'&apos;' => "'",
5070
-			);
5071
-
5072
-			$content = strtr( $content, $trans );
5073
-
5074
-			$trans   = array(
5075
-				'&#091;' => '&#91;',
5076
-				'&#093;' => '&#93;',
5077
-				'&amp;#091;' => '&#91;',
5078
-				'&amp;#093;' => '&#93;',
5079
-				'&0lt;' => '&lt;',
5080
-				'&0gt;' => '&gt;',
5081
-				'&amp;0lt;' => '&lt;',
5082
-				'&amp;0gt;' => '&gt;',
5083
-			);
5084
-
5085
-			$content = strtr( $content, $trans );
5086
-
5087
-			return $content;
5088
-		}
5089
-
5090
-		public function block_visibility_fields( $args ) {
5091
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5092
-			$content = '<div class="bs-vc-rule-template d-none">';
5093
-				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5094
-					$content .= '<div class="row">';
5095
-						$content .= '<div class="col-sm-12">';
5096
-							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5097
-							$content .= aui()->select(
5098
-								array(
5099
-									'id'          => 'bsvc_rule_BSVCINDEX',
5100
-									'name'        => 'bsvc_rule_BSVCINDEX',
5101
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5102
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5103
-									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5104
-									'options'     => sd_visibility_rules_options(),
5105
-									'default'     => '',
5106
-									'value'       => '',
5107
-									'label_type'  => '',
5108
-									'select2'     => false,
5109
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5110
-									'extra_attributes' => array(
5111
-										'data-minimum-results-for-search' => '-1'
5112
-									)
5113
-								)
5114
-							);
5115
-
5116
-						$content .= '</div>';
5117
-
5118
-						if ( class_exists( 'GeoDirectory' ) ) {
5119
-							$content .= '<div class="col-md-7 col-sm-12">';
5120
-
5121
-								$content .= aui()->select(
5122
-									array(
5123
-										'id'          => 'bsvc_gd_field_BSVCINDEX',
5124
-										'name'        => 'bsvc_gd_field_BSVCINDEX',
5125
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5126
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5127
-										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5128
-										'options'     => sd_visibility_gd_field_options(),
5129
-										'default'     => '',
5130
-										'value'       => '',
5131
-										'label_type'  => '',
5132
-										'select2'     => false,
5133
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5134
-										'extra_attributes' => array(
5135
-											'data-minimum-results-for-search' => '-1'
5136
-										)
5137
-									)
5138
-								);
5139
-
5140
-							$content .= '</div>';
5141
-							$content .= '<div class="col-md-5 col-sm-12">';
5142
-
5143
-								$content .= aui()->select(
5144
-									array(
5145
-										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5146
-										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5147
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5148
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5149
-										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5150
-										'options'     => sd_visibility_field_condition_options(),
5151
-										'default'     => '',
5152
-										'value'       => '',
5153
-										'label_type'  => '',
5154
-										'select2'     => false,
5155
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5156
-										'extra_attributes' => array(
5157
-											'data-minimum-results-for-search' => '-1'
5158
-										)
5159
-									)
5160
-								);
5161
-
5162
-							$content .= '</div>';
5163
-							$content .= '<div class="col-sm-12">';
5164
-
5165
-								$content .= aui()->input(
5166
-									array(
5167
-										'type'            => 'text',
5168
-										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5169
-										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5170
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5171
-										'class'           => 'bsvc_gd_field_search form-control-sm',
5172
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5173
-										'label_type'      => '',
5174
-										'value'           => '',
5175
-										'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5176
-									)
5177
-								);
5055
+         *@since 1.0.28
5056
+         *
5057
+         */
5058
+        public function decode_shortcodes( $content ) {
5059
+            $trans   = array(
5060
+                '&#91;' => '[',
5061
+                '&#93;' => ']',
5062
+                '&amp;#91;' => '[',
5063
+                '&amp;#93;' => ']',
5064
+                '&lt;' => '<',
5065
+                '&gt;' => '>',
5066
+                '&amp;lt;' => '<',
5067
+                '&amp;gt;' => '>',
5068
+                '&quot;' => '"',
5069
+                '&apos;' => "'",
5070
+            );
5071
+
5072
+            $content = strtr( $content, $trans );
5073
+
5074
+            $trans   = array(
5075
+                '&#091;' => '&#91;',
5076
+                '&#093;' => '&#93;',
5077
+                '&amp;#091;' => '&#91;',
5078
+                '&amp;#093;' => '&#93;',
5079
+                '&0lt;' => '&lt;',
5080
+                '&0gt;' => '&gt;',
5081
+                '&amp;0lt;' => '&lt;',
5082
+                '&amp;0gt;' => '&gt;',
5083
+            );
5084
+
5085
+            $content = strtr( $content, $trans );
5086
+
5087
+            return $content;
5088
+        }
5178 5089
 
5179
-							$content .= '</div>';
5180
-						}
5090
+        public function block_visibility_fields( $args ) {
5091
+            $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5092
+            $content = '<div class="bs-vc-rule-template d-none">';
5093
+                $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5094
+                    $content .= '<div class="row">';
5095
+                        $content .= '<div class="col-sm-12">';
5096
+                            $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5097
+                            $content .= aui()->select(
5098
+                                array(
5099
+                                    'id'          => 'bsvc_rule_BSVCINDEX',
5100
+                                    'name'        => 'bsvc_rule_BSVCINDEX',
5101
+                                    'label'       => __( 'Rule', 'ayecode-connect' ),
5102
+                                    'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5103
+                                    'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5104
+                                    'options'     => sd_visibility_rules_options(),
5105
+                                    'default'     => '',
5106
+                                    'value'       => '',
5107
+                                    'label_type'  => '',
5108
+                                    'select2'     => false,
5109
+                                    'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5110
+                                    'extra_attributes' => array(
5111
+                                        'data-minimum-results-for-search' => '-1'
5112
+                                    )
5113
+                                )
5114
+                            );
5115
+
5116
+                        $content .= '</div>';
5117
+
5118
+                        if ( class_exists( 'GeoDirectory' ) ) {
5119
+                            $content .= '<div class="col-md-7 col-sm-12">';
5120
+
5121
+                                $content .= aui()->select(
5122
+                                    array(
5123
+                                        'id'          => 'bsvc_gd_field_BSVCINDEX',
5124
+                                        'name'        => 'bsvc_gd_field_BSVCINDEX',
5125
+                                        'label'       => __( 'FIELD', 'ayecode-connect' ),
5126
+                                        'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5127
+                                        'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5128
+                                        'options'     => sd_visibility_gd_field_options(),
5129
+                                        'default'     => '',
5130
+                                        'value'       => '',
5131
+                                        'label_type'  => '',
5132
+                                        'select2'     => false,
5133
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5134
+                                        'extra_attributes' => array(
5135
+                                            'data-minimum-results-for-search' => '-1'
5136
+                                        )
5137
+                                    )
5138
+                                );
5139
+
5140
+                            $content .= '</div>';
5141
+                            $content .= '<div class="col-md-5 col-sm-12">';
5142
+
5143
+                                $content .= aui()->select(
5144
+                                    array(
5145
+                                        'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5146
+                                        'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5147
+                                        'label'       => __( 'CONDITION', 'ayecode-connect' ),
5148
+                                        'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5149
+                                        'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5150
+                                        'options'     => sd_visibility_field_condition_options(),
5151
+                                        'default'     => '',
5152
+                                        'value'       => '',
5153
+                                        'label_type'  => '',
5154
+                                        'select2'     => false,
5155
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5156
+                                        'extra_attributes' => array(
5157
+                                            'data-minimum-results-for-search' => '-1'
5158
+                                        )
5159
+                                    )
5160
+                                );
5161
+
5162
+                            $content .= '</div>';
5163
+                            $content .= '<div class="col-sm-12">';
5164
+
5165
+                                $content .= aui()->input(
5166
+                                    array(
5167
+                                        'type'            => 'text',
5168
+                                        'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5169
+                                        'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5170
+                                        'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5171
+                                        'class'           => 'bsvc_gd_field_search form-control-sm',
5172
+                                        'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5173
+                                        'label_type'      => '',
5174
+                                        'value'           => '',
5175
+                                        'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5176
+                                    )
5177
+                                );
5178
+
5179
+                            $content .= '</div>';
5180
+                        }
5181 5181
 
5182 5182
                         $content .= apply_filters( 'sd_block_visibility_fields', '', $args );
5183 5183
 
5184
-					$content .= '</div>';
5185
-
5186
-					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5187
-						$role_options = sd_user_roles_options();
5188
-
5189
-						$role_option_i = 0;
5190
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5191
-							$role_option_i++;
5192
-
5193
-							$content .= '<div class="col-sm-6">';
5194
-							$content .= aui()->input(
5195
-								array(
5196
-									'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5197
-									'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5198
-									'type'             => 'checkbox',
5199
-									'label'            => $role_option_name,
5200
-									'label_type'       => 'hidden',
5201
-									'class'            => 'bsvc_user_roles',
5202
-									'value'            => $role_option_key,
5203
-									'switch'           => 'md',
5204
-									'no_wrap'          => true
5205
-								)
5206
-							);
5207
-							$content .= '</div>';
5208
-						}
5209
-					$content .= '</div>';
5210
-					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5211
-				$content .= '</div>';
5212
-			$content .= '</div>';
5213
-			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5214
-			$content .= '<div class="bs-vc-rule-sets"></div>';
5215
-			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5216
-			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5217
-			$content .= aui()->select(
5218
-				array(
5219
-					'id'          => 'bsvc_output',
5220
-					'name'        => 'bsvc_output',
5221
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5222
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5223
-					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5224
-					'options'     => sd_visibility_output_options(),
5225
-					'default'     => '',
5226
-					'value'       => '',
5227
-					'label_type'  => 'top',
5228
-					'select2'     => false,
5229
-					'extra_attributes' => array(
5230
-						'data-minimum-results-for-search' => '-1'
5231
-					)
5232
-				)
5233
-			);
5234
-
5235
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5236
-
5237
-			$content .= aui()->select(
5238
-				array(
5239
-					'id'              => 'bsvc_page',
5240
-					'name'            => 'bsvc_page',
5241
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5242
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5243
-					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5244
-					'options'         => sd_template_page_options(),
5245
-					'default'         => '',
5246
-					'value'           => '',
5247
-					'label_type'      => 'top',
5248
-					'select2'         => false,
5249
-					'element_require' => '[%bsvc_output%]=="page"'
5250
-				)
5251
-			);
5252
-
5253
-			$content .= aui()->select(
5254
-				array(
5255
-					'id'          => 'bsvc_tmpl_part',
5256
-					'name'        => 'bsvc_tmpl_part',
5257
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5258
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5259
-					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5260
-					'options'     => sd_template_part_options(),
5261
-					'default'     => '',
5262
-					'value'       => '',
5263
-					'label_type'  => 'top',
5264
-					'select2'     => false,
5265
-					'element_require'  => '[%bsvc_output%]=="template_part"',
5266
-					'extra_attributes' => array(
5267
-						'data-minimum-results-for-search' => '-1'
5268
-					)
5269
-				)
5270
-			);
5271
-
5272
-			$content .= aui()->select(
5273
-				array(
5274
-					'id'               => 'bsvc_message_type',
5275
-					'name'             => 'bsvc_message_type',
5276
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5277
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5278
-					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5279
-					'options'          => sd_aui_colors(),
5280
-					'default'          => '',
5281
-					'value'            => '',
5282
-					'label_type'       => 'top',
5283
-					'select2'          => false,
5284
-					'element_require'  => '[%bsvc_output%]=="message"',
5285
-					'extra_attributes' => array(
5286
-						'data-minimum-results-for-search' => '-1'
5287
-					)
5288
-				)
5289
-			);
5290
-
5291
-			$content .= '</div><div class="col-sm-12">';
5292
-
5293
-			$content .= aui()->input(
5294
-				array(
5295
-					'type'            => 'text',
5296
-					'id'              => 'bsvc_message',
5297
-					'name'            => 'bsvc_message',
5298
-					'label'           => '',
5299
-					'class'           => 'bsvc_message form-control-sm mb-3',
5300
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5301
-					'label_type'      => '',
5302
-					'value'           => '',
5303
-					'form_group_class' => ' ',
5304
-					'element_require' => '[%bsvc_output%]=="message"',
5305
-				)
5306
-			);
5307
-
5308
-			$content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5309
-			$content .= aui()->select(
5310
-				array(
5311
-					'id'          => 'bsvc_output_n',
5312
-					'name'        => 'bsvc_output_n',
5313
-					'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5314
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5315
-					'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5316
-					'options'     => sd_visibility_output_options(),
5317
-					'default'     => '',
5318
-					'value'       => '',
5319
-					'label_type'  => 'top',
5320
-					'select2'     => false,
5321
-					'extra_attributes' => array(
5322
-						'data-minimum-results-for-search' => '-1'
5323
-					)
5324
-				)
5325
-			);
5326
-
5327
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5328
-
5329
-			$content .= aui()->select(
5330
-				array(
5331
-					'id'              => 'bsvc_page_n',
5332
-					'name'            => 'bsvc_page_n',
5333
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5334
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5335
-					'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5336
-					'options'         => sd_template_page_options(),
5337
-					'default'         => '',
5338
-					'value'           => '',
5339
-					'label_type'      => 'top',
5340
-					'select2'         => false,
5341
-					'element_require' => '[%bsvc_output_n%]=="page"'
5342
-				)
5343
-			);
5344
-
5345
-			$content .= aui()->select(
5346
-				array(
5347
-					'id'          => 'bsvc_tmpl_part_n',
5348
-					'name'        => 'bsvc_tmpl_part_n',
5349
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5350
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5351
-					'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5352
-					'options'     => sd_template_part_options(),
5353
-					'default'     => '',
5354
-					'value'       => '',
5355
-					'label_type'  => 'top',
5356
-					'select2'     => false,
5357
-					'element_require'  => '[%bsvc_output_n%]=="template_part"',
5358
-					'extra_attributes' => array(
5359
-						'data-minimum-results-for-search' => '-1'
5360
-					)
5361
-				)
5362
-			);
5363
-
5364
-			$content .= aui()->select(
5365
-				array(
5366
-					'id'               => 'bsvc_message_type_n',
5367
-					'name'             => 'bsvc_message_type_n',
5368
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5369
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5370
-					'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5371
-					'options'          => sd_aui_colors(),
5372
-					'default'          => '',
5373
-					'value'            => '',
5374
-					'label_type'       => 'top',
5375
-					'select2'          => false,
5376
-					'element_require'  => '[%bsvc_output_n%]=="message"',
5377
-					'extra_attributes' => array(
5378
-						'data-minimum-results-for-search' => '-1'
5379
-					)
5380
-				)
5381
-			);
5382
-
5383
-			$content .= '</div><div class="col-sm-12">';
5384
-
5385
-			$content .= aui()->input(
5386
-				array(
5387
-					'type'            => 'text',
5388
-					'id'              => 'bsvc_message_n',
5389
-					'name'            => 'bsvc_message_n',
5390
-					'label'           => '',
5391
-					'class'           => 'bsvc_message_n form-control-sm',
5392
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5393
-					'label_type'      => '',
5394
-					'value'           => '',
5395
-					'form_group_class' => ' ',
5396
-					'element_require' => '[%bsvc_output_n%]=="message"',
5397
-				)
5398
-			);
5399
-
5400
-			$content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5401
-
5402
-			return $content;
5403
-		}
5184
+                    $content .= '</div>';
5185
+
5186
+                    $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5187
+                        $role_options = sd_user_roles_options();
5188
+
5189
+                        $role_option_i = 0;
5190
+                        foreach ( $role_options as $role_option_key => $role_option_name ) {
5191
+                            $role_option_i++;
5192
+
5193
+                            $content .= '<div class="col-sm-6">';
5194
+                            $content .= aui()->input(
5195
+                                array(
5196
+                                    'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5197
+                                    'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5198
+                                    'type'             => 'checkbox',
5199
+                                    'label'            => $role_option_name,
5200
+                                    'label_type'       => 'hidden',
5201
+                                    'class'            => 'bsvc_user_roles',
5202
+                                    'value'            => $role_option_key,
5203
+                                    'switch'           => 'md',
5204
+                                    'no_wrap'          => true
5205
+                                )
5206
+                            );
5207
+                            $content .= '</div>';
5208
+                        }
5209
+                    $content .= '</div>';
5210
+                    $content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5211
+                $content .= '</div>';
5212
+            $content .= '</div>';
5213
+            $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5214
+            $content .= '<div class="bs-vc-rule-sets"></div>';
5215
+            $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5216
+            $content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5217
+            $content .= aui()->select(
5218
+                array(
5219
+                    'id'          => 'bsvc_output',
5220
+                    'name'        => 'bsvc_output',
5221
+                    'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5222
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5223
+                    'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5224
+                    'options'     => sd_visibility_output_options(),
5225
+                    'default'     => '',
5226
+                    'value'       => '',
5227
+                    'label_type'  => 'top',
5228
+                    'select2'     => false,
5229
+                    'extra_attributes' => array(
5230
+                        'data-minimum-results-for-search' => '-1'
5231
+                    )
5232
+                )
5233
+            );
5234
+
5235
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5236
+
5237
+            $content .= aui()->select(
5238
+                array(
5239
+                    'id'              => 'bsvc_page',
5240
+                    'name'            => 'bsvc_page',
5241
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5242
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5243
+                    'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5244
+                    'options'         => sd_template_page_options(),
5245
+                    'default'         => '',
5246
+                    'value'           => '',
5247
+                    'label_type'      => 'top',
5248
+                    'select2'         => false,
5249
+                    'element_require' => '[%bsvc_output%]=="page"'
5250
+                )
5251
+            );
5252
+
5253
+            $content .= aui()->select(
5254
+                array(
5255
+                    'id'          => 'bsvc_tmpl_part',
5256
+                    'name'        => 'bsvc_tmpl_part',
5257
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5258
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5259
+                    'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5260
+                    'options'     => sd_template_part_options(),
5261
+                    'default'     => '',
5262
+                    'value'       => '',
5263
+                    'label_type'  => 'top',
5264
+                    'select2'     => false,
5265
+                    'element_require'  => '[%bsvc_output%]=="template_part"',
5266
+                    'extra_attributes' => array(
5267
+                        'data-minimum-results-for-search' => '-1'
5268
+                    )
5269
+                )
5270
+            );
5271
+
5272
+            $content .= aui()->select(
5273
+                array(
5274
+                    'id'               => 'bsvc_message_type',
5275
+                    'name'             => 'bsvc_message_type',
5276
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5277
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5278
+                    'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5279
+                    'options'          => sd_aui_colors(),
5280
+                    'default'          => '',
5281
+                    'value'            => '',
5282
+                    'label_type'       => 'top',
5283
+                    'select2'          => false,
5284
+                    'element_require'  => '[%bsvc_output%]=="message"',
5285
+                    'extra_attributes' => array(
5286
+                        'data-minimum-results-for-search' => '-1'
5287
+                    )
5288
+                )
5289
+            );
5290
+
5291
+            $content .= '</div><div class="col-sm-12">';
5292
+
5293
+            $content .= aui()->input(
5294
+                array(
5295
+                    'type'            => 'text',
5296
+                    'id'              => 'bsvc_message',
5297
+                    'name'            => 'bsvc_message',
5298
+                    'label'           => '',
5299
+                    'class'           => 'bsvc_message form-control-sm mb-3',
5300
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5301
+                    'label_type'      => '',
5302
+                    'value'           => '',
5303
+                    'form_group_class' => ' ',
5304
+                    'element_require' => '[%bsvc_output%]=="message"',
5305
+                )
5306
+            );
5307
+
5308
+            $content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5309
+            $content .= aui()->select(
5310
+                array(
5311
+                    'id'          => 'bsvc_output_n',
5312
+                    'name'        => 'bsvc_output_n',
5313
+                    'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5314
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5315
+                    'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5316
+                    'options'     => sd_visibility_output_options(),
5317
+                    'default'     => '',
5318
+                    'value'       => '',
5319
+                    'label_type'  => 'top',
5320
+                    'select2'     => false,
5321
+                    'extra_attributes' => array(
5322
+                        'data-minimum-results-for-search' => '-1'
5323
+                    )
5324
+                )
5325
+            );
5326
+
5327
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5328
+
5329
+            $content .= aui()->select(
5330
+                array(
5331
+                    'id'              => 'bsvc_page_n',
5332
+                    'name'            => 'bsvc_page_n',
5333
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5334
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5335
+                    'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5336
+                    'options'         => sd_template_page_options(),
5337
+                    'default'         => '',
5338
+                    'value'           => '',
5339
+                    'label_type'      => 'top',
5340
+                    'select2'         => false,
5341
+                    'element_require' => '[%bsvc_output_n%]=="page"'
5342
+                )
5343
+            );
5344
+
5345
+            $content .= aui()->select(
5346
+                array(
5347
+                    'id'          => 'bsvc_tmpl_part_n',
5348
+                    'name'        => 'bsvc_tmpl_part_n',
5349
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5350
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5351
+                    'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5352
+                    'options'     => sd_template_part_options(),
5353
+                    'default'     => '',
5354
+                    'value'       => '',
5355
+                    'label_type'  => 'top',
5356
+                    'select2'     => false,
5357
+                    'element_require'  => '[%bsvc_output_n%]=="template_part"',
5358
+                    'extra_attributes' => array(
5359
+                        'data-minimum-results-for-search' => '-1'
5360
+                    )
5361
+                )
5362
+            );
5363
+
5364
+            $content .= aui()->select(
5365
+                array(
5366
+                    'id'               => 'bsvc_message_type_n',
5367
+                    'name'             => 'bsvc_message_type_n',
5368
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5369
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5370
+                    'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5371
+                    'options'          => sd_aui_colors(),
5372
+                    'default'          => '',
5373
+                    'value'            => '',
5374
+                    'label_type'       => 'top',
5375
+                    'select2'          => false,
5376
+                    'element_require'  => '[%bsvc_output_n%]=="message"',
5377
+                    'extra_attributes' => array(
5378
+                        'data-minimum-results-for-search' => '-1'
5379
+                    )
5380
+                )
5381
+            );
5382
+
5383
+            $content .= '</div><div class="col-sm-12">';
5384
+
5385
+            $content .= aui()->input(
5386
+                array(
5387
+                    'type'            => 'text',
5388
+                    'id'              => 'bsvc_message_n',
5389
+                    'name'            => 'bsvc_message_n',
5390
+                    'label'           => '',
5391
+                    'class'           => 'bsvc_message_n form-control-sm',
5392
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5393
+                    'label_type'      => '',
5394
+                    'value'           => '',
5395
+                    'form_group_class' => ' ',
5396
+                    'element_require' => '[%bsvc_output_n%]=="message"',
5397
+                )
5398
+            );
5399
+
5400
+            $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5401
+
5402
+            return $content;
5403
+        }
5404 5404
 
5405
-		/**
5406
-		 * Handle media_buttons hook.
5407
-		 *
5408
-		 * @since 1.2.7
5409
-		 */
5410
-		public function wp_media_buttons() {
5411
-			global $shortcode_insert_button_once;
5412
-
5413
-			// Fix conflicts with UpSolution Core in header template edit element.
5414
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5415
-				$shortcode_insert_button_once = true;
5416
-			}
5417
-		}
5418
-	}
5405
+        /**
5406
+         * Handle media_buttons hook.
5407
+         *
5408
+         * @since 1.2.7
5409
+         */
5410
+        public function wp_media_buttons() {
5411
+            global $shortcode_insert_button_once;
5412
+
5413
+            // Fix conflicts with UpSolution Core in header template edit element.
5414
+            if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5415
+                $shortcode_insert_button_once = true;
5416
+            }
5417
+        }
5418
+    }
5419 5419
 }
Please login to merge, or discard this patch.
invoicing.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.8.30' );
26
+    define( 'WPINV_VERSION', '2.8.30' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Indentation   +80 added lines, -80 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;
@@ -180,72 +180,72 @@  discard block
 block discarded – undo
180 180
  * @return int page ID
181 181
  */
182 182
 function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
183
-	global $wpdb;
184
-
185
-	$option_value = wpinv_get_option( $option );
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' ) ) ) {
189
-			// Valid page is already in place
190
-			return $page_object->ID;
191
-		}
192
-	}
193
-
194
-	if ( ! empty( $post_parent ) ) {
195
-		$page = get_page_by_path( $post_parent );
196
-		if ( $page ) {
197
-			$post_parent = $page->ID;
198
-		} else {
199
-			$post_parent = '';
200
-		}
201
-	}
202
-
203
-	// Search for an existing page with the specified page slug
204
-	$valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
-
206
-	$valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
207
-
208
-	if ( $valid_page_found ) {
209
-		if ( $option ) {
210
-			wpinv_update_option( $option, $valid_page_found );
211
-		}
212
-
213
-		return $valid_page_found;
214
-	}
215
-
216
-	// Search for an existing page with the specified page slug
217
-	$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 ) );
218
-
219
-	if ( $trashed_page_found ) {
220
-		$page_id   = $trashed_page_found;
221
-
222
-		$page_data = array(
223
-			'ID'          => $page_id,
224
-			'post_status' => 'publish',
225
-			'post_parent' => $post_parent,
226
-		);
227
-
228
-		wp_update_post( $page_data );
229
-	} else {
230
-		$page_data = array(
231
-			'post_status'    => 'publish',
232
-			'post_type'      => 'page',
233
-			'post_author'    => 1,
234
-			'post_name'      => $slug,
235
-			'post_title'     => $page_title,
236
-			'post_content'   => $page_content,
237
-			'post_parent'    => $post_parent,
238
-			'comment_status' => 'closed',
239
-		);
240
-
241
-		$page_id = wp_insert_post( $page_data );
242
-	}
243
-
244
-	if ( $option ) {
245
-		wpinv_update_option( $option, (int) $page_id );
246
-	}
247
-
248
-	return $page_id;
183
+    global $wpdb;
184
+
185
+    $option_value = wpinv_get_option( $option );
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' ) ) ) {
189
+            // Valid page is already in place
190
+            return $page_object->ID;
191
+        }
192
+    }
193
+
194
+    if ( ! empty( $post_parent ) ) {
195
+        $page = get_page_by_path( $post_parent );
196
+        if ( $page ) {
197
+            $post_parent = $page->ID;
198
+        } else {
199
+            $post_parent = '';
200
+        }
201
+    }
202
+
203
+    // Search for an existing page with the specified page slug
204
+    $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
+
206
+    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
207
+
208
+    if ( $valid_page_found ) {
209
+        if ( $option ) {
210
+            wpinv_update_option( $option, $valid_page_found );
211
+        }
212
+
213
+        return $valid_page_found;
214
+    }
215
+
216
+    // Search for an existing page with the specified page slug
217
+    $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 ) );
218
+
219
+    if ( $trashed_page_found ) {
220
+        $page_id   = $trashed_page_found;
221
+
222
+        $page_data = array(
223
+            'ID'          => $page_id,
224
+            'post_status' => 'publish',
225
+            'post_parent' => $post_parent,
226
+        );
227
+
228
+        wp_update_post( $page_data );
229
+    } else {
230
+        $page_data = array(
231
+            'post_status'    => 'publish',
232
+            'post_type'      => 'page',
233
+            'post_author'    => 1,
234
+            'post_name'      => $slug,
235
+            'post_title'     => $page_title,
236
+            'post_content'   => $page_content,
237
+            'post_parent'    => $post_parent,
238
+            'comment_status' => 'closed',
239
+        );
240
+
241
+        $page_id = wp_insert_post( $page_data );
242
+    }
243
+
244
+    if ( $option ) {
245
+        wpinv_update_option( $option, (int) $page_id );
246
+    }
247
+
248
+    return $page_id;
249 249
 }
250 250
 
251 251
 /**
Please login to merge, or discard this patch.
includes/admin/class-getpaid-installer.php 1 patch
Indentation   +493 added lines, -493 removed lines patch added patch discarded remove patch
@@ -20,392 +20,392 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class GetPaid_Installer {
22 22
 
23
-	private static $schema = null;
24
-	private static $schema_version = null;
25
-
26
-	/**
27
-	 * Upgrades the install.
28
-	 *
29
-	 * @param string $upgrade_from The current invoicing version.
30
-	 */
31
-	public function upgrade_db( $upgrade_from ) {
32
-
33
-		// Save the current invoicing version.
34
-		update_option( 'wpinv_version', WPINV_VERSION );
35
-
36
-		// Setup the invoice Custom Post Type.
37
-		GetPaid_Post_Types::register_post_types();
38
-
39
-		// Clear the permalinks
40
-		flush_rewrite_rules();
41
-
42
-		// Maybe create new/missing pages.
43
-		$this->create_pages();
44
-
45
-		// Maybe re(add) admin capabilities.
46
-		$this->add_capabilities();
47
-
48
-		// Maybe create the default payment form.
49
-		wpinv_get_default_payment_form();
50
-
51
-		// Create any missing database tables.
52
-		$method = "upgrade_from_$upgrade_from";
53
-
54
-		$installed = get_option( 'gepaid_installed_on' );
55
-
56
-		if ( empty( $installed ) ) {
57
-			update_option( 'gepaid_installed_on', time() );
58
-		}
59
-
60
-		if ( method_exists( $this, $method ) ) {
61
-			$this->$method();
62
-		}
63
-
64
-	}
65
-
66
-	/**
67
-	 * Do a fresh install.
68
-	 *
69
-	 */
70
-	public function upgrade_from_0() {
71
-
72
-		// Save default tax rates.
73
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
-	}
75
-
76
-	/**
77
-	 * Upgrade to 0.0.5
78
-	 *
79
-	 */
80
-	public function upgrade_from_004() {
81
-		global $wpdb;
82
-
83
-		// Invoices.
84
-		$results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
-		if ( ! empty( $results ) ) {
86
-			$wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
-
88
-			// Clean post cache
89
-			foreach ( $results as $row ) {
90
-				clean_post_cache( $row->ID );
91
-			}
92
-		}
93
-
94
-		// Item meta key changes
95
-		$query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
-		$results = $wpdb->get_results( $query );
97
-
98
-		if ( ! empty( $results ) ) {
99
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
-			$wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
-
103
-			foreach ( $results as $row ) {
104
-				clean_post_cache( $row->post_id );
105
-			}
106
-		}
107
-
108
-		$this->upgrade_from_118();
109
-	}
110
-
111
-	/**
112
-	 * Upgrade to version 2.0.0.
113
-	 *
114
-	 */
115
-	public function upgrade_from_118() {
116
-		$this->migrate_old_invoices();
117
-		$this->upgrade_from_279();
118
-	}
119
-
120
-	/**
121
-	 * Upgrade to version 2.0.0.
122
-	 *
123
-	 */
124
-	public function upgrade_from_279() {
125
-		self::migrate_old_customers();
126
-	}
127
-
128
-	/**
129
-	 * Give administrators the capability to manage GetPaid.
130
-	 *
131
-	 */
132
-	public function add_capabilities() {
133
-		$GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
134
-	}
135
-
136
-	/**
137
-	 * Retreives GetPaid pages.
138
-	 *
139
-	 */
140
-	public static function get_pages( $filtered = false ) {
141
-		$gutenberg = getpaid_is_gutenberg();
142
-
143
-		return apply_filters(
144
-			'wpinv_create_pages',
145
-			array(
146
-				// Checkout page.
147
-				'checkout_page' => array(
148
-					'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
149
-					'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
150
-					'content' => getpaid_page_content_checkout( $filtered, $gutenberg ),
151
-					'parent'  => ''
152
-				),
153
-
154
-				// Invoice history page.
155
-				'invoice_history_page' => array(
156
-					'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
157
-					'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
158
-					'content' => getpaid_page_content_invoice_history( $filtered, $gutenberg ),
159
-					'parent'  => ''
160
-				),
161
-
162
-				// Success page content.
163
-				'success_page' => array(
164
-					'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
165
-					'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
166
-					'content' => getpaid_page_content_receipt( $filtered, $gutenberg ),
167
-					'parent'  => 'gp-checkout'
168
-				),
169
-
170
-				// Failure page content.
171
-				'failure_page' => array(
172
-					'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
173
-					'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
174
-					'content' => getpaid_page_content_failure( $filtered, $gutenberg ),
175
-					'parent'  => 'gp-checkout'
176
-				),
177
-
178
-				// Subscriptions history page.
179
-				'invoice_subscription_page' => array(
180
-					'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
181
-					'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
182
-					'content' => getpaid_page_content_subscriptions( $filtered, $gutenberg ),
183
-					'parent'  => ''
184
-				)
185
-			)
186
-		);
187
-	}
188
-
189
-	/**
190
-	 * Re-create GetPaid pages.
191
-	 *
192
-	 */
193
-	public function create_pages() {
194
-		foreach ( self::get_pages() as $key => $page ) {
195
-			wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
196
-		}
197
-
198
-	}
199
-
200
-	/**
201
-	 * Migrates old invoices to new invoices.
202
-	 *
203
-	 */
204
-	public function migrate_old_invoices() {
205
-		global $wpdb;
206
-
207
-		$invoices_table      = $wpdb->prefix . 'getpaid_invoices';
208
-		$invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
209
-		$migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
210
-		$invoices            = array_unique(
211
-			get_posts(
212
-				array(
213
-					'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
214
-					'posts_per_page' => -1,
215
-					'fields'         => 'ids',
216
-					'post_status'    => array_keys( get_post_stati() ),
217
-					'exclude'        => (array) $migrated,
218
-				)
219
-			)
220
-		);
221
-
222
-		// Abort if we do not have any invoices.
223
-		if ( empty( $invoices ) ) {
224
-			return;
225
-		}
226
-
227
-		require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
228
-
229
-		$invoice_rows = array();
230
-		foreach ( $invoices as $invoice ) {
231
-
232
-			$invoice = new WPInv_Legacy_Invoice( $invoice );
233
-
234
-			if ( empty( $invoice->ID ) ) {
235
-				return;
236
-			}
237
-
238
-			$fields = array(
239
-				'post_id'            => $invoice->ID,
240
-				'number'             => $invoice->get_number(),
241
-				'key'                => $invoice->get_key(),
242
-				'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
243
-				'mode'               => $invoice->mode,
244
-				'user_ip'            => $invoice->get_ip(),
245
-				'first_name'         => $invoice->get_first_name(),
246
-				'last_name'          => $invoice->get_last_name(),
247
-				'address'            => $invoice->get_address(),
248
-				'city'               => $invoice->city,
249
-				'state'              => $invoice->state,
250
-				'country'            => $invoice->country,
251
-				'zip'                => $invoice->zip,
252
-				'adddress_confirmed' => (int) $invoice->adddress_confirmed,
253
-				'gateway'            => $invoice->get_gateway(),
254
-				'transaction_id'     => $invoice->get_transaction_id(),
255
-				'currency'           => $invoice->get_currency(),
256
-				'subtotal'           => $invoice->get_subtotal(),
257
-				'tax'                => $invoice->get_tax(),
258
-				'fees_total'         => $invoice->get_fees_total(),
259
-				'total'              => $invoice->get_total(),
260
-				'discount'           => $invoice->get_discount(),
261
-				'discount_code'      => $invoice->get_discount_code(),
262
-				'disable_taxes'      => $invoice->disable_taxes,
263
-				'due_date'           => $invoice->get_due_date(),
264
-				'completed_date'     => $invoice->get_completed_date(),
265
-				'company'            => $invoice->company,
266
-				'vat_number'         => $invoice->vat_number,
267
-				'vat_rate'           => $invoice->vat_rate,
268
-				'custom_meta'        => $invoice->payment_meta,
269
-			);
270
-
271
-			foreach ( $fields as $key => $val ) {
272
-				if ( is_null( $val ) ) {
273
-					$val = '';
274
-				}
275
-				$val = maybe_serialize( $val );
276
-				$fields[ $key ] = $wpdb->prepare( '%s', $val );
277
-			}
278
-
279
-			$fields = implode( ', ', $fields );
280
-			$invoice_rows[] = "($fields)";
281
-
282
-			$item_rows    = array();
283
-			$item_columns = array();
284
-			foreach ( $invoice->get_cart_details() as $details ) {
285
-				$fields = array(
286
-					'post_id'          => $invoice->ID,
287
-					'item_id'          => $details['id'],
288
-					'item_name'        => $details['name'],
289
-					'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
290
-					'vat_rate'         => $details['vat_rate'],
291
-					'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
292
-					'tax'              => $details['tax'],
293
-					'item_price'       => $details['item_price'],
294
-					'custom_price'     => $details['custom_price'],
295
-					'quantity'         => $details['quantity'],
296
-					'discount'         => $details['discount'],
297
-					'subtotal'         => $details['subtotal'],
298
-					'price'            => $details['price'],
299
-					'meta'             => $details['meta'],
300
-					'fees'             => $details['fees'],
301
-				);
302
-
303
-				$item_columns = array_keys( $fields );
304
-
305
-				foreach ( $fields as $key => $val ) {
306
-					if ( is_null( $val ) ) {
307
-						$val = '';
308
-					}
309
-					$val = maybe_serialize( $val );
310
-					$fields[ $key ] = $wpdb->prepare( '%s', $val );
311
-				}
312
-
313
-				$fields = implode( ', ', $fields );
314
-				$item_rows[] = "($fields)";
315
-			}
316
-
317
-			$item_rows    = implode( ', ', $item_rows );
318
-			$item_columns = implode( ', ', $item_columns );
319
-			$wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
320
-		}
321
-
322
-		if ( empty( $invoice_rows ) ) {
323
-			return;
324
-		}
325
-
326
-		$invoice_rows = implode( ', ', $invoice_rows );
327
-		$wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
328
-
329
-	}
330
-
331
-	/**
332
-	 * Migrates old customers to new table.
333
-	 *
334
-	 */
335
-	public static function migrate_old_customers() {
336
-		global $wpdb;
337
-
338
-		// Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
339
-		$invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
340
-
341
-		foreach ( $invoice_ids as $invoice_id ) {
342
-			$invoice = wpinv_get_invoice( $invoice_id );
343
-
344
-			if ( empty( $invoice ) ) {
345
-				continue;
346
-			}
347
-
348
-			// Fetch customer from the user ID.
349
-			$user_id = $invoice->get_user_id();
350
-
351
-			if ( empty( $user_id ) ) {
352
-				continue;
353
-			}
354
-
355
-			$customer = getpaid_get_customer_by_user_id( $user_id );
356
-
357
-			// Create if not exists.
358
-			if ( empty( $customer ) ) {
359
-				$customer = new GetPaid_Customer( 0 );
360
-				$customer->clone_user( $user_id );
361
-				$customer->save();
362
-			}
363
-
364
-			$invoice->set_customer_id( $customer->get_id() );
365
-			$invoice->save();
366
-		}
367
-
368
-	}
369
-
370
-	/**
371
-	 * Migrates old invoices to new invoices.
372
-	 *
373
-	 */
374
-	public static function rename_gateways_label() {
375
-		global $wpdb;
376
-
377
-		foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
378
-
379
-			$wpdb->update(
380
-				$wpdb->prefix . 'getpaid_invoices',
381
-				array( 'gateway' => $gateway ),
382
-				array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
383
-				'%s',
384
-				'%s'
385
-			);
386
-
387
-		}
388
-	}
389
-
390
-	/**
391
-	 * Returns the DB schema.
392
-	 *
393
-	 */
394
-	public static function get_db_schema() {
395
-		global $wpdb;
396
-
397
-		if ( ! empty( self::$schema ) ) {
398
-			return self::$schema;
399
-		}
23
+    private static $schema = null;
24
+    private static $schema_version = null;
25
+
26
+    /**
27
+     * Upgrades the install.
28
+     *
29
+     * @param string $upgrade_from The current invoicing version.
30
+     */
31
+    public function upgrade_db( $upgrade_from ) {
32
+
33
+        // Save the current invoicing version.
34
+        update_option( 'wpinv_version', WPINV_VERSION );
35
+
36
+        // Setup the invoice Custom Post Type.
37
+        GetPaid_Post_Types::register_post_types();
38
+
39
+        // Clear the permalinks
40
+        flush_rewrite_rules();
41
+
42
+        // Maybe create new/missing pages.
43
+        $this->create_pages();
44
+
45
+        // Maybe re(add) admin capabilities.
46
+        $this->add_capabilities();
47
+
48
+        // Maybe create the default payment form.
49
+        wpinv_get_default_payment_form();
50
+
51
+        // Create any missing database tables.
52
+        $method = "upgrade_from_$upgrade_from";
53
+
54
+        $installed = get_option( 'gepaid_installed_on' );
55
+
56
+        if ( empty( $installed ) ) {
57
+            update_option( 'gepaid_installed_on', time() );
58
+        }
59
+
60
+        if ( method_exists( $this, $method ) ) {
61
+            $this->$method();
62
+        }
63
+
64
+    }
65
+
66
+    /**
67
+     * Do a fresh install.
68
+     *
69
+     */
70
+    public function upgrade_from_0() {
71
+
72
+        // Save default tax rates.
73
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
74
+    }
75
+
76
+    /**
77
+     * Upgrade to 0.0.5
78
+     *
79
+     */
80
+    public function upgrade_from_004() {
81
+        global $wpdb;
82
+
83
+        // Invoices.
84
+        $results = $wpdb->get_results( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
85
+        if ( ! empty( $results ) ) {
86
+            $wpdb->query( "UPDATE {$wpdb->posts} SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
87
+
88
+            // Clean post cache
89
+            foreach ( $results as $row ) {
90
+                clean_post_cache( $row->ID );
91
+            }
92
+        }
93
+
94
+        // Item meta key changes
95
+        $query = 'SELECT DISTINCT post_id FROM ' . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
96
+        $results = $wpdb->get_results( $query );
97
+
98
+        if ( ! empty( $results ) ) {
99
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
100
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
101
+            $wpdb->query( 'UPDATE ' . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
102
+
103
+            foreach ( $results as $row ) {
104
+                clean_post_cache( $row->post_id );
105
+            }
106
+        }
107
+
108
+        $this->upgrade_from_118();
109
+    }
110
+
111
+    /**
112
+     * Upgrade to version 2.0.0.
113
+     *
114
+     */
115
+    public function upgrade_from_118() {
116
+        $this->migrate_old_invoices();
117
+        $this->upgrade_from_279();
118
+    }
119
+
120
+    /**
121
+     * Upgrade to version 2.0.0.
122
+     *
123
+     */
124
+    public function upgrade_from_279() {
125
+        self::migrate_old_customers();
126
+    }
127
+
128
+    /**
129
+     * Give administrators the capability to manage GetPaid.
130
+     *
131
+     */
132
+    public function add_capabilities() {
133
+        $GLOBALS['wp_roles']->add_cap( 'administrator', 'manage_invoicing' );
134
+    }
135
+
136
+    /**
137
+     * Retreives GetPaid pages.
138
+     *
139
+     */
140
+    public static function get_pages( $filtered = false ) {
141
+        $gutenberg = getpaid_is_gutenberg();
142
+
143
+        return apply_filters(
144
+            'wpinv_create_pages',
145
+            array(
146
+                // Checkout page.
147
+                'checkout_page' => array(
148
+                    'name'    => _x( 'gp-checkout', 'Page slug', 'invoicing' ),
149
+                    'title'   => _x( 'Checkout', 'Page title', 'invoicing' ),
150
+                    'content' => getpaid_page_content_checkout( $filtered, $gutenberg ),
151
+                    'parent'  => ''
152
+                ),
153
+
154
+                // Invoice history page.
155
+                'invoice_history_page' => array(
156
+                    'name'    => _x( 'gp-invoices', 'Page slug', 'invoicing' ),
157
+                    'title'   => _x( 'My Invoices', 'Page title', 'invoicing' ),
158
+                    'content' => getpaid_page_content_invoice_history( $filtered, $gutenberg ),
159
+                    'parent'  => ''
160
+                ),
161
+
162
+                // Success page content.
163
+                'success_page' => array(
164
+                    'name'    => _x( 'gp-receipt', 'Page slug', 'invoicing' ),
165
+                    'title'   => _x( 'Payment Confirmation', 'Page title', 'invoicing' ),
166
+                    'content' => getpaid_page_content_receipt( $filtered, $gutenberg ),
167
+                    'parent'  => 'gp-checkout'
168
+                ),
169
+
170
+                // Failure page content.
171
+                'failure_page' => array(
172
+                    'name'    => _x( 'gp-transaction-failed', 'Page slug', 'invoicing' ),
173
+                    'title'   => _x( 'Transaction Failed', 'Page title', 'invoicing' ),
174
+                    'content' => getpaid_page_content_failure( $filtered, $gutenberg ),
175
+                    'parent'  => 'gp-checkout'
176
+                ),
177
+
178
+                // Subscriptions history page.
179
+                'invoice_subscription_page' => array(
180
+                    'name'    => _x( 'gp-subscriptions', 'Page slug', 'invoicing' ),
181
+                    'title'   => _x( 'My Subscriptions', 'Page title', 'invoicing' ),
182
+                    'content' => getpaid_page_content_subscriptions( $filtered, $gutenberg ),
183
+                    'parent'  => ''
184
+                )
185
+            )
186
+        );
187
+    }
188
+
189
+    /**
190
+     * Re-create GetPaid pages.
191
+     *
192
+     */
193
+    public function create_pages() {
194
+        foreach ( self::get_pages() as $key => $page ) {
195
+            wpinv_create_page( esc_sql( $page['name'] ), $key, $page['title'], $page['content'], $page['parent'] );
196
+        }
197
+
198
+    }
199
+
200
+    /**
201
+     * Migrates old invoices to new invoices.
202
+     *
203
+     */
204
+    public function migrate_old_invoices() {
205
+        global $wpdb;
206
+
207
+        $invoices_table      = $wpdb->prefix . 'getpaid_invoices';
208
+        $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
209
+        $migrated            = $wpdb->get_col( "SELECT post_id FROM $invoices_table" );
210
+        $invoices            = array_unique(
211
+            get_posts(
212
+                array(
213
+                    'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
214
+                    'posts_per_page' => -1,
215
+                    'fields'         => 'ids',
216
+                    'post_status'    => array_keys( get_post_stati() ),
217
+                    'exclude'        => (array) $migrated,
218
+                )
219
+            )
220
+        );
221
+
222
+        // Abort if we do not have any invoices.
223
+        if ( empty( $invoices ) ) {
224
+            return;
225
+        }
226
+
227
+        require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php';
228
+
229
+        $invoice_rows = array();
230
+        foreach ( $invoices as $invoice ) {
231
+
232
+            $invoice = new WPInv_Legacy_Invoice( $invoice );
233
+
234
+            if ( empty( $invoice->ID ) ) {
235
+                return;
236
+            }
237
+
238
+            $fields = array(
239
+                'post_id'            => $invoice->ID,
240
+                'number'             => $invoice->get_number(),
241
+                'key'                => $invoice->get_key(),
242
+                'type'               => str_replace( 'wpi_', '', $invoice->post_type ),
243
+                'mode'               => $invoice->mode,
244
+                'user_ip'            => $invoice->get_ip(),
245
+                'first_name'         => $invoice->get_first_name(),
246
+                'last_name'          => $invoice->get_last_name(),
247
+                'address'            => $invoice->get_address(),
248
+                'city'               => $invoice->city,
249
+                'state'              => $invoice->state,
250
+                'country'            => $invoice->country,
251
+                'zip'                => $invoice->zip,
252
+                'adddress_confirmed' => (int) $invoice->adddress_confirmed,
253
+                'gateway'            => $invoice->get_gateway(),
254
+                'transaction_id'     => $invoice->get_transaction_id(),
255
+                'currency'           => $invoice->get_currency(),
256
+                'subtotal'           => $invoice->get_subtotal(),
257
+                'tax'                => $invoice->get_tax(),
258
+                'fees_total'         => $invoice->get_fees_total(),
259
+                'total'              => $invoice->get_total(),
260
+                'discount'           => $invoice->get_discount(),
261
+                'discount_code'      => $invoice->get_discount_code(),
262
+                'disable_taxes'      => $invoice->disable_taxes,
263
+                'due_date'           => $invoice->get_due_date(),
264
+                'completed_date'     => $invoice->get_completed_date(),
265
+                'company'            => $invoice->company,
266
+                'vat_number'         => $invoice->vat_number,
267
+                'vat_rate'           => $invoice->vat_rate,
268
+                'custom_meta'        => $invoice->payment_meta,
269
+            );
270
+
271
+            foreach ( $fields as $key => $val ) {
272
+                if ( is_null( $val ) ) {
273
+                    $val = '';
274
+                }
275
+                $val = maybe_serialize( $val );
276
+                $fields[ $key ] = $wpdb->prepare( '%s', $val );
277
+            }
278
+
279
+            $fields = implode( ', ', $fields );
280
+            $invoice_rows[] = "($fields)";
281
+
282
+            $item_rows    = array();
283
+            $item_columns = array();
284
+            foreach ( $invoice->get_cart_details() as $details ) {
285
+                $fields = array(
286
+                    'post_id'          => $invoice->ID,
287
+                    'item_id'          => $details['id'],
288
+                    'item_name'        => $details['name'],
289
+                    'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
290
+                    'vat_rate'         => $details['vat_rate'],
291
+                    'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
292
+                    'tax'              => $details['tax'],
293
+                    'item_price'       => $details['item_price'],
294
+                    'custom_price'     => $details['custom_price'],
295
+                    'quantity'         => $details['quantity'],
296
+                    'discount'         => $details['discount'],
297
+                    'subtotal'         => $details['subtotal'],
298
+                    'price'            => $details['price'],
299
+                    'meta'             => $details['meta'],
300
+                    'fees'             => $details['fees'],
301
+                );
302
+
303
+                $item_columns = array_keys( $fields );
304
+
305
+                foreach ( $fields as $key => $val ) {
306
+                    if ( is_null( $val ) ) {
307
+                        $val = '';
308
+                    }
309
+                    $val = maybe_serialize( $val );
310
+                    $fields[ $key ] = $wpdb->prepare( '%s', $val );
311
+                }
312
+
313
+                $fields = implode( ', ', $fields );
314
+                $item_rows[] = "($fields)";
315
+            }
316
+
317
+            $item_rows    = implode( ', ', $item_rows );
318
+            $item_columns = implode( ', ', $item_columns );
319
+            $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
320
+        }
321
+
322
+        if ( empty( $invoice_rows ) ) {
323
+            return;
324
+        }
325
+
326
+        $invoice_rows = implode( ', ', $invoice_rows );
327
+        $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
328
+
329
+    }
330
+
331
+    /**
332
+     * Migrates old customers to new table.
333
+     *
334
+     */
335
+    public static function migrate_old_customers() {
336
+        global $wpdb;
337
+
338
+        // Fetch post_id from $wpdb->prefix . 'getpaid_invoices' where customer_id = 0 or null.
339
+        $invoice_ids = $wpdb->get_col( "SELECT post_id FROM {$wpdb->prefix}getpaid_invoices WHERE customer_id = 0 OR customer_id IS NULL" );
340
+
341
+        foreach ( $invoice_ids as $invoice_id ) {
342
+            $invoice = wpinv_get_invoice( $invoice_id );
343
+
344
+            if ( empty( $invoice ) ) {
345
+                continue;
346
+            }
347
+
348
+            // Fetch customer from the user ID.
349
+            $user_id = $invoice->get_user_id();
350
+
351
+            if ( empty( $user_id ) ) {
352
+                continue;
353
+            }
354
+
355
+            $customer = getpaid_get_customer_by_user_id( $user_id );
356
+
357
+            // Create if not exists.
358
+            if ( empty( $customer ) ) {
359
+                $customer = new GetPaid_Customer( 0 );
360
+                $customer->clone_user( $user_id );
361
+                $customer->save();
362
+            }
363
+
364
+            $invoice->set_customer_id( $customer->get_id() );
365
+            $invoice->save();
366
+        }
367
+
368
+    }
369
+
370
+    /**
371
+     * Migrates old invoices to new invoices.
372
+     *
373
+     */
374
+    public static function rename_gateways_label() {
375
+        global $wpdb;
376
+
377
+        foreach ( array_keys( wpinv_get_payment_gateways() ) as $gateway ) {
378
+
379
+            $wpdb->update(
380
+                $wpdb->prefix . 'getpaid_invoices',
381
+                array( 'gateway' => $gateway ),
382
+                array( 'gateway' => wpinv_get_gateway_admin_label( $gateway ) ),
383
+                '%s',
384
+                '%s'
385
+            );
386
+
387
+        }
388
+    }
389
+
390
+    /**
391
+     * Returns the DB schema.
392
+     *
393
+     */
394
+    public static function get_db_schema() {
395
+        global $wpdb;
396
+
397
+        if ( ! empty( self::$schema ) ) {
398
+            return self::$schema;
399
+        }
400 400
 
401
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
401
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
402 402
 
403
-		$charset_collate = $wpdb->get_charset_collate();
403
+        $charset_collate = $wpdb->get_charset_collate();
404 404
 
405
-		$schema = array();
405
+        $schema = array();
406 406
 
407
-		// Subscriptions.
408
-		$schema['subscriptions'] = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
407
+        // Subscriptions.
408
+        $schema['subscriptions'] = "CREATE TABLE {$wpdb->prefix}wpinv_subscriptions (
409 409
 			id bigint(20) unsigned NOT NULL auto_increment,
410 410
 			customer_id bigint(20) NOT NULL,
411 411
 			frequency int(11) NOT NULL DEFAULT '1',
@@ -428,8 +428,8 @@  discard block
 block discarded – undo
428 428
 			KEY customer_and_status (customer_id, status)
429 429
 		  ) $charset_collate;";
430 430
 
431
-		// Invoices.
432
-		$schema['invoices'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
431
+        // Invoices.
432
+        $schema['invoices'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoices (
433 433
 			post_id BIGINT(20) NOT NULL,
434 434
 			customer_id BIGINT(20) NOT NULL DEFAULT 0,
435 435
             `number` VARCHAR(100),
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 			KEY invoice_key (invoice_key)
468 468
 		  ) $charset_collate;";
469 469
 
470
-		// Invoice items.
471
-		$schema['items'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
470
+        // Invoice items.
471
+        $schema['items'] = "CREATE TABLE {$wpdb->prefix}getpaid_invoice_items (
472 472
 			ID BIGINT(20) NOT NULL AUTO_INCREMENT,
473 473
             post_id BIGINT(20) NOT NULL,
474 474
             item_id BIGINT(20) NOT NULL,
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 			KEY post_id (post_id)
491 491
 		  ) $charset_collate;";
492 492
 
493
-		// Customers.
494
-		$schema['customers'] = "CREATE TABLE {$wpdb->prefix}getpaid_customers (
493
+        // Customers.
494
+        $schema['customers'] = "CREATE TABLE {$wpdb->prefix}getpaid_customers (
495 495
 			id BIGINT(20) NOT NULL AUTO_INCREMENT,
496 496
 			user_id BIGINT(20) NOT NULL,
497 497
 			email VARCHAR(100) NOT NULL,
@@ -501,38 +501,38 @@  discard block
 block discarded – undo
501 501
 			purchase_count BIGINT(20) NOT NULL DEFAULT 0,
502 502
 			";
503 503
 
504
-		// Add address fields.
505
-		foreach ( array_keys( getpaid_user_address_fields( true ) ) as $field ) {
506
-			// Skip id, user_id and email.
507
-			if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
508
-				continue;
509
-			}
510
-
511
-			$field   = sanitize_key( $field );
512
-			$length  = 100;
513
-			$default = '';
514
-
515
-			// Country.
516
-			if ( 'country' === $field ) {
517
-				$length  = 2;
518
-				$default = wpinv_get_default_country();
519
-			}
520
-
521
-			// State.
522
-			if ( 'state' === $field ) {
523
-				$default = wpinv_get_default_state();
524
-			}
525
-
526
-			// Phone, zip.
527
-			if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
528
-				$length = 20;
529
-			}
530
-
531
-			$schema['customers'] .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',
504
+        // Add address fields.
505
+        foreach ( array_keys( getpaid_user_address_fields( true ) ) as $field ) {
506
+            // Skip id, user_id and email.
507
+            if ( in_array( $field, array( 'id', 'user_id', 'email', 'purchase_value', 'purchase_count', 'date_created', 'date_modified', 'uuid' ), true ) ) {
508
+                continue;
509
+            }
510
+
511
+            $field   = sanitize_key( $field );
512
+            $length  = 100;
513
+            $default = '';
514
+
515
+            // Country.
516
+            if ( 'country' === $field ) {
517
+                $length  = 2;
518
+                $default = wpinv_get_default_country();
519
+            }
520
+
521
+            // State.
522
+            if ( 'state' === $field ) {
523
+                $default = wpinv_get_default_state();
524
+            }
525
+
526
+            // Phone, zip.
527
+            if ( in_array( $field, array( 'phone', 'zip' ), true ) ) {
528
+                $length = 20;
529
+            }
530
+
531
+            $schema['customers'] .= "`$field` VARCHAR($length) NOT NULL DEFAULT '$default',
532 532
 			";
533
-		}
533
+        }
534 534
 
535
-		$schema['customers'] .= "date_created DATETIME NOT NULL,
535
+        $schema['customers'] .= "date_created DATETIME NOT NULL,
536 536
 			date_modified DATETIME NOT NULL,
537 537
 			uuid VARCHAR(100) NOT NULL,
538 538
 			is_anonymized INT(2) NOT NULL DEFAULT 0,
@@ -542,8 +542,8 @@  discard block
 block discarded – undo
542 542
 			KEY email (email)
543 543
 		  ) $charset_collate;";
544 544
 
545
-		// Customer meta.
546
-		$schema['customer_meta'] = "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
545
+        // Customer meta.
546
+        $schema['customer_meta'] = "CREATE TABLE {$wpdb->prefix}getpaid_customer_meta (
547 547
 			meta_id BIGINT(20) NOT NULL AUTO_INCREMENT,
548 548
 			customer_id BIGINT(20) NOT NULL,
549 549
 			meta_key VARCHAR(255) NOT NULL,
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 			KEY meta_key (meta_key(191))
554 554
 		  ) $charset_collate;";
555 555
 
556
-		// Anonymization Logs.
557
-		$schema['anonymization_logs'] = "CREATE TABLE {$wpdb->prefix}getpaid_anonymization_logs (
556
+        // Anonymization Logs.
557
+        $schema['anonymization_logs'] = "CREATE TABLE {$wpdb->prefix}getpaid_anonymization_logs (
558 558
 			log_id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
559 559
 			user_id BIGINT(20) UNSIGNED NOT NULL,
560 560
 			action VARCHAR(50) NOT NULL,
@@ -568,75 +568,75 @@  discard block
 block discarded – undo
568 568
 			KEY timestamp (timestamp)
569 569
 		) $charset_collate;";
570 570
 
571
-		// Filter.
572
-		$schema = apply_filters( 'getpaid_db_schema', $schema );
573
-
574
-		self::$schema         = implode( "\n", array_values( $schema ) );
575
-		self::$schema_version = md5( sanitize_key( self::$schema ) );
576
-
577
-		return self::$schema;
578
-	}
579
-
580
-	/**
581
-	 * Returns the DB schema version.
582
-	 *
583
-	 */
584
-	public static function get_db_schema_version() {
585
-		if ( ! empty( self::$schema_version ) ) {
586
-			return self::$schema_version;
587
-		}
588
-
589
-		self::get_db_schema();
590
-
591
-		return self::$schema_version;
592
-	}
593
-
594
-	/**
595
-	 * Checks if the db schema is up to date.
596
-	 *
597
-	 * @return bool
598
-	 */
599
-	public static function is_db_schema_up_to_date() {
600
-		return self::get_db_schema_version() === get_option( 'getpaid_db_schema' );
601
-	}
602
-
603
-	/**
604
-	 * Set up the database tables which the plugin needs to function.
605
-	 */
606
-	public static function create_db_tables() {
607
-		global $wpdb;
608
-
609
-		$wpdb->hide_errors();
610
-
611
-		require_once ABSPATH . 'wp-admin/includes/upgrade.php';
612
-
613
-		$schema = self::get_db_schema();
614
-
615
-		// If invoices table exists, rename key to invoice_key.
616
-		$invoices_table = "{$wpdb->prefix}getpaid_invoices";
617
-
618
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
619
-			$fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
620
-
621
-			foreach ( $fields as $field ) {
622
-				if ( 'key' === $field->Field ) {
623
-					$wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
624
-					break;
625
-				}
626
-			}
627
-		}
628
-
629
-		dbDelta( $schema );
630
-		wp_cache_flush();
631
-		update_option( 'getpaid_db_schema', self::get_db_schema_version() );
632
-	}
633
-
634
-	/**
635
-	 * Creates tables if schema is not up to date.
636
-	 */
637
-	public static function maybe_create_db_tables() {
638
-		if ( ! self::is_db_schema_up_to_date() ) {
639
-			self::create_db_tables();
640
-		}
641
-	}
571
+        // Filter.
572
+        $schema = apply_filters( 'getpaid_db_schema', $schema );
573
+
574
+        self::$schema         = implode( "\n", array_values( $schema ) );
575
+        self::$schema_version = md5( sanitize_key( self::$schema ) );
576
+
577
+        return self::$schema;
578
+    }
579
+
580
+    /**
581
+     * Returns the DB schema version.
582
+     *
583
+     */
584
+    public static function get_db_schema_version() {
585
+        if ( ! empty( self::$schema_version ) ) {
586
+            return self::$schema_version;
587
+        }
588
+
589
+        self::get_db_schema();
590
+
591
+        return self::$schema_version;
592
+    }
593
+
594
+    /**
595
+     * Checks if the db schema is up to date.
596
+     *
597
+     * @return bool
598
+     */
599
+    public static function is_db_schema_up_to_date() {
600
+        return self::get_db_schema_version() === get_option( 'getpaid_db_schema' );
601
+    }
602
+
603
+    /**
604
+     * Set up the database tables which the plugin needs to function.
605
+     */
606
+    public static function create_db_tables() {
607
+        global $wpdb;
608
+
609
+        $wpdb->hide_errors();
610
+
611
+        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
612
+
613
+        $schema = self::get_db_schema();
614
+
615
+        // If invoices table exists, rename key to invoice_key.
616
+        $invoices_table = "{$wpdb->prefix}getpaid_invoices";
617
+
618
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) === $invoices_table ) {
619
+            $fields = $wpdb->get_results( "SHOW COLUMNS FROM {$wpdb->prefix}getpaid_invoices" );
620
+
621
+            foreach ( $fields as $field ) {
622
+                if ( 'key' === $field->Field ) {
623
+                    $wpdb->query( "ALTER TABLE {$wpdb->prefix}getpaid_invoices CHANGE `key` `invoice_key` VARCHAR(100)" );
624
+                    break;
625
+                }
626
+            }
627
+        }
628
+
629
+        dbDelta( $schema );
630
+        wp_cache_flush();
631
+        update_option( 'getpaid_db_schema', self::get_db_schema_version() );
632
+    }
633
+
634
+    /**
635
+     * Creates tables if schema is not up to date.
636
+     */
637
+    public static function maybe_create_db_tables() {
638
+        if ( ! self::is_db_schema_up_to_date() ) {
639
+            self::create_db_tables();
640
+        }
641
+    }
642 642
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +848 added lines, -848 removed lines patch added patch discarded remove patch
@@ -13,755 +13,755 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-			$actions['reset'] = sprintf(
131
-				'<a href="%1$s" style="color: #800">%2$s</a>',
132
-				esc_url(
133
-					wp_nonce_url(
134
-						add_query_arg(
135
-							array(
136
-								'getpaid-admin-action' => 'reset_form_stats',
137
-								'form_id'              => $post->ID,
138
-							)
139
-						),
140
-						'getpaid-nonce',
141
-						'getpaid-nonce'
142
-					)
143
-				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
145
-			);
146
-		}
147
-
148
-		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
-				$actions['buy'] = sprintf(
152
-					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
155
-				);
156
-			}
157
-		}
158
-
159
-		return $actions;
160
-	}
161
-
162
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( wpinv_get_default_payment_form() === $post->ID ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+            $actions['reset'] = sprintf(
131
+                '<a href="%1$s" style="color: #800">%2$s</a>',
132
+                esc_url(
133
+                    wp_nonce_url(
134
+                        add_query_arg(
135
+                            array(
136
+                                'getpaid-admin-action' => 'reset_form_stats',
137
+                                'form_id'              => $post->ID,
138
+                            )
139
+                        ),
140
+                        'getpaid-nonce',
141
+                        'getpaid-nonce'
142
+                    )
143
+                ),
144
+                esc_html( __( 'Reset Stats', 'invoicing' ) )
145
+            );
146
+        }
147
+
148
+        // Link to item payment form.
149
+        if ( 'wpi_item' == $post->post_type ) {
150
+            if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
+                $actions['buy'] = sprintf(
152
+                    '<a href="%1$s">%2$s</a>',
153
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
+                    esc_html( __( 'Buy', 'invoicing' ) )
155
+                );
156
+            }
157
+        }
158
+
159
+        return $actions;
160
+    }
161
+
162
+    /**
163 163
      * Remove bulk edit option from admin side quote listing
164 164
      *
165 165
      * @since    1.0.0
166 166
      * @param array $actions post actions
167
-	 * @param WP_Post $post
167
+     * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170 170
     public static function filter_invoice_row_actions( $actions, $post ) {
171 171
 
172 172
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
173 173
 
174
-			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
176
-
177
-			$actions['edit'] = sprintf(
178
-				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
181
-			);
182
-
183
-			if ( ! $invoice->is_draft() ) {
184
-
185
-				$actions['view'] = sprintf(
186
-					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
188
-					sprintf(
189
-						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
-					)
193
-				);
194
-
195
-				$actions['send'] = sprintf(
196
-					'<a href="%1$s">%2$s</a>',
197
-					esc_url(
198
-						wp_nonce_url(
199
-							add_query_arg(
200
-								array(
201
-									'getpaid-admin-action' => 'send_invoice',
202
-									'invoice_id'           => $invoice->get_id(),
203
-								)
204
-							),
205
-							'getpaid-nonce',
206
-							'getpaid-nonce'
207
-						)
208
-					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
210
-				);
211
-
212
-			}
213
-
214
-			$actions['duplicate'] = sprintf(
215
-				'<a href="%1$s">%2$s</a>',
216
-				esc_url(
217
-					wp_nonce_url(
218
-						add_query_arg(
219
-							array(
220
-								'getpaid-admin-action' => 'duplicate_invoice',
221
-								'invoice_id'           => $post->ID,
222
-							)
223
-						),
224
-						'getpaid-nonce',
225
-						'getpaid-nonce'
226
-					)
227
-				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
229
-			);
174
+            $actions = array();
175
+            $invoice = new WPInv_Invoice( $post );
176
+
177
+            $actions['edit'] = sprintf(
178
+                '<a href="%1$s">%2$s</a>',
179
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
+                esc_html( __( 'Edit', 'invoicing' ) )
181
+            );
182
+
183
+            if ( ! $invoice->is_draft() ) {
184
+
185
+                $actions['view'] = sprintf(
186
+                    '<a href="%1$s">%2$s</a>',
187
+                    esc_url( $invoice->get_view_url() ),
188
+                    sprintf(
189
+                        // translators: %s is the invoice type
190
+                        esc_html__( 'View %s', 'invoicing' ),
191
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
+                    )
193
+                );
194
+
195
+                $actions['send'] = sprintf(
196
+                    '<a href="%1$s">%2$s</a>',
197
+                    esc_url(
198
+                        wp_nonce_url(
199
+                            add_query_arg(
200
+                                array(
201
+                                    'getpaid-admin-action' => 'send_invoice',
202
+                                    'invoice_id'           => $invoice->get_id(),
203
+                                )
204
+                            ),
205
+                            'getpaid-nonce',
206
+                            'getpaid-nonce'
207
+                        )
208
+                    ),
209
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
210
+                );
211
+
212
+            }
213
+
214
+            $actions['duplicate'] = sprintf(
215
+                '<a href="%1$s">%2$s</a>',
216
+                esc_url(
217
+                    wp_nonce_url(
218
+                        add_query_arg(
219
+                            array(
220
+                                'getpaid-admin-action' => 'duplicate_invoice',
221
+                                'invoice_id'           => $post->ID,
222
+                            )
223
+                        ),
224
+                        'getpaid-nonce',
225
+                        'getpaid-nonce'
226
+                    )
227
+                ),
228
+                esc_html( __( 'Duplicate', 'invoicing' ) )
229
+            );
230 230
 
231 231
         }
232 232
 
233 233
         return $actions;
234
-	}
235
-
236
-	/**
237
-	 * Returns an array of invoice table columns.
238
-	 */
239
-	public static function invoice_columns( $columns ) {
240
-
241
-		$columns = array(
242
-			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
250
-		);
251
-
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
253
-	}
254
-
255
-	/**
256
-	 * Displays invoice table columns.
257
-	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
259
-
260
-		$invoice = new WPInv_Invoice( $post_id );
261
-
262
-		switch ( $column_name ) {
263
-
264
-			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
-				break;
269
-
270
-			case 'payment_date':
271
-				if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
-
276
-					if ( $_gateway = $invoice->get_gateway() ) {
277
-						$gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
-
279
-						if ( $transaction_url = $invoice->get_transaction_url() ) {
280
-							$gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
-						}
282
-
283
-						$gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
-					} else {
285
-						$gateway = '';
286
-					}
287
-
288
-					$gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
-
290
-					if ( $gateway ) {
291
-						echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
-					}
293
-				} else {
294
-					echo '&mdash;';
295
-				}
296
-
297
-				break;
298
-
299
-			case 'amount':
300
-				$amount = $invoice->get_total();
301
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
-
303
-				if ( $invoice->is_refunded() ) {
304
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
-				} else {
307
-
308
-					$discount = $invoice->get_total_discount();
309
-
310
-					if ( ! empty( $discount ) ) {
311
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
-					} else {
314
-						echo wp_kses_post( $formated_amount );
315
-					}
316
-				}
317
-
318
-				break;
319
-
320
-			case 'status':
321
-				$status = esc_html( $invoice->get_status() );
322
-
323
-				// If it is paid, show the gateway title.
324
-				if ( $invoice->is_paid() ) {
325
-					$gateway = esc_html( $invoice->get_gateway_title() );
326
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
327
-
328
-					echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
329
-				} else {
330
-					echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
331
-				}
332
-
333
-				// If it is not paid, display the overdue and view status.
334
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
335
-
336
-					// Invoice view status.
337
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
338
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
339
-					} else {
340
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
341
-					}
342
-
343
-					// Display the overview status.
344
-					if ( wpinv_get_option( 'overdue_active' ) ) {
345
-						$due_date = $invoice->get_due_date();
346
-						$fomatted = getpaid_format_date( $due_date );
347
-
348
-						if ( ! empty( $fomatted ) ) {
349
-							$date = wp_sprintf(
350
-								// translators: %s is the due date.
351
-								__( 'Due %s', 'invoicing' ),
352
-								$fomatted
353
-							);
354
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
355
-						}
356
-					}
357
-				}
358
-
359
-				break;
360
-
361
-			case 'recurring':
362
-				if ( $invoice->is_recurring() ) {
363
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
364
-				} else {
365
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
366
-				}
367
-				break;
368
-
369
-			case 'number':
370
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
371
-				$invoice_number  = esc_html( $invoice->get_number() );
372
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
373
-
374
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
375
-
376
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
377
-				break;
378
-
379
-			case 'customer':
380
-				$customer_name = $invoice->get_user_full_name();
381
-
382
-				if ( empty( $customer_name ) ) {
383
-					$customer_name = $invoice->get_email();
384
-				}
385
-
386
-				if ( ! empty( $customer_name ) ) {
387
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
388
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
389
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
390
-				} else {
391
-					echo '<div>&mdash;</div>';
392
-				}
393
-
394
-				break;
395
-
396
-		}
397
-
398
-	}
399
-
400
-	/**
401
-	 * Displays invoice bulk actions.
402
-	 */
403
-	public static function invoice_bulk_actions( $actions ) {
404
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
405
-		return $actions;
406
-	}
407
-
408
-	/**
409
-	 * Processes invoice bulk actions.
410
-	 */
411
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
412
-
413
-		if ( 'resend-invoice' === $action ) {
414
-			foreach ( $post_ids as $post_id ) {
415
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
416
-			}
417
-		}
418
-
419
-		return $redirect_url;
420
-
421
-	}
422
-
423
-	/**
424
-	 * Returns an array of payment forms table columns.
425
-	 */
426
-	public static function payment_form_columns( $columns ) {
427
-
428
-		$columns = array(
429
-			'cb'        => $columns['cb'],
430
-			'title'     => __( 'Name', 'invoicing' ),
431
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
432
-			'earnings'  => __( 'Revenue', 'invoicing' ),
433
-			'refunds'   => __( 'Refunded', 'invoicing' ),
434
-			'items'     => __( 'Items', 'invoicing' ),
435
-			'date'      => __( 'Date', 'invoicing' ),
436
-		);
437
-
438
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
439
-
440
-	}
441
-
442
-	/**
443
-	 * Displays payment form table columns.
444
-	 */
445
-	public static function display_payment_form_columns( $column_name, $post_id ) {
446
-
447
-		// Retrieve the payment form.
448
-		$form = new GetPaid_Payment_Form( $post_id );
449
-
450
-		switch ( $column_name ) {
451
-
452
-			case 'earnings':
453
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
454
-				break;
455
-
456
-			case 'refunds':
457
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
458
-				break;
459
-
460
-			case 'refunds':
461
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
462
-				break;
463
-
464
-			case 'shortcode':
465
-				if ( $form->is_default() ) {
466
-					echo '&mdash;';
467
-				} else {
468
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
469
-				}
470
-
471
-				break;
234
+    }
235
+
236
+    /**
237
+     * Returns an array of invoice table columns.
238
+     */
239
+    public static function invoice_columns( $columns ) {
240
+
241
+        $columns = array(
242
+            'cb'           => $columns['cb'],
243
+            'number'       => __( 'Invoice', 'invoicing' ),
244
+            'customer'     => __( 'Customer', 'invoicing' ),
245
+            'invoice_date' => __( 'Created', 'invoicing' ),
246
+            'payment_date' => __( 'Completed', 'invoicing' ),
247
+            'amount'       => __( 'Amount', 'invoicing' ),
248
+            'recurring'    => __( 'Recurring', 'invoicing' ),
249
+            'status'       => __( 'Status', 'invoicing' ),
250
+        );
251
+
252
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
253
+    }
254
+
255
+    /**
256
+     * Displays invoice table columns.
257
+     */
258
+    public static function display_invoice_columns( $column_name, $post_id ) {
259
+
260
+        $invoice = new WPInv_Invoice( $post_id );
261
+
262
+        switch ( $column_name ) {
263
+
264
+            case 'invoice_date':
265
+                $date_time = esc_attr( $invoice->get_created_date() );
266
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
+                break;
269
+
270
+            case 'payment_date':
271
+                if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
+                    $date_time = esc_attr( $invoice->get_completed_date() );
273
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
+
276
+                    if ( $_gateway = $invoice->get_gateway() ) {
277
+                        $gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
+
279
+                        if ( $transaction_url = $invoice->get_transaction_url() ) {
280
+                            $gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
+                        }
282
+
283
+                        $gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
+                    } else {
285
+                        $gateway = '';
286
+                    }
287
+
288
+                    $gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
+
290
+                    if ( $gateway ) {
291
+                        echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
+                    }
293
+                } else {
294
+                    echo '&mdash;';
295
+                }
296
+
297
+                break;
298
+
299
+            case 'amount':
300
+                $amount = $invoice->get_total();
301
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
+
303
+                if ( $invoice->is_refunded() ) {
304
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
+                } else {
307
+
308
+                    $discount = $invoice->get_total_discount();
309
+
310
+                    if ( ! empty( $discount ) ) {
311
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
+                    } else {
314
+                        echo wp_kses_post( $formated_amount );
315
+                    }
316
+                }
317
+
318
+                break;
319
+
320
+            case 'status':
321
+                $status = esc_html( $invoice->get_status() );
322
+
323
+                // If it is paid, show the gateway title.
324
+                if ( $invoice->is_paid() ) {
325
+                    $gateway = esc_html( $invoice->get_gateway_title() );
326
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
327
+
328
+                    echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
329
+                } else {
330
+                    echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
331
+                }
332
+
333
+                // If it is not paid, display the overdue and view status.
334
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
335
+
336
+                    // Invoice view status.
337
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
338
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
339
+                    } else {
340
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
341
+                    }
342
+
343
+                    // Display the overview status.
344
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
345
+                        $due_date = $invoice->get_due_date();
346
+                        $fomatted = getpaid_format_date( $due_date );
347
+
348
+                        if ( ! empty( $fomatted ) ) {
349
+                            $date = wp_sprintf(
350
+                                // translators: %s is the due date.
351
+                                __( 'Due %s', 'invoicing' ),
352
+                                $fomatted
353
+                            );
354
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
355
+                        }
356
+                    }
357
+                }
358
+
359
+                break;
360
+
361
+            case 'recurring':
362
+                if ( $invoice->is_recurring() ) {
363
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
364
+                } else {
365
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
366
+                }
367
+                break;
368
+
369
+            case 'number':
370
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
371
+                $invoice_number  = esc_html( $invoice->get_number() );
372
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
373
+
374
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
375
+
376
+                do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
377
+                break;
378
+
379
+            case 'customer':
380
+                $customer_name = $invoice->get_user_full_name();
381
+
382
+                if ( empty( $customer_name ) ) {
383
+                    $customer_name = $invoice->get_email();
384
+                }
385
+
386
+                if ( ! empty( $customer_name ) ) {
387
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
388
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
389
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
390
+                } else {
391
+                    echo '<div>&mdash;</div>';
392
+                }
393
+
394
+                break;
395
+
396
+        }
397
+
398
+    }
399
+
400
+    /**
401
+     * Displays invoice bulk actions.
402
+     */
403
+    public static function invoice_bulk_actions( $actions ) {
404
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
405
+        return $actions;
406
+    }
407
+
408
+    /**
409
+     * Processes invoice bulk actions.
410
+     */
411
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
412
+
413
+        if ( 'resend-invoice' === $action ) {
414
+            foreach ( $post_ids as $post_id ) {
415
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
416
+            }
417
+        }
418
+
419
+        return $redirect_url;
420
+
421
+    }
422
+
423
+    /**
424
+     * Returns an array of payment forms table columns.
425
+     */
426
+    public static function payment_form_columns( $columns ) {
427
+
428
+        $columns = array(
429
+            'cb'        => $columns['cb'],
430
+            'title'     => __( 'Name', 'invoicing' ),
431
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
432
+            'earnings'  => __( 'Revenue', 'invoicing' ),
433
+            'refunds'   => __( 'Refunded', 'invoicing' ),
434
+            'items'     => __( 'Items', 'invoicing' ),
435
+            'date'      => __( 'Date', 'invoicing' ),
436
+        );
437
+
438
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
439
+
440
+    }
441
+
442
+    /**
443
+     * Displays payment form table columns.
444
+     */
445
+    public static function display_payment_form_columns( $column_name, $post_id ) {
446
+
447
+        // Retrieve the payment form.
448
+        $form = new GetPaid_Payment_Form( $post_id );
449
+
450
+        switch ( $column_name ) {
451
+
452
+            case 'earnings':
453
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
454
+                break;
455
+
456
+            case 'refunds':
457
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
458
+                break;
459
+
460
+            case 'refunds':
461
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
462
+                break;
463
+
464
+            case 'shortcode':
465
+                if ( $form->is_default() ) {
466
+                    echo '&mdash;';
467
+                } else {
468
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
469
+                }
470
+
471
+                break;
472
+
473
+            case 'items':
474
+                $items = $form->get_items();
475
+
476
+                if ( $form->is_default() || empty( $items ) ) {
477
+                    echo '&mdash;';
478
+                    return;
479
+                }
472 480
 
473
-			case 'items':
474
-				$items = $form->get_items();
475
-
476
-				if ( $form->is_default() || empty( $items ) ) {
477
-					echo '&mdash;';
478
-					return;
479
-				}
480
-
481
-				$_items = array();
482
-
483
-				foreach ( $items as $item ) {
484
-					$url = $item->get_edit_url();
485
-
486
-					if ( empty( $url ) ) {
487
-						$_items[] = esc_html( $item->get_name() );
488
-					} else {
489
-						$_items[] = sprintf(
490
-							'<a href="%s">%s</a>',
491
-							esc_url( $url ),
492
-							esc_html( $item->get_name() )
493
-						);
494
-					}
481
+                $_items = array();
482
+
483
+                foreach ( $items as $item ) {
484
+                    $url = $item->get_edit_url();
485
+
486
+                    if ( empty( $url ) ) {
487
+                        $_items[] = esc_html( $item->get_name() );
488
+                    } else {
489
+                        $_items[] = sprintf(
490
+                            '<a href="%s">%s</a>',
491
+                            esc_url( $url ),
492
+                            esc_html( $item->get_name() )
493
+                        );
494
+                    }
495 495
 }
496 496
 
497
-				echo wp_kses_post( implode( '<br>', $_items ) );
497
+                echo wp_kses_post( implode( '<br>', $_items ) );
498 498
 
499
-				break;
499
+                break;
500 500
 
501
-		}
501
+        }
502 502
 
503
-	}
503
+    }
504 504
 
505
-	/**
506
-	 * Filters post states.
507
-	 */
508
-	public static function filter_payment_form_state( $post_states, $post ) {
505
+    /**
506
+     * Filters post states.
507
+     */
508
+    public static function filter_payment_form_state( $post_states, $post ) {
509 509
 
510
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
511
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
512
-		}
510
+        if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
511
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
512
+        }
513 513
 
514
-		return $post_states;
514
+        return $post_states;
515 515
 
516
-	}
516
+    }
517 517
 
518
-	/**
519
-	 * Returns an array of coupon table columns.
520
-	 */
521
-	public static function discount_columns( $columns ) {
518
+    /**
519
+     * Returns an array of coupon table columns.
520
+     */
521
+    public static function discount_columns( $columns ) {
522
+
523
+        $columns = array(
524
+            'cb'          => $columns['cb'],
525
+            'title'       => __( 'Name', 'invoicing' ),
526
+            'code'        => __( 'Code', 'invoicing' ),
527
+            'amount'      => __( 'Amount', 'invoicing' ),
528
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
529
+            'start_date'  => __( 'Start Date', 'invoicing' ),
530
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
531
+        );
532
+
533
+        return apply_filters( 'wpi_discount_table_columns', $columns );
534
+    }
522 535
 
523
-		$columns = array(
524
-			'cb'          => $columns['cb'],
525
-			'title'       => __( 'Name', 'invoicing' ),
526
-			'code'        => __( 'Code', 'invoicing' ),
527
-			'amount'      => __( 'Amount', 'invoicing' ),
528
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
529
-			'start_date'  => __( 'Start Date', 'invoicing' ),
530
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
531
-		);
536
+    /**
537
+     * Filters post states.
538
+     */
539
+    public static function filter_discount_state( $post_states, $post ) {
532 540
 
533
-		return apply_filters( 'wpi_discount_table_columns', $columns );
534
-	}
541
+        if ( 'wpi_discount' === $post->post_type ) {
535 542
 
536
-	/**
537
-	 * Filters post states.
538
-	 */
539
-	public static function filter_discount_state( $post_states, $post ) {
543
+            $discount = new WPInv_Discount( $post );
540 544
 
541
-		if ( 'wpi_discount' === $post->post_type ) {
545
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
542 546
 
543
-			$discount = new WPInv_Discount( $post );
547
+            if ( 'publish' !== $status ) {
548
+                return array(
549
+                    'discount_status' => wpinv_discount_status( $status ),
550
+                );
551
+            }
544 552
 
545
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
553
+            return array();
546 554
 
547
-			if ( 'publish' !== $status ) {
548
-				return array(
549
-					'discount_status' => wpinv_discount_status( $status ),
550
-				);
551
-			}
555
+        }
552 556
 
553
-			return array();
557
+        return $post_states;
554 558
 
555
-		}
559
+    }
556 560
 
557
-		return $post_states;
561
+    /**
562
+     * Returns an array of items table columns.
563
+     */
564
+    public static function item_columns( $columns ) {
565
+
566
+        $columns = array(
567
+            'cb'        => $columns['cb'],
568
+            'title'     => __( 'Name', 'invoicing' ),
569
+            'price'     => __( 'Price', 'invoicing' ),
570
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
571
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
572
+            'type'      => __( 'Type', 'invoicing' ),
573
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
574
+        );
575
+
576
+        if ( ! wpinv_use_taxes() ) {
577
+            unset( $columns['vat_rule'] );
578
+            unset( $columns['vat_class'] );
579
+        }
558 580
 
559
-	}
581
+        return apply_filters( 'wpi_item_table_columns', $columns );
582
+    }
560 583
 
561
-	/**
562
-	 * Returns an array of items table columns.
563
-	 */
564
-	public static function item_columns( $columns ) {
584
+    /**
585
+     * Returns an array of sortable items table columns.
586
+     */
587
+    public static function sortable_item_columns( $columns ) {
588
+
589
+        return array_merge(
590
+            $columns,
591
+            array(
592
+                'price'     => 'price',
593
+                'vat_rule'  => 'vat_rule',
594
+                'vat_class' => 'vat_class',
595
+                'type'      => 'type',
596
+            )
597
+        );
565 598
 
566
-		$columns = array(
567
-			'cb'        => $columns['cb'],
568
-			'title'     => __( 'Name', 'invoicing' ),
569
-			'price'     => __( 'Price', 'invoicing' ),
570
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
571
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
572
-			'type'      => __( 'Type', 'invoicing' ),
573
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
574
-		);
599
+    }
575 600
 
576
-		if ( ! wpinv_use_taxes() ) {
577
-			unset( $columns['vat_rule'] );
578
-			unset( $columns['vat_class'] );
579
-		}
601
+    /**
602
+     * Displays items table columns.
603
+     */
604
+    public static function display_item_columns( $column_name, $post_id ) {
605
+
606
+        $item = new WPInv_Item( $post_id );
607
+
608
+        switch ( $column_name ) {
609
+
610
+            case 'price':
611
+                if ( ! $item->is_recurring() ) {
612
+                    echo wp_kses_post( $item->get_the_price() );
613
+                    break;
614
+                }
615
+
616
+                $price = wp_sprintf(
617
+                    __( '%1$s / %2$s', 'invoicing' ),
618
+                    $item->get_the_price(),
619
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
620
+                );
621
+
622
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
623
+                    echo wp_kses_post( $price );
624
+                    break;
625
+                }
626
+
627
+                echo wp_kses_post( $item->get_the_initial_price() );
628
+
629
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
630
+                break;
631
+
632
+            case 'vat_rule':
633
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
634
+                break;
635
+
636
+            case 'vat_class':
637
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
638
+                break;
639
+
640
+            case 'shortcode':
641
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
642
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
643
+                } else {
644
+                    echo '&mdash;';
645
+                }
646
+
647
+                break;
648
+
649
+            case 'type':
650
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
651
+                break;
652
+
653
+        }
654
+
655
+    }
656
+
657
+    /**
658
+     * Lets users filter items using taxes.
659
+     */
660
+    public static function add_item_filters( $post_type ) {
661
+
662
+        // Abort if we're not dealing with items.
663
+        if ( 'wpi_item' !== $post_type ) {
664
+            return;
665
+        }
666
+
667
+        // Filter by vat rules.
668
+        if ( wpinv_use_taxes() ) {
669
+
670
+            // Sanitize selected vat rule.
671
+            $vat_rule   = '';
672
+            $vat_rules  = getpaid_get_tax_rules();
673
+            if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
+            }
676
+
677
+            // Filter by VAT rule.
678
+            wpinv_html_select(
679
+                array(
680
+                    'options'          => array_merge(
681
+                        array(
682
+                            '' => __( 'All Tax Rules', 'invoicing' ),
683
+                        ),
684
+                        $vat_rules
685
+                    ),
686
+                    'name'             => 'vat_rule',
687
+                    'id'               => 'vat_rule',
688
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
689
+                    'show_option_all'  => false,
690
+                    'show_option_none' => false,
691
+                )
692
+            );
693
+
694
+            // Filter by VAT class.
695
+
696
+            // Sanitize selected vat rule.
697
+            $vat_class   = '';
698
+            $vat_classes = getpaid_get_tax_classes();
699
+            if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
+            }
702
+
703
+            wpinv_html_select(
704
+                array(
705
+                    'options'          => array_merge(
706
+                        array(
707
+                            '' => __( 'All Tax Classes', 'invoicing' ),
708
+                        ),
709
+                        $vat_classes
710
+                    ),
711
+                    'name'             => 'vat_class',
712
+                    'id'               => 'vat_class',
713
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
714
+                    'show_option_all'  => false,
715
+                    'show_option_none' => false,
716
+                )
717
+            );
718
+
719
+        }
720
+
721
+        // Filter by item type.
722
+        $type   = '';
723
+        if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
+            $type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
+        }
726
+
727
+        wpinv_html_select(
728
+            array(
729
+                'options'          => array_merge(
730
+                    array(
731
+                        '' => __( 'All item types', 'invoicing' ),
732
+                    ),
733
+                    wpinv_get_item_types()
734
+                ),
735
+                'name'             => 'type',
736
+                'id'               => 'type',
737
+                'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
738
+                'show_option_all'  => false,
739
+                'show_option_none' => false,
740
+            )
741
+        );
742
+
743
+    }
580 744
 
581
-		return apply_filters( 'wpi_item_table_columns', $columns );
582
-	}
745
+    /**
746
+     * Filters the item query.
747
+     */
748
+    public static function filter_item_query( $query ) {
583 749
 
584
-	/**
585
-	 * Returns an array of sortable items table columns.
586
-	 */
587
-	public static function sortable_item_columns( $columns ) {
588
-
589
-		return array_merge(
590
-			$columns,
591
-			array(
592
-				'price'     => 'price',
593
-				'vat_rule'  => 'vat_rule',
594
-				'vat_class' => 'vat_class',
595
-				'type'      => 'type',
596
-			)
597
-		);
598
-
599
-	}
600
-
601
-	/**
602
-	 * Displays items table columns.
603
-	 */
604
-	public static function display_item_columns( $column_name, $post_id ) {
605
-
606
-		$item = new WPInv_Item( $post_id );
607
-
608
-		switch ( $column_name ) {
609
-
610
-			case 'price':
611
-				if ( ! $item->is_recurring() ) {
612
-					echo wp_kses_post( $item->get_the_price() );
613
-					break;
614
-				}
615
-
616
-				$price = wp_sprintf(
617
-					__( '%1$s / %2$s', 'invoicing' ),
618
-					$item->get_the_price(),
619
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
620
-				);
621
-
622
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
623
-					echo wp_kses_post( $price );
624
-					break;
625
-				}
626
-
627
-				echo wp_kses_post( $item->get_the_initial_price() );
628
-
629
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
630
-				break;
631
-
632
-			case 'vat_rule':
633
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
634
-				break;
635
-
636
-			case 'vat_class':
637
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
638
-				break;
639
-
640
-			case 'shortcode':
641
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
642
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
643
-				} else {
644
-					echo '&mdash;';
645
-				}
646
-
647
-				break;
648
-
649
-			case 'type':
650
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
651
-				break;
652
-
653
-		}
654
-
655
-	}
656
-
657
-	/**
658
-	 * Lets users filter items using taxes.
659
-	 */
660
-	public static function add_item_filters( $post_type ) {
661
-
662
-		// Abort if we're not dealing with items.
663
-		if ( 'wpi_item' !== $post_type ) {
664
-			return;
665
-		}
666
-
667
-		// Filter by vat rules.
668
-		if ( wpinv_use_taxes() ) {
669
-
670
-			// Sanitize selected vat rule.
671
-			$vat_rule   = '';
672
-			$vat_rules  = getpaid_get_tax_rules();
673
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
-			}
676
-
677
-			// Filter by VAT rule.
678
-			wpinv_html_select(
679
-				array(
680
-					'options'          => array_merge(
681
-						array(
682
-							'' => __( 'All Tax Rules', 'invoicing' ),
683
-						),
684
-						$vat_rules
685
-					),
686
-					'name'             => 'vat_rule',
687
-					'id'               => 'vat_rule',
688
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
689
-					'show_option_all'  => false,
690
-					'show_option_none' => false,
691
-				)
692
-			);
693
-
694
-			// Filter by VAT class.
695
-
696
-			// Sanitize selected vat rule.
697
-			$vat_class   = '';
698
-			$vat_classes = getpaid_get_tax_classes();
699
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
-			}
702
-
703
-			wpinv_html_select(
704
-				array(
705
-					'options'          => array_merge(
706
-						array(
707
-							'' => __( 'All Tax Classes', 'invoicing' ),
708
-						),
709
-						$vat_classes
710
-					),
711
-					'name'             => 'vat_class',
712
-					'id'               => 'vat_class',
713
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
714
-					'show_option_all'  => false,
715
-					'show_option_none' => false,
716
-				)
717
-			);
718
-
719
-		}
720
-
721
-		// Filter by item type.
722
-		$type   = '';
723
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
-		}
726
-
727
-		wpinv_html_select(
728
-			array(
729
-				'options'          => array_merge(
730
-					array(
731
-						'' => __( 'All item types', 'invoicing' ),
732
-					),
733
-					wpinv_get_item_types()
734
-				),
735
-				'name'             => 'type',
736
-				'id'               => 'type',
737
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
738
-				'show_option_all'  => false,
739
-				'show_option_none' => false,
740
-			)
741
-		);
742
-
743
-	}
744
-
745
-	/**
746
-	 * Filters the item query.
747
-	 */
748
-	public static function filter_item_query( $query ) {
749
-
750
-		// modify the query only if it admin and main query.
751
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
752
-			return $query;
753
-		}
754
-
755
-		// we want to modify the query for our items.
756
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
757
-			return $query;
758
-		}
759
-
760
-		if ( empty( $query->query_vars['meta_query'] ) ) {
761
-			$query->query_vars['meta_query'] = array();
762
-		}
763
-
764
-		// Filter vat rule type
750
+        // modify the query only if it admin and main query.
751
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
752
+            return $query;
753
+        }
754
+
755
+        // we want to modify the query for our items.
756
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
757
+            return $query;
758
+        }
759
+
760
+        if ( empty( $query->query_vars['meta_query'] ) ) {
761
+            $query->query_vars['meta_query'] = array();
762
+        }
763
+
764
+        // Filter vat rule type
765 765
         if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
766 766
             $query->query_vars['meta_query'][] = array(
767 767
                 'key'     => '_wpinv_vat_rule',
@@ -786,146 +786,146 @@  discard block
 block discarded – undo
786 786
                 'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
787 787
                 'compare' => '=',
788 788
             );
789
-		}
790
-
791
-		$query->query_vars['meta_query'][] = array(
792
-			'key'     => '_wpinv_one_time',
793
-			'compare' => 'NOT EXISTS',
794
-		);
795
-	}
796
-
797
-	/**
798
-	 * Reorders items.
799
-	 */
800
-	public static function reorder_items( $vars ) {
801
-		global $typenow;
802
-
803
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
804
-			return $vars;
805
-		}
806
-
807
-		// By item type.
808
-		if ( 'type' === $vars['orderby'] ) {
809
-			return array_merge(
810
-				$vars,
811
-				array(
812
-					'meta_key' => '_wpinv_type',
813
-					'orderby'  => 'meta_value',
814
-				)
815
-			);
816
-		}
817
-
818
-		// By vat class.
819
-		if ( 'vat_class' === $vars['orderby'] ) {
820
-			return array_merge(
821
-				$vars,
822
-				array(
823
-					'meta_key' => '_wpinv_vat_class',
824
-					'orderby'  => 'meta_value',
825
-				)
826
-			);
827
-		}
828
-
829
-		// By vat rule.
830
-		if ( 'vat_rule' === $vars['orderby'] ) {
831
-			return array_merge(
832
-				$vars,
833
-				array(
834
-					'meta_key' => '_wpinv_vat_rule',
835
-					'orderby'  => 'meta_value',
836
-				)
837
-			);
838
-		}
839
-
840
-		// By price.
841
-		if ( 'price' === $vars['orderby'] ) {
842
-			return array_merge(
843
-				$vars,
844
-				array(
845
-					'meta_key' => '_wpinv_price',
846
-					'orderby'  => 'meta_value_num',
847
-				)
848
-			);
849
-		}
850
-
851
-		return $vars;
852
-
853
-	}
854
-
855
-	/**
856
-	 * Fired when deleting a post.
857
-	 */
858
-	public static function delete_post( $post_id ) {
859
-
860
-		switch ( get_post_type( $post_id ) ) {
861
-
862
-			case 'wpi_item':
863
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
864
-				break;
865
-
866
-			case 'wpi_payment_form':
867
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
868
-				break;
869
-
870
-			case 'wpi_discount':
871
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
872
-				break;
873
-
874
-			case 'wpi_invoice':
875
-				$invoice = new WPInv_Invoice( $post_id );
876
-				do_action( 'getpaid_before_delete_invoice', $invoice );
877
-				$invoice->get_data_store()->delete_items( $invoice );
878
-				$invoice->get_data_store()->delete_special_fields( $invoice );
879
-				break;
880
-		}
881
-	}
882
-
883
-	/**
884
-	 * Add a post display state for special GetPaid pages in the page list table.
885
-	 *
886
-	 * @param array   $post_states An array of post display states.
887
-	 * @param WP_Post $post        The current post object.
888
-	 *
889
-	 * @return mixed
890
-	 */
891
-	public static function add_display_post_states( $post_states, $post ) {
892
-		if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
893
-			$post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
894
-		}
895
-
896
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
897
-			$_post_type = str_replace( "wpi_", "", $post_type );
898
-
899
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
900
-				$post_states[ "getpaid_{$post_type}_history_page" ] = wp_sprintf(
901
-					__( 'GetPaid %s History Page', 'invoicing' ),
902
-					$label
903
-				);
904
-			} else if ( wpinv_get_option( "{$_post_type}_history_page", 0 ) == $post->ID ) {
905
-				$post_states[ "getpaid_{$_post_type}_history_page" ] = wp_sprintf(
906
-					__( 'GetPaid %s History Page', 'invoicing' ),
907
-					$label
908
-				);
909
-			}
910
-		}
911
-
912
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
913
-			$post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscriptions Page', 'invoicing' );
914
-		}
915
-
916
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
917
-			$post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
918
-		}
919
-
920
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
921
-			$post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
922
-		}
923
-
924
-		if ( wpinv_get_option( 'failure_page', 0 ) == $post->ID ) {
925
-			$post_states['getpaid_failure_page'] = __( 'GetPaid Transaction Failed Page', 'invoicing' );
926
-		}
927
-
928
-		return $post_states;
789
+        }
790
+
791
+        $query->query_vars['meta_query'][] = array(
792
+            'key'     => '_wpinv_one_time',
793
+            'compare' => 'NOT EXISTS',
794
+        );
795
+    }
796
+
797
+    /**
798
+     * Reorders items.
799
+     */
800
+    public static function reorder_items( $vars ) {
801
+        global $typenow;
802
+
803
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
804
+            return $vars;
805
+        }
806
+
807
+        // By item type.
808
+        if ( 'type' === $vars['orderby'] ) {
809
+            return array_merge(
810
+                $vars,
811
+                array(
812
+                    'meta_key' => '_wpinv_type',
813
+                    'orderby'  => 'meta_value',
814
+                )
815
+            );
816
+        }
817
+
818
+        // By vat class.
819
+        if ( 'vat_class' === $vars['orderby'] ) {
820
+            return array_merge(
821
+                $vars,
822
+                array(
823
+                    'meta_key' => '_wpinv_vat_class',
824
+                    'orderby'  => 'meta_value',
825
+                )
826
+            );
827
+        }
828
+
829
+        // By vat rule.
830
+        if ( 'vat_rule' === $vars['orderby'] ) {
831
+            return array_merge(
832
+                $vars,
833
+                array(
834
+                    'meta_key' => '_wpinv_vat_rule',
835
+                    'orderby'  => 'meta_value',
836
+                )
837
+            );
838
+        }
839
+
840
+        // By price.
841
+        if ( 'price' === $vars['orderby'] ) {
842
+            return array_merge(
843
+                $vars,
844
+                array(
845
+                    'meta_key' => '_wpinv_price',
846
+                    'orderby'  => 'meta_value_num',
847
+                )
848
+            );
849
+        }
850
+
851
+        return $vars;
852
+
853
+    }
854
+
855
+    /**
856
+     * Fired when deleting a post.
857
+     */
858
+    public static function delete_post( $post_id ) {
859
+
860
+        switch ( get_post_type( $post_id ) ) {
861
+
862
+            case 'wpi_item':
863
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
864
+                break;
865
+
866
+            case 'wpi_payment_form':
867
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
868
+                break;
869
+
870
+            case 'wpi_discount':
871
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
872
+                break;
873
+
874
+            case 'wpi_invoice':
875
+                $invoice = new WPInv_Invoice( $post_id );
876
+                do_action( 'getpaid_before_delete_invoice', $invoice );
877
+                $invoice->get_data_store()->delete_items( $invoice );
878
+                $invoice->get_data_store()->delete_special_fields( $invoice );
879
+                break;
880
+        }
881
+    }
882
+
883
+    /**
884
+     * Add a post display state for special GetPaid pages in the page list table.
885
+     *
886
+     * @param array   $post_states An array of post display states.
887
+     * @param WP_Post $post        The current post object.
888
+     *
889
+     * @return mixed
890
+     */
891
+    public static function add_display_post_states( $post_states, $post ) {
892
+        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
893
+            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
894
+        }
895
+
896
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
897
+            $_post_type = str_replace( "wpi_", "", $post_type );
898
+
899
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
900
+                $post_states[ "getpaid_{$post_type}_history_page" ] = wp_sprintf(
901
+                    __( 'GetPaid %s History Page', 'invoicing' ),
902
+                    $label
903
+                );
904
+            } else if ( wpinv_get_option( "{$_post_type}_history_page", 0 ) == $post->ID ) {
905
+                $post_states[ "getpaid_{$_post_type}_history_page" ] = wp_sprintf(
906
+                    __( 'GetPaid %s History Page', 'invoicing' ),
907
+                    $label
908
+                );
909
+            }
910
+        }
911
+
912
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
913
+            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscriptions Page', 'invoicing' );
914
+        }
915
+
916
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
917
+            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
918
+        }
919
+
920
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
921
+            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
922
+        }
923
+
924
+        if ( wpinv_get_option( 'failure_page', 0 ) == $post->ID ) {
925
+            $post_states['getpaid_failure_page'] = __( 'GetPaid Transaction Failed Page', 'invoicing' );
926
+        }
927
+
928
+        return $post_states;
929 929
     }
930 930
 
931 931
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142 142
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
143
+    return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
144 144
 }
145 145
 
146 146
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
162 162
 }
163 163
 
164 164
 /**
@@ -175,125 +175,125 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
178
+    do_action( 'get_template_part_' . $slug, $slug, $name );
179 179
 
180
-	// Setup possible parts
181
-	$templates = array();
182
-	if ( isset( $name ) ) {
183
-		$templates[] = $slug . '-' . $name . '.php';
180
+    // Setup possible parts
181
+    $templates = array();
182
+    if ( isset( $name ) ) {
183
+        $templates[] = $slug . '-' . $name . '.php';
184 184
     }
185
-	$templates[] = $slug . '.php';
185
+    $templates[] = $slug . '.php';
186 186
 
187
-	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+    // Allow template parts to be filtered
188
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
189 189
 
190
-	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+    // Return the part that is found
191
+    return wpinv_locate_tmpl( $templates, $load, false );
192 192
 }
193 193
 
194 194
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
195
-	// No file found yet
196
-	$located = false;
195
+    // No file found yet
196
+    $located = false;
197 197
 
198
-	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
198
+    // Try to find a template file
199
+    foreach ( (array)$template_names as $template_name ) {
200 200
 
201
-		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
203
-			continue;
201
+        // Continue if template is empty
202
+        if ( empty( $template_name ) ) {
203
+            continue;
204 204
         }
205 205
 
206
-		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
206
+        // Trim off any slashes from the template name
207
+        $template_name = ltrim( $template_name, '/' );
208 208
 
209
-		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
209
+        // try locating this template file by looping through the template paths
210
+        foreach ( wpinv_get_theme_template_paths() as $template_path ) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
213
-				$located = $template_path . $template_name;
214
-				break;
215
-			}
216
-		}
212
+            if ( file_exists( $template_path . $template_name ) ) {
213
+                $located = $template_path . $template_name;
214
+                break;
215
+            }
216
+        }
217 217
 
218
-		if ( ! empty( $located ) ) {
219
-			break;
220
-		}
221
-	}
218
+        if ( ! empty( $located ) ) {
219
+            break;
220
+        }
221
+    }
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+    if ( ( true == $load ) && ! empty( $located ) ) {
224
+        load_template( $located, $require_once );
225 225
     }
226 226
 
227
-	return $located;
227
+    return $located;
228 228
 }
229 229
 
230 230
 function wpinv_get_theme_template_paths() {
231
-	$template_dir = wpinv_get_theme_template_dir_name();
231
+    $template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233
-	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
236
-		100 => wpinv_get_templates_dir(),
237
-	);
233
+    $file_paths = array(
234
+        1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
+        10  => trailingslashit( get_template_directory() ) . $template_dir,
236
+        100 => wpinv_get_templates_dir(),
237
+    );
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
240 240
 
241
-	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
241
+    // sort the file paths based on priority
242
+    ksort( $file_paths, SORT_NUMERIC );
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+    return array_map( 'trailingslashit', $file_paths );
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249
-	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
249
+    $pages   = array();
250
+    $pages[] = wpinv_get_option( 'success_page' );
251
+    $pages[] = wpinv_get_option( 'failure_page' );
252
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
253
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
-		return;
257
-	}
255
+    if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
+        return;
257
+    }
258 258
 
259
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
259
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261 261
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
262 262
 
263 263
 function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
264
+    $classes = (array)$class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
267
-		$classes[] = 'wpinv-checkout';
268
-		$classes[] = 'wpinv-page';
269
-	}
266
+    if ( wpinv_is_checkout() ) {
267
+        $classes[] = 'wpinv-checkout';
268
+        $classes[] = 'wpinv-page';
269
+    }
270 270
 
271
-	if ( wpinv_is_success_page() ) {
272
-		$classes[] = 'wpinv-success';
273
-		$classes[] = 'wpinv-page';
274
-	}
271
+    if ( wpinv_is_success_page() ) {
272
+        $classes[] = 'wpinv-success';
273
+        $classes[] = 'wpinv-page';
274
+    }
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
277
-		$classes[] = 'wpinv-failed-transaction';
278
-		$classes[] = 'wpinv-page';
279
-	}
276
+    if ( wpinv_is_failed_transaction_page() ) {
277
+        $classes[] = 'wpinv-failed-transaction';
278
+        $classes[] = 'wpinv-page';
279
+    }
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
282
-		$classes[] = 'wpinv-history';
283
-		$classes[] = 'wpinv-page';
284
-	}
281
+    if ( wpinv_is_invoice_history_page() ) {
282
+        $classes[] = 'wpinv-history';
283
+        $classes[] = 'wpinv-page';
284
+    }
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
287
-		$classes[] = 'wpinv-subscription';
288
-		$classes[] = 'wpinv-page';
289
-	}
286
+    if ( wpinv_is_subscriptions_history_page() ) {
287
+        $classes[] = 'wpinv-subscription';
288
+        $classes[] = 'wpinv-page';
289
+    }
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
292
-		$classes[] = 'wpinv-test-mode';
293
-		$classes[] = 'wpinv-page';
294
-	}
291
+    if ( wpinv_is_test_mode() ) {
292
+        $classes[] = 'wpinv-test-mode';
293
+        $classes[] = 'wpinv-page';
294
+    }
295 295
 
296
-	return array_unique( $classes );
296
+    return array_unique( $classes );
297 297
 }
298 298
 add_filter( 'body_class', 'wpinv_add_body_classes' );
299 299
 
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 
468 468
     wpinv_html_select(
469 469
         array(
470
-			'name'             => $args['name'],
471
-			'selected'         => $args['selected'],
472
-			'id'               => $args['id'],
473
-			'class'            => $args['class'],
474
-			'options'          => $options,
475
-			'multiple'         => $args['multiple'],
476
-			'placeholder'      => $args['placeholder'],
477
-			'show_option_all'  => $args['show_option_all'],
478
-			'show_option_none' => $args['show_option_none'],
479
-			'data'             => $args['data'],
470
+            'name'             => $args['name'],
471
+            'selected'         => $args['selected'],
472
+            'id'               => $args['id'],
473
+            'class'            => $args['class'],
474
+            'options'          => $options,
475
+            'multiple'         => $args['multiple'],
476
+            'placeholder'      => $args['placeholder'],
477
+            'show_option_all'  => $args['show_option_all'],
478
+            'show_option_none' => $args['show_option_none'],
479
+            'data'             => $args['data'],
480 480
         )
481 481
     );
482 482
 
@@ -776,21 +776,21 @@  discard block
 block discarded – undo
776 776
 
777 777
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
778 778
 
779
-	// Remove unavailable tags.
779
+    // Remove unavailable tags.
780 780
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
781 781
 
782 782
     // Clean up white space.
783
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
783
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
784 784
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
785 785
 
786 786
     // Break newlines apart and remove empty lines/trim commas and white space.
787
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
787
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
788 788
 
789 789
     // Add html breaks.
790
-	$formatted_address = implode( $separator, $formatted_address );
790
+    $formatted_address = implode( $separator, $formatted_address );
791 791
 
792
-	// We're done!
793
-	return $formatted_address;
792
+    // We're done!
793
+    return $formatted_address;
794 794
 
795 795
 }
796 796
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 function getpaid_display_invoice_subscriptions( $invoice ) {
837 837
 
838 838
     // Subscriptions.
839
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
839
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
840 840
 
841 841
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
842 842
         return;
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_empty_cart_message() {
1055
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1055
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1250,9 +1250,9 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
     if ( 0 == count( $form->get_items() ) ) {
1252 1252
         aui()->alert(
1253
-			array(
1254
-				'type'    => 'warning',
1255
-				'content' => __( 'No published items found', 'invoicing' ),
1253
+            array(
1254
+                'type'    => 'warning',
1255
+                'content' => __( 'No published items found', 'invoicing' ),
1256 1256
             ),
1257 1257
             true
1258 1258
         );
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
     $invoice = wpinv_get_invoice( $invoice_id );
1276 1276
 
1277 1277
     if ( empty( $invoice ) ) {
1278
-		aui()->alert(
1279
-			array(
1280
-				'type'    => 'warning',
1281
-				'content' => __( 'Invoice not found', 'invoicing' ),
1278
+        aui()->alert(
1279
+            array(
1280
+                'type'    => 'warning',
1281
+                'content' => __( 'Invoice not found', 'invoicing' ),
1282 1282
             ),
1283 1283
             true
1284 1284
         );
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
     }
1287 1287
 
1288 1288
     if ( $invoice->is_paid() ) {
1289
-		aui()->alert(
1290
-			array(
1291
-				'type'    => 'warning',
1292
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1289
+        aui()->alert(
1290
+            array(
1291
+                'type'    => 'warning',
1292
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1293 1293
             ),
1294 1294
             true
1295 1295
         );
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1355 1355
     }
1356 1356
 
1357
-	if ( ! empty( $items ) ) {
1357
+    if ( ! empty( $items ) ) {
1358 1358
         $items  = esc_attr( $items );
1359 1359
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1360 1360
     }
@@ -1554,21 +1554,21 @@  discard block
 block discarded – undo
1554 1554
 
1555 1555
         return aui()->select(
1556 1556
             array(
1557
-				'options'          => $states,
1558
-				'name'             => esc_attr( $field_name ),
1559
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
-				'value'            => sanitize_text_field( $state ),
1561
-				'placeholder'      => $placeholder,
1562
-				'required'         => $required,
1563
-				'label'            => wp_kses_post( $label ),
1564
-				'label_type'       => 'vertical',
1565
-				'help_text'        => $help_text,
1566
-				'class'            => 'getpaid-address-field wpinv_state',
1567
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
-				'extra_attributes' => array(
1570
-					'autocomplete' => 'address-level1',
1571
-				),
1557
+                'options'          => $states,
1558
+                'name'             => esc_attr( $field_name ),
1559
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
+                'value'            => sanitize_text_field( $state ),
1561
+                'placeholder'      => $placeholder,
1562
+                'required'         => $required,
1563
+                'label'            => wp_kses_post( $label ),
1564
+                'label_type'       => 'vertical',
1565
+                'help_text'        => $help_text,
1566
+                'class'            => 'getpaid-address-field wpinv_state',
1567
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
+                'extra_attributes' => array(
1570
+                    'autocomplete' => 'address-level1',
1571
+                ),
1572 1572
             ),
1573 1573
             $echo
1574 1574
         );
@@ -1664,36 +1664,36 @@  discard block
 block discarded – undo
1664 1664
  * @return array Array of custom fields.
1665 1665
  */
1666 1666
 function getpaid_get_payment_form_custom_fields() {
1667
-	global $wpdb, $payment_form_meta_fields;
1667
+    global $wpdb, $payment_form_meta_fields;
1668 1668
 
1669
-	if ( ! empty( $payment_form_meta_fields ) ) {
1670
-		return $payment_form_meta_fields;
1671
-	}
1669
+    if ( ! empty( $payment_form_meta_fields ) ) {
1670
+        return $payment_form_meta_fields;
1671
+    }
1672 1672
 
1673
-	$results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1673
+    $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1674 1674
 
1675
-	$meta_fields = array();
1675
+    $meta_fields = array();
1676 1676
 
1677
-	if ( ! empty( $results ) ) {
1678
-		foreach ( $results as $row ) {
1679
-			$fields = maybe_unserialize( $row->meta_value );
1677
+    if ( ! empty( $results ) ) {
1678
+        foreach ( $results as $row ) {
1679
+            $fields = maybe_unserialize( $row->meta_value );
1680 1680
 
1681
-			if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
-				foreach ( $fields as $field ) {
1683
-					$label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1681
+            if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
+                foreach ( $fields as $field ) {
1683
+                    $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1684 1684
 
1685
-					if ( $label ) {
1686
-						$field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
-						$meta_fields[ $field_key ] = $label;
1688
-					}
1689
-				}
1690
-			}
1691
-		}
1692
-	}
1685
+                    if ( $label ) {
1686
+                        $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
+                        $meta_fields[ $field_key ] = $label;
1688
+                    }
1689
+                }
1690
+            }
1691
+        }
1692
+    }
1693 1693
 
1694
-	$payment_form_meta_fields = $meta_fields;
1694
+    $payment_form_meta_fields = $meta_fields;
1695 1695
 
1696
-	return $meta_fields;
1696
+    return $meta_fields;
1697 1697
 }
1698 1698
 
1699 1699
 /**
@@ -1704,22 +1704,22 @@  discard block
 block discarded – undo
1704 1704
  * @return bool True if site uses Gutenberg else False.
1705 1705
  */
1706 1706
 function getpaid_is_gutenberg() {
1707
-	global $wp_version;
1707
+    global $wp_version;
1708 1708
 
1709
-	$is_gutenberg = true;
1709
+    $is_gutenberg = true;
1710 1710
 
1711
-	// If less than v5.
1712
-	if ( version_compare( $wp_version, '5.0.0', '<' ) ) {
1713
-		$is_gutenberg = false;
1714
-	}
1711
+    // If less than v5.
1712
+    if ( version_compare( $wp_version, '5.0.0', '<' ) ) {
1713
+        $is_gutenberg = false;
1714
+    }
1715 1715
 
1716
-	if ( class_exists( 'Classic_Editor' ) ) {
1717
-		$is_gutenberg = false; // Classic Editor plugin is active.
1718
-	} else if ( getpaid_is_classicpress() ) {
1719
-		$is_gutenberg = false; // Site is using ClassicPress.
1720
-	}
1716
+    if ( class_exists( 'Classic_Editor' ) ) {
1717
+        $is_gutenberg = false; // Classic Editor plugin is active.
1718
+    } else if ( getpaid_is_classicpress() ) {
1719
+        $is_gutenberg = false; // Site is using ClassicPress.
1720
+    }
1721 1721
 
1722
-	return $is_gutenberg;
1722
+    return $is_gutenberg;
1723 1723
 }
1724 1724
 
1725 1725
 /**
@@ -1730,13 +1730,13 @@  discard block
 block discarded – undo
1730 1730
  * @return bool True if site uses ClassicPress else False.
1731 1731
  */
1732 1732
 function getpaid_is_classicpress() {
1733
-	if ( function_exists( 'classicpress_version' ) ) {
1734
-		$is_classicpress = true;
1735
-	} else {
1736
-		$is_classicpress = false;
1737
-	}
1733
+    if ( function_exists( 'classicpress_version' ) ) {
1734
+        $is_classicpress = true;
1735
+    } else {
1736
+        $is_classicpress = false;
1737
+    }
1738 1738
 
1739
-	return $is_classicpress;
1739
+    return $is_classicpress;
1740 1740
 }
1741 1741
 
1742 1742
 /**
@@ -1748,20 +1748,20 @@  discard block
 block discarded – undo
1748 1748
  * @param @bool $blocks True to use blocks.
1749 1749
  * @return string Page content.
1750 1750
  */
1751
- function getpaid_page_content_checkout( $filtered = false, $blocks = false ) {
1752
-	if ( $blocks ) {
1753
-		$content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} -->
1751
+    function getpaid_page_content_checkout( $filtered = false, $blocks = false ) {
1752
+    if ( $blocks ) {
1753
+        $content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} -->
1754 1754
 <div class=\"wp-block-invoicing-wpinv-checkout-widget\"></div>
1755 1755
 <!-- /wp:invoicing/wpinv-checkout-widget -->";
1756
-	} else {
1757
-		$content = "[wpinv_checkout]";
1758
-	}
1756
+    } else {
1757
+        $content = "[wpinv_checkout]";
1758
+    }
1759 1759
 
1760
-	if ( $filtered ) {
1761
-		$content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks );
1762
-	}
1760
+    if ( $filtered ) {
1761
+        $content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks );
1762
+    }
1763 1763
 
1764
-	return $content;
1764
+    return $content;
1765 1765
 }
1766 1766
 
1767 1767
 /**
@@ -1773,20 +1773,20 @@  discard block
 block discarded – undo
1773 1773
  * @param @bool $blocks True to use blocks.
1774 1774
  * @return string Page content.
1775 1775
  */
1776
- function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) {
1777
-	if ( $blocks ) {
1778
-		$content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} -->
1776
+    function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) {
1777
+    if ( $blocks ) {
1778
+        $content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} -->
1779 1779
 <div class=\"wp-block-invoicing-wpinv-history-widget\"></div>
1780 1780
 <!-- /wp:invoicing/wpinv-history-widget -->";
1781
-	} else {
1782
-		$content = "[wpinv_history]";
1783
-	}
1781
+    } else {
1782
+        $content = "[wpinv_history]";
1783
+    }
1784 1784
 
1785
-	if ( $filtered ) {
1786
-		$content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks );
1787
-	}
1785
+    if ( $filtered ) {
1786
+        $content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks );
1787
+    }
1788 1788
 
1789
-	return $content;
1789
+    return $content;
1790 1790
 }
1791 1791
 
1792 1792
 /**
@@ -1798,20 +1798,20 @@  discard block
 block discarded – undo
1798 1798
  * @param @bool $blocks True to use blocks.
1799 1799
  * @return string Page content.
1800 1800
  */
1801
- function getpaid_page_content_receipt( $filtered = false, $blocks = false ) {
1802
-	if ( $blocks ) {
1803
-		$content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} -->
1801
+    function getpaid_page_content_receipt( $filtered = false, $blocks = false ) {
1802
+    if ( $blocks ) {
1803
+        $content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} -->
1804 1804
 <div class=\"wp-block-invoicing-wpinv-receipt-widget\"></div>
1805 1805
 <!-- /wp:invoicing/wpinv-receipt-widget -->";
1806
-	} else {
1807
-		$content = "[wpinv_receipt]";
1808
-	}
1806
+    } else {
1807
+        $content = "[wpinv_receipt]";
1808
+    }
1809 1809
 
1810
-	if ( $filtered ) {
1811
-		$content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks );
1812
-	}
1810
+    if ( $filtered ) {
1811
+        $content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks );
1812
+    }
1813 1813
 
1814
-	return $content;
1814
+    return $content;
1815 1815
 }
1816 1816
 
1817 1817
 /**
@@ -1823,20 +1823,20 @@  discard block
 block discarded – undo
1823 1823
  * @param @bool $blocks True to use blocks.
1824 1824
  * @return string Page content.
1825 1825
  */
1826
- function getpaid_page_content_failure( $filtered = false, $blocks = false ) {
1827
-	if ( $blocks ) {
1828
-		$content = "<!-- wp:html -->
1826
+    function getpaid_page_content_failure( $filtered = false, $blocks = false ) {
1827
+    if ( $blocks ) {
1828
+        $content = "<!-- wp:html -->
1829 1829
 " . __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ) . "
1830 1830
 <!-- /wp:html -->";
1831
-	} else {
1832
-		$content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' );
1833
-	}
1831
+    } else {
1832
+        $content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' );
1833
+    }
1834 1834
 
1835
-	if ( $filtered ) {
1836
-		$content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks );
1837
-	}
1835
+    if ( $filtered ) {
1836
+        $content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks );
1837
+    }
1838 1838
 
1839
-	return $content;
1839
+    return $content;
1840 1840
 }
1841 1841
 
1842 1842
 /**
@@ -1848,18 +1848,18 @@  discard block
 block discarded – undo
1848 1848
  * @param @bool $blocks True to use blocks.
1849 1849
  * @return string Page content.
1850 1850
  */
1851
- function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) {
1852
-	if ( $blocks ) {
1853
-		$content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} -->
1851
+    function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) {
1852
+    if ( $blocks ) {
1853
+        $content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} -->
1854 1854
 <div class=\"wp-block-invoicing-wpinv-subscriptions-widget\"></div>
1855 1855
 <!-- /wp:invoicing/wpinv-subscriptions-widget -->";
1856
-	} else {
1857
-		$content = "[wpinv_subscriptions]";
1858
-	}
1856
+    } else {
1857
+        $content = "[wpinv_subscriptions]";
1858
+    }
1859 1859
 
1860
-	if ( $filtered ) {
1861
-		$content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks );
1862
-	}
1860
+    if ( $filtered ) {
1861
+        $content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks );
1862
+    }
1863 1863
 
1864
-	return $content;
1864
+    return $content;
1865 1865
 }
1866 1866
\ No newline at end of file
Please login to merge, or discard this patch.
widgets/checkout.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -9,117 +9,117 @@
 block discarded – undo
9 9
  */
10 10
 class WPInv_Checkout_Widget extends WP_Super_Duper {
11 11
 
12
-	/**
13
-	 * Register the widget with WordPress.
14
-	 *
15
-	 */
16
-	public function __construct() {
12
+    /**
13
+     * Register the widget with WordPress.
14
+     *
15
+     */
16
+    public function __construct() {
17 17
 
18
-		$options = array(
19
-			'textdomain'     => 'invoicing',
20
-			'block-icon'     => 'admin-site',
21
-			'block-category' => 'widgets',
22
-			'block-keywords' => "['invoicing','checkout']",
23
-			'class_name'     => __CLASS__,
24
-			'base_id'        => 'wpinv_checkout',
25
-			'name'           => __( 'GetPaid > Checkout', 'invoicing' ),
26
-			'widget_ops'     => array(
27
-				'classname'   => 'getpaid-checkout bsui',
28
-				'description' => esc_html__( 'Displays a checkout form.', 'invoicing' ),
29
-			),
30
-			'arguments'      => array(
31
-				'title' => array(
32
-					'title'    => __( 'Widget title', 'invoicing' ),
33
-					'desc'     => __( 'Enter widget title.', 'invoicing' ),
34
-					'type'     => 'text',
35
-					'desc_tip' => true,
36
-					'default'  => '',
37
-					'advanced' => false,
38
-				),
39
-			),
18
+        $options = array(
19
+            'textdomain'     => 'invoicing',
20
+            'block-icon'     => 'admin-site',
21
+            'block-category' => 'widgets',
22
+            'block-keywords' => "['invoicing','checkout']",
23
+            'class_name'     => __CLASS__,
24
+            'base_id'        => 'wpinv_checkout',
25
+            'name'           => __( 'GetPaid > Checkout', 'invoicing' ),
26
+            'widget_ops'     => array(
27
+                'classname'   => 'getpaid-checkout bsui',
28
+                'description' => esc_html__( 'Displays a checkout form.', 'invoicing' ),
29
+            ),
30
+            'arguments'      => array(
31
+                'title' => array(
32
+                    'title'    => __( 'Widget title', 'invoicing' ),
33
+                    'desc'     => __( 'Enter widget title.', 'invoicing' ),
34
+                    'type'     => 'text',
35
+                    'desc_tip' => true,
36
+                    'default'  => '',
37
+                    'advanced' => false,
38
+                ),
39
+            ),
40 40
 
41
-		);
41
+        );
42 42
 
43
-		parent::__construct( $options );
44
-	}
43
+        parent::__construct( $options );
44
+    }
45 45
 
46
-	/**
47
-	 * The Super block output function.
48
-	 *
49
-	 * @param array $args
50
-	 * @param array $widget_args
51
-	 * @param string $content
52
-	 *
53
-	 * @return mixed|string|bool
54
-	 */
55
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
-		if ( $this->is_preview() ) {
57
-			return $this->get_dummy_preview( $args );
58
-		}
46
+    /**
47
+     * The Super block output function.
48
+     *
49
+     * @param array $args
50
+     * @param array $widget_args
51
+     * @param string $content
52
+     *
53
+     * @return mixed|string|bool
54
+     */
55
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
+        if ( $this->is_preview() ) {
57
+            return $this->get_dummy_preview( $args );
58
+        }
59 59
 
60
-		return wpinv_checkout_form();
61
-	}
60
+        return wpinv_checkout_form();
61
+    }
62 62
 
63
-	public function get_dummy_preview( $args ) {
64
-		$output = '<form><div class="col-12">';
63
+    public function get_dummy_preview( $args ) {
64
+        $output = '<form><div class="col-12">';
65 65
 
66
-		$output .= aui()->alert(
67
-			array(
68
-				'type'=> 'info',
69
-				'content' => __( 'This is a simple preview for a checkout form.', 'invoicing' )
70
-			)
71
-		);
66
+        $output .= aui()->alert(
67
+            array(
68
+                'type'=> 'info',
69
+                'content' => __( 'This is a simple preview for a checkout form.', 'invoicing' )
70
+            )
71
+        );
72 72
 
73
-		$output .= aui()->input(
74
-			array(
75
-				'name'        => 'mmdwqzpox',
76
-				'required'    => true,
77
-				'label'       => __( 'Billing Email', 'invoicing' ),
78
-				'label_type'  => 'vertical',
79
-				'type'        => 'text',
80
-				'placeholder' => '[email protected]',
81
-				'class'       => '',
82
-				'value'       => ''
83
-			)
84
-		);
73
+        $output .= aui()->input(
74
+            array(
75
+                'name'        => 'mmdwqzpox',
76
+                'required'    => true,
77
+                'label'       => __( 'Billing Email', 'invoicing' ),
78
+                'label_type'  => 'vertical',
79
+                'type'        => 'text',
80
+                'placeholder' => '[email protected]',
81
+                'class'       => '',
82
+                'value'       => ''
83
+            )
84
+        );
85 85
 
86
-		$output .= aui()->input(
87
-			array(
88
-				'name'        => 'mmdwqzpoy',
89
-				'required'    => true,
90
-				'label'       => __( 'First Name', 'invoicing' ),
91
-				'label_type'  => 'vertical',
92
-				'type'        => 'text',
93
-				'placeholder' => 'Jon',
94
-				'class'       => '',
95
-				'value'       => ''
96
-			)
97
-		);
86
+        $output .= aui()->input(
87
+            array(
88
+                'name'        => 'mmdwqzpoy',
89
+                'required'    => true,
90
+                'label'       => __( 'First Name', 'invoicing' ),
91
+                'label_type'  => 'vertical',
92
+                'type'        => 'text',
93
+                'placeholder' => 'Jon',
94
+                'class'       => '',
95
+                'value'       => ''
96
+            )
97
+        );
98 98
 
99
-		$output .= aui()->input(
100
-			array(
101
-				'name'        => 'mmdwqzpoz',
102
-				'required'    => true,
103
-				'label'       => __( 'Last Name', 'invoicing' ),
104
-				'label_type'  => 'vertical',
105
-				'type'        => 'text',
106
-				'placeholder' => 'Snow',
107
-				'class'       => '',
108
-				'value'       => ''
109
-			)
110
-		);
99
+        $output .= aui()->input(
100
+            array(
101
+                'name'        => 'mmdwqzpoz',
102
+                'required'    => true,
103
+                'label'       => __( 'Last Name', 'invoicing' ),
104
+                'label_type'  => 'vertical',
105
+                'type'        => 'text',
106
+                'placeholder' => 'Snow',
107
+                'class'       => '',
108
+                'value'       => ''
109
+            )
110
+        );
111 111
 
112
-		$output .= aui()->button(
113
-			array(
114
-				'type'        => 'button',
115
-				'class'       => 'btn btn-primary w-100',
116
-				'content'     => __( 'Pay Now »', 'invoicing' ),
117
-				'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' )
118
-			)
119
-		);
112
+        $output .= aui()->button(
113
+            array(
114
+                'type'        => 'button',
115
+                'class'       => 'btn btn-primary w-100',
116
+                'content'     => __( 'Pay Now »', 'invoicing' ),
117
+                'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' )
118
+            )
119
+        );
120 120
 
121
-		$output .= '</div></form>';
121
+        $output .= '</div></form>';
122 122
 
123
-		return $output;
124
-	}
123
+        return $output;
124
+    }
125 125
 }
Please login to merge, or discard this patch.
widgets/invoice-receipt.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -8,86 +8,86 @@
 block discarded – undo
8 8
  */
9 9
 class WPInv_Receipt_Widget extends WP_Super_Duper {
10 10
 
11
-	/**
12
-	 * Register the widget with WordPress.
13
-	 *
14
-	 */
15
-	public function __construct() {
16
-
17
-		$options = array(
18
-			'textdomain'     => 'invoicing',
19
-			'block-icon'     => 'admin-site',
20
-			'block-category' => 'widgets',
21
-			'block-keywords' => "['invoicing','receipt']",
22
-			'class_name'     => __CLASS__,
23
-			'base_id'        => 'wpinv_receipt',
24
-			'name'           => __( 'GetPaid > Invoice Receipt', 'invoicing' ),
25
-			'widget_ops'     => array(
26
-				'classname'   => 'wpinv-receipt-class bsui',
27
-				'description' => esc_html__( 'Displays invoice receipt after checkout.', 'invoicing' ),
28
-			),
29
-			'arguments'      => array(
30
-				'title' => array(
31
-					'title'    => __( 'Widget title', 'invoicing' ),
32
-					'desc'     => __( 'Enter widget title.', 'invoicing' ),
33
-					'type'     => 'text',
34
-					'desc_tip' => true,
35
-					'default'  => '',
36
-					'advanced' => false,
37
-				),
38
-			),
39
-
40
-		);
41
-
42
-		parent::__construct( $options );
43
-	}
44
-
45
-	/**
46
-	 * The Super block output function.
47
-	 *
48
-	 * @param array $args
49
-	 * @param array $widget_args
50
-	 * @param string $content
51
-	 *
52
-	 * @return mixed|string|bool
53
-	 */
54
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
55
-		if ( $this->is_preview() ) {
56
-			return $this->get_dummy_preview( $args );
57
-		}
58
-
59
-		return wpinv_payment_receipt();
60
-	}
61
-
62
-	public function get_dummy_preview( $args ) {
63
-		global $wpdb;
64
-
65
-		$output = aui()->alert( array(
66
-				'type'=> 'info',
67
-				'content' => __( 'This is a simple preview for a invoice receipt.', 'invoicing' )
68
-			)
69
-		);
70
-
71
-		if ( ! current_user_can( 'manage_options' ) ) {
72
-			return $output;
73
-		}
74
-
75
-		$invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = %s AND `post_status` IN( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold' ) ORDER BY `post_status` ASC, `ID` ASC LIMIT 1;", 'wpi_invoice' ) );
76
-
77
-		if ( ! $invoice_id ) {
78
-			return $output;
79
-		}
80
-
81
-		$invoice = new WPInv_Invoice( $invoice_id );
82
-
83
-		if ( empty( $invoice ) ) {
84
-			return $output;
85
-		}
86
-
87
-		$output .= wpinv_get_template_html( 'invoice-receipt.php', array( 'invoice' => $invoice ) );
88
-
89
-		$output = preg_replace( '/<a([^>]*)href=(["\'])(.*?)\2([^>]*)>/is', '<a\\1href="javascript:void(0)"\\4>', $output );
90
-
91
-		return $output;
92
-	}
11
+    /**
12
+     * Register the widget with WordPress.
13
+     *
14
+     */
15
+    public function __construct() {
16
+
17
+        $options = array(
18
+            'textdomain'     => 'invoicing',
19
+            'block-icon'     => 'admin-site',
20
+            'block-category' => 'widgets',
21
+            'block-keywords' => "['invoicing','receipt']",
22
+            'class_name'     => __CLASS__,
23
+            'base_id'        => 'wpinv_receipt',
24
+            'name'           => __( 'GetPaid > Invoice Receipt', 'invoicing' ),
25
+            'widget_ops'     => array(
26
+                'classname'   => 'wpinv-receipt-class bsui',
27
+                'description' => esc_html__( 'Displays invoice receipt after checkout.', 'invoicing' ),
28
+            ),
29
+            'arguments'      => array(
30
+                'title' => array(
31
+                    'title'    => __( 'Widget title', 'invoicing' ),
32
+                    'desc'     => __( 'Enter widget title.', 'invoicing' ),
33
+                    'type'     => 'text',
34
+                    'desc_tip' => true,
35
+                    'default'  => '',
36
+                    'advanced' => false,
37
+                ),
38
+            ),
39
+
40
+        );
41
+
42
+        parent::__construct( $options );
43
+    }
44
+
45
+    /**
46
+     * The Super block output function.
47
+     *
48
+     * @param array $args
49
+     * @param array $widget_args
50
+     * @param string $content
51
+     *
52
+     * @return mixed|string|bool
53
+     */
54
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
55
+        if ( $this->is_preview() ) {
56
+            return $this->get_dummy_preview( $args );
57
+        }
58
+
59
+        return wpinv_payment_receipt();
60
+    }
61
+
62
+    public function get_dummy_preview( $args ) {
63
+        global $wpdb;
64
+
65
+        $output = aui()->alert( array(
66
+                'type'=> 'info',
67
+                'content' => __( 'This is a simple preview for a invoice receipt.', 'invoicing' )
68
+            )
69
+        );
70
+
71
+        if ( ! current_user_can( 'manage_options' ) ) {
72
+            return $output;
73
+        }
74
+
75
+        $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = %s AND `post_status` IN( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold' ) ORDER BY `post_status` ASC, `ID` ASC LIMIT 1;", 'wpi_invoice' ) );
76
+
77
+        if ( ! $invoice_id ) {
78
+            return $output;
79
+        }
80
+
81
+        $invoice = new WPInv_Invoice( $invoice_id );
82
+
83
+        if ( empty( $invoice ) ) {
84
+            return $output;
85
+        }
86
+
87
+        $output .= wpinv_get_template_html( 'invoice-receipt.php', array( 'invoice' => $invoice ) );
88
+
89
+        $output = preg_replace( '/<a([^>]*)href=(["\'])(.*?)\2([^>]*)>/is', '<a\\1href="javascript:void(0)"\\4>', $output );
90
+
91
+        return $output;
92
+    }
93 93
 }
Please login to merge, or discard this patch.