Passed
Push — master ( 312fad...cb75a2 )
by Brian
08:55 queued 04:16
created
vendor/ayecode/wp-ayecode-ui/includes/class-aui.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,206 +11,206 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI {
13 13
 
14
-	/**
15
-	 * Holds the class instance.
16
-	 *
17
-	 * @since 1.0.0
18
-	 * @var null
19
-	 */
20
-	private static $instance = null;
21
-
22
-	/**
23
-	 * Holds the current AUI version number.
24
-	 *
25
-	 * @var string $ver The current version number.
26
-	 */
27
-	public static $ver = '0.1.22';
28
-
29
-	/**
30
-	 * There can be only one.
31
-	 *
32
-	 * @since 1.0.0
33
-	 * @return AUI|null
34
-	 */
35
-	public static function instance() {
36
-		if ( self::$instance == null ) {
37
-			self::$instance = new AUI();
38
-		}
39
-
40
-		return self::$instance;
41
-	}
42
-
43
-	/**
44
-	 * AUI constructor.
45
-	 *
46
-	 * @since 1.0.0
47
-	 */
48
-	private function __construct() {
49
-		if ( function_exists( "__autoload" ) ) {
50
-			spl_autoload_register( "__autoload" );
51
-		}
52
-		spl_autoload_register( array( $this, 'autoload' ) );
53
-	}
54
-
55
-	/**
56
-	 * Autoload any components on the fly.
57
-	 *
58
-	 * @since 1.0.0
59
-	 *
60
-	 * @param $classname
61
-	 */
62
-	private function autoload( $classname ) {
63
-		$class     = str_replace( '_', '-', strtolower( $classname ) );
64
-		$file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
65
-		if ( $file_path && is_readable( $file_path ) ) {
66
-			include_once( $file_path );
67
-		}
68
-	}
69
-
70
-	public function render( $items = array() ) {
71
-		$output = '';
72
-
73
-		if ( ! empty( $items ) ) {
74
-			foreach ( $items as $args ) {
75
-				$render = isset( $args['render'] ) ? $args['render'] : '';
76
-				if ( $render && method_exists( __CLASS__, $render ) ) {
77
-					$output .= $this->$render( $args );
78
-				}
79
-			}
80
-		}
81
-
82
-		return $output;
83
-	}
84
-
85
-	/**
86
-	 * Render and return a bootstrap alert component.
87
-	 *
88
-	 * @since 1.0.0
89
-	 *
90
-	 * @param array $args
91
-	 *
92
-	 * @return string The rendered component.
93
-	 */
94
-	public function alert( $args = array() ) {
95
-		return AUI_Component_Alert::get( $args );
96
-	}
97
-
98
-	/**
99
-	 * Render and return a bootstrap input component.
100
-	 *
101
-	 * @since 1.0.0
102
-	 *
103
-	 * @param array $args
104
-	 *
105
-	 * @return string The rendered component.
106
-	 */
107
-	public function input( $args = array() ) {
108
-		return AUI_Component_Input::input( $args );
109
-	}
110
-
111
-	/**
112
-	 * Render and return a bootstrap textarea component.
113
-	 *
114
-	 * @since 1.0.0
115
-	 *
116
-	 * @param array $args
117
-	 *
118
-	 * @return string The rendered component.
119
-	 */
120
-	public function textarea( $args = array() ) {
121
-		return AUI_Component_Input::textarea( $args );
122
-	}
123
-
124
-	/**
125
-	 * Render and return a bootstrap button component.
126
-	 *
127
-	 * @since 1.0.0
128
-	 *
129
-	 * @param array $args
130
-	 *
131
-	 * @return string The rendered component.
132
-	 */
133
-	public function button( $args = array() ) {
134
-		return AUI_Component_Button::get( $args );
135
-	}
136
-
137
-	/**
138
-	 * Render and return a bootstrap button component.
139
-	 *
140
-	 * @since 1.0.0
141
-	 *
142
-	 * @param array $args
143
-	 *
144
-	 * @return string The rendered component.
145
-	 */
146
-	public function badge( $args = array() ) {
147
-		$defaults = array(
148
-			'class' => 'badge badge-primary align-middle',
149
-		);
150
-
151
-		// maybe set type
152
-		if ( empty( $args['href'] ) ) {
153
-			$defaults['type'] = 'badge';
154
-		}
155
-
156
-		/**
157
-		 * Parse incoming $args into an array and merge it with $defaults
158
-		 */
159
-		$args = wp_parse_args( $args, $defaults );
160
-
161
-		return AUI_Component_Button::get( $args );
162
-	}
163
-
164
-	/**
165
-	 * Render and return a bootstrap dropdown component.
166
-	 *
167
-	 * @since 1.0.0
168
-	 *
169
-	 * @param array $args
170
-	 *
171
-	 * @return string The rendered component.
172
-	 */
173
-	public function dropdown( $args = array() ) {
174
-		return AUI_Component_Dropdown::get( $args );
175
-	}
176
-
177
-	/**
178
-	 * Render and return a bootstrap select component.
179
-	 *
180
-	 * @since 1.0.0
181
-	 *
182
-	 * @param array $args
183
-	 *
184
-	 * @return string The rendered component.
185
-	 */
186
-	public function select( $args = array() ) {
187
-		return AUI_Component_Input::select( $args );
188
-	}
189
-
190
-	/**
191
-	 * Render and return a bootstrap radio component.
192
-	 *
193
-	 * @since 1.0.0
194
-	 *
195
-	 * @param array $args
196
-	 *
197
-	 * @return string The rendered component.
198
-	 */
199
-	public function radio( $args = array() ) {
200
-		return AUI_Component_Input::radio( $args );
201
-	}
202
-
203
-	/**
204
-	 * Render and return a bootstrap pagination component.
205
-	 *
206
-	 * @since 1.0.0
207
-	 *
208
-	 * @param array $args
209
-	 *
210
-	 * @return string The rendered component.
211
-	 */
212
-	public function pagination( $args = array() ) {
213
-		return AUI_Component_Pagination::get( $args );
214
-	}
14
+    /**
15
+     * Holds the class instance.
16
+     *
17
+     * @since 1.0.0
18
+     * @var null
19
+     */
20
+    private static $instance = null;
21
+
22
+    /**
23
+     * Holds the current AUI version number.
24
+     *
25
+     * @var string $ver The current version number.
26
+     */
27
+    public static $ver = '0.1.22';
28
+
29
+    /**
30
+     * There can be only one.
31
+     *
32
+     * @since 1.0.0
33
+     * @return AUI|null
34
+     */
35
+    public static function instance() {
36
+        if ( self::$instance == null ) {
37
+            self::$instance = new AUI();
38
+        }
39
+
40
+        return self::$instance;
41
+    }
42
+
43
+    /**
44
+     * AUI constructor.
45
+     *
46
+     * @since 1.0.0
47
+     */
48
+    private function __construct() {
49
+        if ( function_exists( "__autoload" ) ) {
50
+            spl_autoload_register( "__autoload" );
51
+        }
52
+        spl_autoload_register( array( $this, 'autoload' ) );
53
+    }
54
+
55
+    /**
56
+     * Autoload any components on the fly.
57
+     *
58
+     * @since 1.0.0
59
+     *
60
+     * @param $classname
61
+     */
62
+    private function autoload( $classname ) {
63
+        $class     = str_replace( '_', '-', strtolower( $classname ) );
64
+        $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
65
+        if ( $file_path && is_readable( $file_path ) ) {
66
+            include_once( $file_path );
67
+        }
68
+    }
69
+
70
+    public function render( $items = array() ) {
71
+        $output = '';
72
+
73
+        if ( ! empty( $items ) ) {
74
+            foreach ( $items as $args ) {
75
+                $render = isset( $args['render'] ) ? $args['render'] : '';
76
+                if ( $render && method_exists( __CLASS__, $render ) ) {
77
+                    $output .= $this->$render( $args );
78
+                }
79
+            }
80
+        }
81
+
82
+        return $output;
83
+    }
84
+
85
+    /**
86
+     * Render and return a bootstrap alert component.
87
+     *
88
+     * @since 1.0.0
89
+     *
90
+     * @param array $args
91
+     *
92
+     * @return string The rendered component.
93
+     */
94
+    public function alert( $args = array() ) {
95
+        return AUI_Component_Alert::get( $args );
96
+    }
97
+
98
+    /**
99
+     * Render and return a bootstrap input component.
100
+     *
101
+     * @since 1.0.0
102
+     *
103
+     * @param array $args
104
+     *
105
+     * @return string The rendered component.
106
+     */
107
+    public function input( $args = array() ) {
108
+        return AUI_Component_Input::input( $args );
109
+    }
110
+
111
+    /**
112
+     * Render and return a bootstrap textarea component.
113
+     *
114
+     * @since 1.0.0
115
+     *
116
+     * @param array $args
117
+     *
118
+     * @return string The rendered component.
119
+     */
120
+    public function textarea( $args = array() ) {
121
+        return AUI_Component_Input::textarea( $args );
122
+    }
123
+
124
+    /**
125
+     * Render and return a bootstrap button component.
126
+     *
127
+     * @since 1.0.0
128
+     *
129
+     * @param array $args
130
+     *
131
+     * @return string The rendered component.
132
+     */
133
+    public function button( $args = array() ) {
134
+        return AUI_Component_Button::get( $args );
135
+    }
136
+
137
+    /**
138
+     * Render and return a bootstrap button component.
139
+     *
140
+     * @since 1.0.0
141
+     *
142
+     * @param array $args
143
+     *
144
+     * @return string The rendered component.
145
+     */
146
+    public function badge( $args = array() ) {
147
+        $defaults = array(
148
+            'class' => 'badge badge-primary align-middle',
149
+        );
150
+
151
+        // maybe set type
152
+        if ( empty( $args['href'] ) ) {
153
+            $defaults['type'] = 'badge';
154
+        }
155
+
156
+        /**
157
+         * Parse incoming $args into an array and merge it with $defaults
158
+         */
159
+        $args = wp_parse_args( $args, $defaults );
160
+
161
+        return AUI_Component_Button::get( $args );
162
+    }
163
+
164
+    /**
165
+     * Render and return a bootstrap dropdown component.
166
+     *
167
+     * @since 1.0.0
168
+     *
169
+     * @param array $args
170
+     *
171
+     * @return string The rendered component.
172
+     */
173
+    public function dropdown( $args = array() ) {
174
+        return AUI_Component_Dropdown::get( $args );
175
+    }
176
+
177
+    /**
178
+     * Render and return a bootstrap select component.
179
+     *
180
+     * @since 1.0.0
181
+     *
182
+     * @param array $args
183
+     *
184
+     * @return string The rendered component.
185
+     */
186
+    public function select( $args = array() ) {
187
+        return AUI_Component_Input::select( $args );
188
+    }
189
+
190
+    /**
191
+     * Render and return a bootstrap radio component.
192
+     *
193
+     * @since 1.0.0
194
+     *
195
+     * @param array $args
196
+     *
197
+     * @return string The rendered component.
198
+     */
199
+    public function radio( $args = array() ) {
200
+        return AUI_Component_Input::radio( $args );
201
+    }
202
+
203
+    /**
204
+     * Render and return a bootstrap pagination component.
205
+     *
206
+     * @since 1.0.0
207
+     *
208
+     * @param array $args
209
+     *
210
+     * @return string The rendered component.
211
+     */
212
+    public function pagination( $args = array() ) {
213
+        return AUI_Component_Pagination::get( $args );
214
+    }
215 215
 
216 216
 }
217 217
\ No newline at end of file
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 2 patches
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,220 +11,220 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Helper {
13 13
 
14
-	/**
15
-	 * A component helper for generating a input name.
16
-	 *
17
-	 * @param $text
18
-	 *
19
-	 * @return string
20
-	 */
21
-	public static function name($text,$multiple = false){
22
-		$output = '';
23
-
24
-		if($text){
25
-			$is_multiple = $multiple ? '[]' : '';
26
-			$output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
27
-		}
28
-
29
-		return $output;
30
-	}
31
-
32
-	/**
33
-	 * A component helper for generating a item id.
34
-	 *
35
-	 * @param $text string The text to be used as the value.
36
-	 *
37
-	 * @return string The sanitized item.
38
-	 */
39
-	public static function id($text){
40
-		$output = '';
41
-
42
-		if($text){
43
-			$output = ' id="'.sanitize_html_class($text).'" ';
44
-		}
45
-
46
-		return $output;
47
-	}
48
-
49
-	/**
50
-	 * A component helper for generating a item title.
51
-	 *
52
-	 * @param $text string The text to be used as the value.
53
-	 *
54
-	 * @return string The sanitized item.
55
-	 */
56
-	public static function title($text){
57
-		$output = '';
58
-
59
-		if($text){
60
-			$output = ' title="'.esc_attr($text).'" ';
61
-		}
62
-
63
-		return $output;
64
-	}
65
-
66
-	/**
67
-	 * A component helper for generating a item value.
68
-	 *
69
-	 * @param $text string The text to be used as the value.
70
-	 *
71
-	 * @return string The sanitized item.
72
-	 */
73
-	public static function value($text){
74
-		$output = '';
75
-
76
-		if($text){
77
-			$output = ' value="'.sanitize_text_field($text).'" ';
78
-		}
79
-
80
-		return $output;
81
-	}
82
-
83
-	/**
84
-	 * A component helper for generating a item class attribute.
85
-	 *
86
-	 * @param $text string The text to be used as the value.
87
-	 *
88
-	 * @return string The sanitized item.
89
-	 */
90
-	public static function class_attr($text){
91
-		$output = '';
92
-
93
-		if($text){
94
-			$classes = self::esc_classes($text);
95
-			if(!empty($classes)){
96
-				$output = ' class="'.$classes.'" ';
97
-			}
98
-		}
99
-
100
-		return $output;
101
-	}
102
-
103
-	/**
104
-	 * Escape a string of classes.
105
-	 *
106
-	 * @param $text
107
-	 *
108
-	 * @return string
109
-	 */
110
-	public static function esc_classes($text){
111
-		$output = '';
112
-
113
-		if($text){
114
-			$classes = explode(" ",$text);
115
-			$classes = array_map("trim",$classes);
116
-			$classes = array_map("sanitize_html_class",$classes);
117
-			if(!empty($classes)){
118
-				$output = implode(" ",$classes);
119
-			}
120
-		}
121
-
122
-		return $output;
123
-
124
-	}
125
-
126
-	/**
127
-	 * @param $args
128
-	 *
129
-	 * @return string
130
-	 */
131
-	public static function data_attributes($args){
132
-		$output = '';
133
-
134
-		if(!empty($args)){
135
-
136
-			foreach($args as $key => $val){
137
-				if(substr( $key, 0, 5 ) === "data-"){
138
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
139
-				}
140
-			}
141
-		}
142
-
143
-		return $output;
144
-	}
145
-
146
-	/**
147
-	 * @param $args
148
-	 *
149
-	 * @return string
150
-	 */
151
-	public static function aria_attributes($args){
152
-		$output = '';
153
-
154
-		if(!empty($args)){
155
-
156
-			foreach($args as $key => $val){
157
-				if(substr( $key, 0, 5 ) === "aria-"){
158
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
159
-				}
160
-			}
161
-		}
162
-
163
-		return $output;
164
-	}
165
-
166
-	/**
167
-	 * Build a font awesome icon from a class.
168
-	 *
169
-	 * @param $class
170
-	 * @param bool $space_after
171
-	 * @param array $extra_attributes An array of extra attributes.
172
-	 *
173
-	 * @return string
174
-	 */
175
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
176
-		$output = '';
177
-
178
-		if($class){
179
-			$classes = self::esc_classes($class);
180
-			if(!empty($classes)){
181
-				$output = '<i class="'.$classes.'" ';
182
-				// extra attributes
183
-				if(!empty($extra_attributes)){
184
-					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185
-				}
186
-				$output .= '></i>';
187
-				if($space_after){
188
-					$output .= " ";
189
-				}
190
-			}
191
-		}
192
-
193
-		return $output;
194
-	}
195
-
196
-	/**
197
-	 * @param $args
198
-	 *
199
-	 * @return string
200
-	 */
201
-	public static function extra_attributes($args){
202
-		$output = '';
203
-
204
-		if(!empty($args) && is_array($args) ){
205
-
206
-			foreach($args as $key => $val){
207
-				$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
208
-			}
209
-		}
210
-
211
-		return $output;
212
-	}
213
-
214
-	/**
215
-	 * @param $args
216
-	 *
217
-	 * @return string
218
-	 */
219
-	public static function help_text($text){
220
-		$output = '';
221
-
222
-		if($text){
223
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
224
-		}
225
-
226
-
227
-		return $output;
228
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     *
19
+     * @return string
20
+     */
21
+    public static function name($text,$multiple = false){
22
+        $output = '';
23
+
24
+        if($text){
25
+            $is_multiple = $multiple ? '[]' : '';
26
+            $output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
27
+        }
28
+
29
+        return $output;
30
+    }
31
+
32
+    /**
33
+     * A component helper for generating a item id.
34
+     *
35
+     * @param $text string The text to be used as the value.
36
+     *
37
+     * @return string The sanitized item.
38
+     */
39
+    public static function id($text){
40
+        $output = '';
41
+
42
+        if($text){
43
+            $output = ' id="'.sanitize_html_class($text).'" ';
44
+        }
45
+
46
+        return $output;
47
+    }
48
+
49
+    /**
50
+     * A component helper for generating a item title.
51
+     *
52
+     * @param $text string The text to be used as the value.
53
+     *
54
+     * @return string The sanitized item.
55
+     */
56
+    public static function title($text){
57
+        $output = '';
58
+
59
+        if($text){
60
+            $output = ' title="'.esc_attr($text).'" ';
61
+        }
62
+
63
+        return $output;
64
+    }
65
+
66
+    /**
67
+     * A component helper for generating a item value.
68
+     *
69
+     * @param $text string The text to be used as the value.
70
+     *
71
+     * @return string The sanitized item.
72
+     */
73
+    public static function value($text){
74
+        $output = '';
75
+
76
+        if($text){
77
+            $output = ' value="'.sanitize_text_field($text).'" ';
78
+        }
79
+
80
+        return $output;
81
+    }
82
+
83
+    /**
84
+     * A component helper for generating a item class attribute.
85
+     *
86
+     * @param $text string The text to be used as the value.
87
+     *
88
+     * @return string The sanitized item.
89
+     */
90
+    public static function class_attr($text){
91
+        $output = '';
92
+
93
+        if($text){
94
+            $classes = self::esc_classes($text);
95
+            if(!empty($classes)){
96
+                $output = ' class="'.$classes.'" ';
97
+            }
98
+        }
99
+
100
+        return $output;
101
+    }
102
+
103
+    /**
104
+     * Escape a string of classes.
105
+     *
106
+     * @param $text
107
+     *
108
+     * @return string
109
+     */
110
+    public static function esc_classes($text){
111
+        $output = '';
112
+
113
+        if($text){
114
+            $classes = explode(" ",$text);
115
+            $classes = array_map("trim",$classes);
116
+            $classes = array_map("sanitize_html_class",$classes);
117
+            if(!empty($classes)){
118
+                $output = implode(" ",$classes);
119
+            }
120
+        }
121
+
122
+        return $output;
123
+
124
+    }
125
+
126
+    /**
127
+     * @param $args
128
+     *
129
+     * @return string
130
+     */
131
+    public static function data_attributes($args){
132
+        $output = '';
133
+
134
+        if(!empty($args)){
135
+
136
+            foreach($args as $key => $val){
137
+                if(substr( $key, 0, 5 ) === "data-"){
138
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
139
+                }
140
+            }
141
+        }
142
+
143
+        return $output;
144
+    }
145
+
146
+    /**
147
+     * @param $args
148
+     *
149
+     * @return string
150
+     */
151
+    public static function aria_attributes($args){
152
+        $output = '';
153
+
154
+        if(!empty($args)){
155
+
156
+            foreach($args as $key => $val){
157
+                if(substr( $key, 0, 5 ) === "aria-"){
158
+                    $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
159
+                }
160
+            }
161
+        }
162
+
163
+        return $output;
164
+    }
165
+
166
+    /**
167
+     * Build a font awesome icon from a class.
168
+     *
169
+     * @param $class
170
+     * @param bool $space_after
171
+     * @param array $extra_attributes An array of extra attributes.
172
+     *
173
+     * @return string
174
+     */
175
+    public static function icon($class,$space_after = false, $extra_attributes = array()){
176
+        $output = '';
177
+
178
+        if($class){
179
+            $classes = self::esc_classes($class);
180
+            if(!empty($classes)){
181
+                $output = '<i class="'.$classes.'" ';
182
+                // extra attributes
183
+                if(!empty($extra_attributes)){
184
+                    $output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185
+                }
186
+                $output .= '></i>';
187
+                if($space_after){
188
+                    $output .= " ";
189
+                }
190
+            }
191
+        }
192
+
193
+        return $output;
194
+    }
195
+
196
+    /**
197
+     * @param $args
198
+     *
199
+     * @return string
200
+     */
201
+    public static function extra_attributes($args){
202
+        $output = '';
203
+
204
+        if(!empty($args) && is_array($args) ){
205
+
206
+            foreach($args as $key => $val){
207
+                $output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
208
+            }
209
+        }
210
+
211
+        return $output;
212
+    }
213
+
214
+    /**
215
+     * @param $args
216
+     *
217
+     * @return string
218
+     */
219
+    public static function help_text($text){
220
+        $output = '';
221
+
222
+        if($text){
223
+            $output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
224
+        }
225
+
226
+
227
+        return $output;
228
+    }
229 229
 
230 230
 }
231 231
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string
20 20
 	 */
21
-	public static function name($text,$multiple = false){
21
+	public static function name($text, $multiple = false) {
22 22
 		$output = '';
23 23
 
24
-		if($text){
24
+		if ($text) {
25 25
 			$is_multiple = $multiple ? '[]' : '';
26
-			$output = ' name="'.sanitize_html_class($text).$is_multiple.'" ';
26
+			$output = ' name="' . sanitize_html_class($text) . $is_multiple . '" ';
27 27
 		}
28 28
 
29 29
 		return $output;
@@ -36,11 +36,11 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return string The sanitized item.
38 38
 	 */
39
-	public static function id($text){
39
+	public static function id($text) {
40 40
 		$output = '';
41 41
 
42
-		if($text){
43
-			$output = ' id="'.sanitize_html_class($text).'" ';
42
+		if ($text) {
43
+			$output = ' id="' . sanitize_html_class($text) . '" ';
44 44
 		}
45 45
 
46 46
 		return $output;
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return string The sanitized item.
55 55
 	 */
56
-	public static function title($text){
56
+	public static function title($text) {
57 57
 		$output = '';
58 58
 
59
-		if($text){
60
-			$output = ' title="'.esc_attr($text).'" ';
59
+		if ($text) {
60
+			$output = ' title="' . esc_attr($text) . '" ';
61 61
 		}
62 62
 
63 63
 		return $output;
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return string The sanitized item.
72 72
 	 */
73
-	public static function value($text){
73
+	public static function value($text) {
74 74
 		$output = '';
75 75
 
76
-		if($text){
77
-			$output = ' value="'.sanitize_text_field($text).'" ';
76
+		if ($text) {
77
+			$output = ' value="' . sanitize_text_field($text) . '" ';
78 78
 		}
79 79
 
80 80
 		return $output;
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return string The sanitized item.
89 89
 	 */
90
-	public static function class_attr($text){
90
+	public static function class_attr($text) {
91 91
 		$output = '';
92 92
 
93
-		if($text){
93
+		if ($text) {
94 94
 			$classes = self::esc_classes($text);
95
-			if(!empty($classes)){
96
-				$output = ' class="'.$classes.'" ';
95
+			if (!empty($classes)) {
96
+				$output = ' class="' . $classes . '" ';
97 97
 			}
98 98
 		}
99 99
 
@@ -107,15 +107,15 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @return string
109 109
 	 */
110
-	public static function esc_classes($text){
110
+	public static function esc_classes($text) {
111 111
 		$output = '';
112 112
 
113
-		if($text){
114
-			$classes = explode(" ",$text);
115
-			$classes = array_map("trim",$classes);
116
-			$classes = array_map("sanitize_html_class",$classes);
117
-			if(!empty($classes)){
118
-				$output = implode(" ",$classes);
113
+		if ($text) {
114
+			$classes = explode(" ", $text);
115
+			$classes = array_map("trim", $classes);
116
+			$classes = array_map("sanitize_html_class", $classes);
117
+			if (!empty($classes)) {
118
+				$output = implode(" ", $classes);
119 119
 			}
120 120
 		}
121 121
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return string
130 130
 	 */
131
-	public static function data_attributes($args){
131
+	public static function data_attributes($args) {
132 132
 		$output = '';
133 133
 
134
-		if(!empty($args)){
134
+		if (!empty($args)) {
135 135
 
136
-			foreach($args as $key => $val){
137
-				if(substr( $key, 0, 5 ) === "data-"){
138
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
136
+			foreach ($args as $key => $val) {
137
+				if (substr($key, 0, 5) === "data-") {
138
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
139 139
 				}
140 140
 			}
141 141
 		}
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return string
150 150
 	 */
151
-	public static function aria_attributes($args){
151
+	public static function aria_attributes($args) {
152 152
 		$output = '';
153 153
 
154
-		if(!empty($args)){
154
+		if (!empty($args)) {
155 155
 
156
-			foreach($args as $key => $val){
157
-				if(substr( $key, 0, 5 ) === "aria-"){
158
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
156
+			foreach ($args as $key => $val) {
157
+				if (substr($key, 0, 5) === "aria-") {
158
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
159 159
 				}
160 160
 			}
161 161
 		}
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string
174 174
 	 */
175
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
175
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
176 176
 		$output = '';
177 177
 
178
-		if($class){
178
+		if ($class) {
179 179
 			$classes = self::esc_classes($class);
180
-			if(!empty($classes)){
181
-				$output = '<i class="'.$classes.'" ';
180
+			if (!empty($classes)) {
181
+				$output = '<i class="' . $classes . '" ';
182 182
 				// extra attributes
183
-				if(!empty($extra_attributes)){
183
+				if (!empty($extra_attributes)) {
184 184
 					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
185 185
 				}
186 186
 				$output .= '></i>';
187
-				if($space_after){
187
+				if ($space_after) {
188 188
 					$output .= " ";
189 189
 				}
190 190
 			}
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return string
200 200
 	 */
201
-	public static function extra_attributes($args){
201
+	public static function extra_attributes($args) {
202 202
 		$output = '';
203 203
 
204
-		if(!empty($args) && is_array($args) ){
204
+		if (!empty($args) && is_array($args)) {
205 205
 
206
-			foreach($args as $key => $val){
207
-				$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
206
+			foreach ($args as $key => $val) {
207
+				$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
208 208
 			}
209 209
 		}
210 210
 
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @return string
218 218
 	 */
219
-	public static function help_text($text){
219
+	public static function help_text($text) {
220 220
 		$output = '';
221 221
 
222
-		if($text){
223
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
222
+		if ($text) {
223
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
224 224
 		}
225 225
 
226 226
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +946 added lines, -946 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,958 +11,958 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'text',
24
-			'name'       => '',
25
-			'class'      => '',
26
-			'id'         => '',
27
-			'placeholder'=> '',
28
-			'title'      => '',
29
-			'value'      => '',
30
-			'required'   => false,
31
-			'label'      => '',
32
-			'label_after'=> false,
33
-			'label_class'=> '',
34
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
-			'help_text'  => '',
36
-			'validation_text'   => '',
37
-			'validation_pattern' => '',
38
-			'no_wrap'    => false,
39
-			'input_group_right' => '',
40
-			'input_group_left' => '',
41
-			'input_group_right_inside' => false, // forces the input group inside the input
42
-			'input_group_left_inside' => false, // forces the input group inside the input
43
-			'step'       => '',
44
-			'switch'     => false, // to show checkbox as a switch
45
-			'checked'   => false, // set a checkbox or radio as selected
46
-			'password_toggle' => true, // toggle view/hide password
47
-			'extra_attributes'  => array() // an array of extra attributes
48
-		);
49
-
50
-		/**
51
-		 * Parse incoming $args into an array and merge it with $defaults
52
-		 */
53
-		$args   = wp_parse_args( $args, $defaults );
54
-		$output = '';
55
-		if ( ! empty( $args['type'] ) ) {
56
-			// hidden label option needs to be empty
57
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
58
-
59
-			$type = sanitize_html_class( $args['type'] );
60
-
61
-			$help_text = '';
62
-			$label = '';
63
-			$label_after = $args['label_after'];
64
-			$label_args = array(
65
-				'title'=> $args['label'],
66
-				'for'=> $args['id'],
67
-				'class' => $args['label_class']." ",
68
-				'label_type' => $args['label_type']
69
-			);
70
-
71
-			// floating labels need label after
72
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
73
-				$label_after = true;
74
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
75
-			}
76
-
77
-			// Some special sauce for files
78
-			if($type=='file' ){
79
-				$label_after = true; // if type file we need the label after
80
-				$args['class'] .= ' custom-file-input ';
81
-			}elseif($type=='checkbox'){
82
-				$label_after = true; // if type file we need the label after
83
-				$args['class'] .= ' custom-control-input ';
84
-			}elseif($type=='datepicker' || $type=='timepicker'){
85
-				$type = 'text';
86
-				$args['class'] .= ' aui-flatpickr bg-initial ';
87
-
88
-				// enqueue the script
89
-				$aui_settings = AyeCode_UI_Settings::instance();
90
-				$aui_settings->enqueue_flatpickr();
91
-			}
92
-
93
-
94
-			// open/type
95
-			$output .= '<input type="' . $type . '" ';
96
-
97
-			// name
98
-			if(!empty($args['name'])){
99
-				$output .= ' name="'.esc_attr($args['name']).'" ';
100
-			}
101
-
102
-			// id
103
-			if(!empty($args['id'])){
104
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
105
-			}
106
-
107
-			// placeholder
108
-			if(!empty($args['placeholder'])){
109
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
110
-			}
111
-
112
-			// title
113
-			if(!empty($args['title'])){
114
-				$output .= ' title="'.esc_attr($args['title']).'" ';
115
-			}
116
-
117
-			// value
118
-			if(!empty($args['value'])){
119
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
120
-			}
121
-
122
-			// checked, for radio and checkboxes
123
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
124
-				$output .= ' checked ';
125
-			}
126
-
127
-			// validation text
128
-			if(!empty($args['validation_text'])){
129
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
130
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
131
-			}
132
-
133
-			// validation_pattern
134
-			if(!empty($args['validation_pattern'])){
135
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
136
-			}
137
-
138
-			// step (for numbers)
139
-			if(!empty($args['step'])){
140
-				$output .= ' step="'.$args['step'].'" ';
141
-			}
142
-
143
-			// required
144
-			if(!empty($args['required'])){
145
-				$output .= ' required ';
146
-			}
147
-
148
-			// class
149
-			$class = !empty($args['class']) ? $args['class'] : '';
150
-			$output .= ' class="form-control '.$class.'" ';
151
-
152
-			// data-attributes
153
-			$output .= AUI_Component_Helper::data_attributes($args);
154
-
155
-			// extra attributes
156
-			if(!empty($args['extra_attributes'])){
157
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
158
-			}
159
-
160
-			// close
161
-			$output .= ' >';
162
-
163
-
164
-			// label
165
-			if(!empty($args['label'])){
166
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
167
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
168
-				$label = self::label( $label_args, $type );
169
-			}
170
-
171
-			// help text
172
-			if(!empty($args['help_text'])){
173
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
174
-			}
175
-
176
-
177
-			// set help text in the correct possition
178
-			if($label_after){
179
-				$output .= $label . $help_text;
180
-			}
181
-
182
-			// some input types need a separate wrap
183
-			if($type == 'file') {
184
-				$output = self::wrap( array(
185
-					'content' => $output,
186
-					'class'   => 'form-group custom-file'
187
-				) );
188
-			}elseif($type == 'checkbox'){
189
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
190
-				$output = self::wrap( array(
191
-					'content' => $output,
192
-					'class'   => 'custom-control '.$wrap_class
193
-				) );
194
-
195
-				if($args['label_type']=='horizontal'){
196
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
197
-				}
198
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
199
-
200
-
201
-				// allow password field to toggle view
202
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'text',
24
+            'name'       => '',
25
+            'class'      => '',
26
+            'id'         => '',
27
+            'placeholder'=> '',
28
+            'title'      => '',
29
+            'value'      => '',
30
+            'required'   => false,
31
+            'label'      => '',
32
+            'label_after'=> false,
33
+            'label_class'=> '',
34
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
+            'help_text'  => '',
36
+            'validation_text'   => '',
37
+            'validation_pattern' => '',
38
+            'no_wrap'    => false,
39
+            'input_group_right' => '',
40
+            'input_group_left' => '',
41
+            'input_group_right_inside' => false, // forces the input group inside the input
42
+            'input_group_left_inside' => false, // forces the input group inside the input
43
+            'step'       => '',
44
+            'switch'     => false, // to show checkbox as a switch
45
+            'checked'   => false, // set a checkbox or radio as selected
46
+            'password_toggle' => true, // toggle view/hide password
47
+            'extra_attributes'  => array() // an array of extra attributes
48
+        );
49
+
50
+        /**
51
+         * Parse incoming $args into an array and merge it with $defaults
52
+         */
53
+        $args   = wp_parse_args( $args, $defaults );
54
+        $output = '';
55
+        if ( ! empty( $args['type'] ) ) {
56
+            // hidden label option needs to be empty
57
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
58
+
59
+            $type = sanitize_html_class( $args['type'] );
60
+
61
+            $help_text = '';
62
+            $label = '';
63
+            $label_after = $args['label_after'];
64
+            $label_args = array(
65
+                'title'=> $args['label'],
66
+                'for'=> $args['id'],
67
+                'class' => $args['label_class']." ",
68
+                'label_type' => $args['label_type']
69
+            );
70
+
71
+            // floating labels need label after
72
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
73
+                $label_after = true;
74
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
75
+            }
76
+
77
+            // Some special sauce for files
78
+            if($type=='file' ){
79
+                $label_after = true; // if type file we need the label after
80
+                $args['class'] .= ' custom-file-input ';
81
+            }elseif($type=='checkbox'){
82
+                $label_after = true; // if type file we need the label after
83
+                $args['class'] .= ' custom-control-input ';
84
+            }elseif($type=='datepicker' || $type=='timepicker'){
85
+                $type = 'text';
86
+                $args['class'] .= ' aui-flatpickr bg-initial ';
87
+
88
+                // enqueue the script
89
+                $aui_settings = AyeCode_UI_Settings::instance();
90
+                $aui_settings->enqueue_flatpickr();
91
+            }
92
+
93
+
94
+            // open/type
95
+            $output .= '<input type="' . $type . '" ';
96
+
97
+            // name
98
+            if(!empty($args['name'])){
99
+                $output .= ' name="'.esc_attr($args['name']).'" ';
100
+            }
101
+
102
+            // id
103
+            if(!empty($args['id'])){
104
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
105
+            }
106
+
107
+            // placeholder
108
+            if(!empty($args['placeholder'])){
109
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
110
+            }
111
+
112
+            // title
113
+            if(!empty($args['title'])){
114
+                $output .= ' title="'.esc_attr($args['title']).'" ';
115
+            }
116
+
117
+            // value
118
+            if(!empty($args['value'])){
119
+                $output .= ' value="'.sanitize_text_field($args['value']).'" ';
120
+            }
121
+
122
+            // checked, for radio and checkboxes
123
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
124
+                $output .= ' checked ';
125
+            }
126
+
127
+            // validation text
128
+            if(!empty($args['validation_text'])){
129
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
130
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
131
+            }
132
+
133
+            // validation_pattern
134
+            if(!empty($args['validation_pattern'])){
135
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
136
+            }
137
+
138
+            // step (for numbers)
139
+            if(!empty($args['step'])){
140
+                $output .= ' step="'.$args['step'].'" ';
141
+            }
142
+
143
+            // required
144
+            if(!empty($args['required'])){
145
+                $output .= ' required ';
146
+            }
147
+
148
+            // class
149
+            $class = !empty($args['class']) ? $args['class'] : '';
150
+            $output .= ' class="form-control '.$class.'" ';
151
+
152
+            // data-attributes
153
+            $output .= AUI_Component_Helper::data_attributes($args);
154
+
155
+            // extra attributes
156
+            if(!empty($args['extra_attributes'])){
157
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
158
+            }
159
+
160
+            // close
161
+            $output .= ' >';
162
+
163
+
164
+            // label
165
+            if(!empty($args['label'])){
166
+                if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
167
+                elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
168
+                $label = self::label( $label_args, $type );
169
+            }
170
+
171
+            // help text
172
+            if(!empty($args['help_text'])){
173
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
174
+            }
175
+
176
+
177
+            // set help text in the correct possition
178
+            if($label_after){
179
+                $output .= $label . $help_text;
180
+            }
181
+
182
+            // some input types need a separate wrap
183
+            if($type == 'file') {
184
+                $output = self::wrap( array(
185
+                    'content' => $output,
186
+                    'class'   => 'form-group custom-file'
187
+                ) );
188
+            }elseif($type == 'checkbox'){
189
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
190
+                $output = self::wrap( array(
191
+                    'content' => $output,
192
+                    'class'   => 'custom-control '.$wrap_class
193
+                ) );
194
+
195
+                if($args['label_type']=='horizontal'){
196
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
197
+                }
198
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
199
+
200
+
201
+                // allow password field to toggle view
202
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
203 203
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
204 204
 var $eli = jQuery(this).parent().parent().find(\'input\');
205 205
 if($el.hasClass(\'fa-eye\'))
206 206
 {$eli.attr(\'type\',\'text\');}
207 207
 else{$eli.attr(\'type\',\'password\');}"
208 208
 ><i class="far fa-fw fa-eye-slash"></i></span>';
209
-			}
210
-
211
-			// input group wraps
212
-			if($args['input_group_left'] || $args['input_group_right']){
213
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
214
-				if($args['input_group_left']){
215
-					$output = self::wrap( array(
216
-						'content' => $output,
217
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
218
-						'input_group_left' => $args['input_group_left'],
219
-						'input_group_left_inside'    => $args['input_group_left_inside']
220
-					) );
221
-				}
222
-				if($args['input_group_right']){
223
-					$output = self::wrap( array(
224
-						'content' => $output,
225
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
226
-						'input_group_right' => $args['input_group_right'],
227
-						'input_group_right_inside'    => $args['input_group_right_inside']
228
-					) );
229
-				}
230
-
231
-			}
232
-
233
-			if(!$label_after){
234
-				$output .= $help_text;
235
-			}
236
-
237
-
238
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
239
-				$output = self::wrap( array(
240
-					'content' => $output,
241
-					'class'   => 'col-sm-10',
242
-				) );
243
-			}
244
-
245
-			if(!$label_after){
246
-				$output = $label . $output;
247
-			}
248
-
249
-			// wrap
250
-			if(!$args['no_wrap']){
251
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
252
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
253
-				$output = self::wrap(array(
254
-					'content' => $output,
255
-					'class'   => $wrap_class,
256
-				));
257
-			}
258
-
259
-
260
-
261
-		}
262
-
263
-		return $output;
264
-	}
265
-
266
-	/**
267
-	 * Build the component.
268
-	 *
269
-	 * @param array $args
270
-	 *
271
-	 * @return string The rendered component.
272
-	 */
273
-	public static function textarea($args = array()){
274
-		$defaults = array(
275
-			'name'       => '',
276
-			'class'      => '',
277
-			'id'         => '',
278
-			'placeholder'=> '',
279
-			'title'      => '',
280
-			'value'      => '',
281
-			'required'   => false,
282
-			'label'      => '',
283
-			'label_after'=> false,
284
-			'label_class'      => '',
285
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
286
-			'help_text'  => '',
287
-			'validation_text'   => '',
288
-			'validation_pattern' => '',
289
-			'no_wrap'    => false,
290
-			'rows'      => '',
291
-			'wysiwyg'   => false,
292
-		);
293
-
294
-		/**
295
-		 * Parse incoming $args into an array and merge it with $defaults
296
-		 */
297
-		$args   = wp_parse_args( $args, $defaults );
298
-		$output = '';
299
-
300
-		// hidden label option needs to be empty
301
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
302
-
303
-		// floating labels don't work with wysiwyg so set it as top
304
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
305
-			$args['label_type'] = 'top';
306
-		}
307
-
308
-		$label_after = $args['label_after'];
309
-
310
-		// floating labels need label after
311
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
312
-			$label_after = true;
313
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
314
-		}
315
-
316
-		// label
317
-		if(!empty($args['label']) && is_array($args['label'])){
318
-		}elseif(!empty($args['label']) && !$label_after){
319
-			$label_args = array(
320
-				'title'=> $args['label'],
321
-				'for'=> $args['id'],
322
-				'class' => $args['label_class']." ",
323
-				'label_type' => $args['label_type']
324
-			);
325
-			$output .= self::label( $label_args );
326
-		}
327
-
328
-		// maybe horizontal label
329
-		if($args['label_type']=='horizontal'){
330
-			$output .= '<div class="col-sm-10">';
331
-		}
332
-
333
-		if(!empty($args['wysiwyg'])){
334
-			ob_start();
335
-			$content = $args['value'];
336
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
337
-			$settings = array(
338
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
339
-				'quicktags'     => false,
340
-				'media_buttons' => false,
341
-				'editor_class'  => 'form-control',
342
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
343
-				'teeny'         => true,
344
-			);
345
-
346
-			// maybe set settings if array
347
-			if(is_array($args['wysiwyg'])){
348
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
349
-			}
350
-
351
-			wp_editor( $content, $editor_id, $settings );
352
-			$output .= ob_get_clean();
353
-		}else{
354
-
355
-			// open
356
-			$output .= '<textarea ';
357
-
358
-			// name
359
-			if(!empty($args['name'])){
360
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
361
-			}
362
-
363
-			// id
364
-			if(!empty($args['id'])){
365
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
366
-			}
367
-
368
-			// placeholder
369
-			if(!empty($args['placeholder'])){
370
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
371
-			}
372
-
373
-			// title
374
-			if(!empty($args['title'])){
375
-				$output .= ' title="'.esc_attr($args['title']).'" ';
376
-			}
377
-
378
-			// validation text
379
-			if(!empty($args['validation_text'])){
380
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
381
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
382
-			}
383
-
384
-			// validation_pattern
385
-			if(!empty($args['validation_pattern'])){
386
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
387
-			}
388
-
389
-			// required
390
-			if(!empty($args['required'])){
391
-				$output .= ' required ';
392
-			}
393
-
394
-			// rows
395
-			if(!empty($args['rows'])){
396
-				$output .= ' rows="'.absint($args['rows']).'" ';
397
-			}
398
-
399
-
400
-			// class
401
-			$class = !empty($args['class']) ? $args['class'] : '';
402
-			$output .= ' class="form-control '.$class.'" ';
403
-
404
-
405
-			// close tag
406
-			$output .= ' >';
407
-
408
-			// value
409
-			if(!empty($args['value'])){
410
-				$output .= sanitize_textarea_field($args['value']);
411
-			}
412
-
413
-			// closing tag
414
-			$output .= '</textarea>';
415
-
416
-		}
417
-
418
-		if(!empty($args['label']) && $label_after){
419
-			$label_args = array(
420
-				'title'=> $args['label'],
421
-				'for'=> $args['id'],
422
-				'class' => $args['label_class']." ",
423
-				'label_type' => $args['label_type']
424
-			);
425
-			$output .= self::label( $label_args );
426
-		}
427
-
428
-		// help text
429
-		if(!empty($args['help_text'])){
430
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
431
-		}
432
-
433
-		// maybe horizontal label
434
-		if($args['label_type']=='horizontal'){
435
-			$output .= '</div>';
436
-		}
437
-
438
-
439
-		// wrap
440
-		if(!$args['no_wrap']){
441
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
442
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
443
-			$output = self::wrap(array(
444
-				'content' => $output,
445
-				'class'   => $wrap_class,
446
-			));
447
-		}
448
-
449
-
450
-		return $output;
451
-	}
452
-
453
-	public static function label($args = array(), $type = ''){
454
-		//<label for="exampleInputEmail1">Email address</label>
455
-		$defaults = array(
456
-			'title'       => 'div',
457
-			'for'      => '',
458
-			'class'      => '',
459
-			'label_type'    => '', // empty = hidden, top, horizontal
460
-		);
461
-
462
-		/**
463
-		 * Parse incoming $args into an array and merge it with $defaults
464
-		 */
465
-		$args   = wp_parse_args( $args, $defaults );
466
-		$output = '';
209
+            }
210
+
211
+            // input group wraps
212
+            if($args['input_group_left'] || $args['input_group_right']){
213
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
214
+                if($args['input_group_left']){
215
+                    $output = self::wrap( array(
216
+                        'content' => $output,
217
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
218
+                        'input_group_left' => $args['input_group_left'],
219
+                        'input_group_left_inside'    => $args['input_group_left_inside']
220
+                    ) );
221
+                }
222
+                if($args['input_group_right']){
223
+                    $output = self::wrap( array(
224
+                        'content' => $output,
225
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
226
+                        'input_group_right' => $args['input_group_right'],
227
+                        'input_group_right_inside'    => $args['input_group_right_inside']
228
+                    ) );
229
+                }
230
+
231
+            }
232
+
233
+            if(!$label_after){
234
+                $output .= $help_text;
235
+            }
236
+
237
+
238
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
239
+                $output = self::wrap( array(
240
+                    'content' => $output,
241
+                    'class'   => 'col-sm-10',
242
+                ) );
243
+            }
244
+
245
+            if(!$label_after){
246
+                $output = $label . $output;
247
+            }
248
+
249
+            // wrap
250
+            if(!$args['no_wrap']){
251
+                $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
252
+                $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
253
+                $output = self::wrap(array(
254
+                    'content' => $output,
255
+                    'class'   => $wrap_class,
256
+                ));
257
+            }
258
+
259
+
260
+
261
+        }
262
+
263
+        return $output;
264
+    }
265
+
266
+    /**
267
+     * Build the component.
268
+     *
269
+     * @param array $args
270
+     *
271
+     * @return string The rendered component.
272
+     */
273
+    public static function textarea($args = array()){
274
+        $defaults = array(
275
+            'name'       => '',
276
+            'class'      => '',
277
+            'id'         => '',
278
+            'placeholder'=> '',
279
+            'title'      => '',
280
+            'value'      => '',
281
+            'required'   => false,
282
+            'label'      => '',
283
+            'label_after'=> false,
284
+            'label_class'      => '',
285
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
286
+            'help_text'  => '',
287
+            'validation_text'   => '',
288
+            'validation_pattern' => '',
289
+            'no_wrap'    => false,
290
+            'rows'      => '',
291
+            'wysiwyg'   => false,
292
+        );
293
+
294
+        /**
295
+         * Parse incoming $args into an array and merge it with $defaults
296
+         */
297
+        $args   = wp_parse_args( $args, $defaults );
298
+        $output = '';
299
+
300
+        // hidden label option needs to be empty
301
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
302
+
303
+        // floating labels don't work with wysiwyg so set it as top
304
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
305
+            $args['label_type'] = 'top';
306
+        }
307
+
308
+        $label_after = $args['label_after'];
309
+
310
+        // floating labels need label after
311
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
312
+            $label_after = true;
313
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
314
+        }
315
+
316
+        // label
317
+        if(!empty($args['label']) && is_array($args['label'])){
318
+        }elseif(!empty($args['label']) && !$label_after){
319
+            $label_args = array(
320
+                'title'=> $args['label'],
321
+                'for'=> $args['id'],
322
+                'class' => $args['label_class']." ",
323
+                'label_type' => $args['label_type']
324
+            );
325
+            $output .= self::label( $label_args );
326
+        }
327
+
328
+        // maybe horizontal label
329
+        if($args['label_type']=='horizontal'){
330
+            $output .= '<div class="col-sm-10">';
331
+        }
332
+
333
+        if(!empty($args['wysiwyg'])){
334
+            ob_start();
335
+            $content = $args['value'];
336
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
337
+            $settings = array(
338
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
339
+                'quicktags'     => false,
340
+                'media_buttons' => false,
341
+                'editor_class'  => 'form-control',
342
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
343
+                'teeny'         => true,
344
+            );
345
+
346
+            // maybe set settings if array
347
+            if(is_array($args['wysiwyg'])){
348
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
349
+            }
350
+
351
+            wp_editor( $content, $editor_id, $settings );
352
+            $output .= ob_get_clean();
353
+        }else{
354
+
355
+            // open
356
+            $output .= '<textarea ';
357
+
358
+            // name
359
+            if(!empty($args['name'])){
360
+                $output .= ' name="'.sanitize_html_class($args['name']).'" ';
361
+            }
362
+
363
+            // id
364
+            if(!empty($args['id'])){
365
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
366
+            }
367
+
368
+            // placeholder
369
+            if(!empty($args['placeholder'])){
370
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
371
+            }
372
+
373
+            // title
374
+            if(!empty($args['title'])){
375
+                $output .= ' title="'.esc_attr($args['title']).'" ';
376
+            }
377
+
378
+            // validation text
379
+            if(!empty($args['validation_text'])){
380
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
381
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
382
+            }
383
+
384
+            // validation_pattern
385
+            if(!empty($args['validation_pattern'])){
386
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
387
+            }
388
+
389
+            // required
390
+            if(!empty($args['required'])){
391
+                $output .= ' required ';
392
+            }
393
+
394
+            // rows
395
+            if(!empty($args['rows'])){
396
+                $output .= ' rows="'.absint($args['rows']).'" ';
397
+            }
398
+
399
+
400
+            // class
401
+            $class = !empty($args['class']) ? $args['class'] : '';
402
+            $output .= ' class="form-control '.$class.'" ';
403
+
404
+
405
+            // close tag
406
+            $output .= ' >';
407
+
408
+            // value
409
+            if(!empty($args['value'])){
410
+                $output .= sanitize_textarea_field($args['value']);
411
+            }
412
+
413
+            // closing tag
414
+            $output .= '</textarea>';
415
+
416
+        }
417
+
418
+        if(!empty($args['label']) && $label_after){
419
+            $label_args = array(
420
+                'title'=> $args['label'],
421
+                'for'=> $args['id'],
422
+                'class' => $args['label_class']." ",
423
+                'label_type' => $args['label_type']
424
+            );
425
+            $output .= self::label( $label_args );
426
+        }
427
+
428
+        // help text
429
+        if(!empty($args['help_text'])){
430
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
431
+        }
432
+
433
+        // maybe horizontal label
434
+        if($args['label_type']=='horizontal'){
435
+            $output .= '</div>';
436
+        }
437
+
438
+
439
+        // wrap
440
+        if(!$args['no_wrap']){
441
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
442
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
443
+            $output = self::wrap(array(
444
+                'content' => $output,
445
+                'class'   => $wrap_class,
446
+            ));
447
+        }
448
+
449
+
450
+        return $output;
451
+    }
452
+
453
+    public static function label($args = array(), $type = ''){
454
+        //<label for="exampleInputEmail1">Email address</label>
455
+        $defaults = array(
456
+            'title'       => 'div',
457
+            'for'      => '',
458
+            'class'      => '',
459
+            'label_type'    => '', // empty = hidden, top, horizontal
460
+        );
461
+
462
+        /**
463
+         * Parse incoming $args into an array and merge it with $defaults
464
+         */
465
+        $args   = wp_parse_args( $args, $defaults );
466
+        $output = '';
467 467
 
468
-		if($args['title']){
468
+        if($args['title']){
469 469
 
470
-			// maybe hide labels //@todo set a global option for visibility class
471
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
472
-				$class = $args['class'];
473
-			}else{
474
-				$class = 'sr-only '.$args['class'];
475
-			}
476
-
477
-			// maybe horizontal
478
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
479
-				$class .= ' col-sm-2 col-form-label';
480
-			}
481
-
482
-			// open
483
-			$output .= '<label ';
484
-
485
-			// for
486
-			if(!empty($args['for'])){
487
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
488
-			}
489
-
490
-			// class
491
-			$output .= ' class="'.$class.'" ';
492
-
493
-			// close
494
-			$output .= '>';
495
-
496
-
497
-			// title, don't escape fully as can contain html
498
-			if(!empty($args['title'])){
499
-				$output .= wp_kses_post($args['title']);
500
-			}
501
-
502
-			// close wrap
503
-			$output .= '</label>';
504
-
505
-
506
-		}
507
-
508
-
509
-		return $output;
510
-	}
511
-
512
-	public static function wrap($args = array()){
513
-		$defaults = array(
514
-			'type'       => 'div',
515
-			'class'      => 'form-group',
516
-			'content'   => '',
517
-			'input_group_left' => '',
518
-			'input_group_right' => '',
519
-			'input_group_left_inside' => false,
520
-			'input_group_right_inside' => false,
521
-		);
522
-
523
-		/**
524
-		 * Parse incoming $args into an array and merge it with $defaults
525
-		 */
526
-		$args   = wp_parse_args( $args, $defaults );
527
-		$output = '';
528
-		if($args['type']){
529
-
530
-			// open
531
-			$output .= '<'.sanitize_html_class($args['type']);
532
-
533
-			// class
534
-			$class = !empty($args['class']) ? $args['class'] : '';
535
-			$output .= ' class="'.$class.'" ';
536
-
537
-			// close wrap
538
-			$output .= ' >';
539
-
540
-
541
-			// Input group left
542
-			if(!empty($args['input_group_left'])){
543
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
544
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
545
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
546
-			}
547
-
548
-			// content
549
-			$output .= $args['content'];
550
-
551
-			// Input group right
552
-			if(!empty($args['input_group_right'])){
553
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
554
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
555
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
556
-			}
557
-
558
-
559
-			// close wrap
560
-			$output .= '</'.sanitize_html_class($args['type']).'>';
561
-
562
-
563
-		}else{
564
-			$output = $args['content'];
565
-		}
566
-
567
-		return $output;
568
-	}
569
-
570
-	/**
571
-	 * Build the component.
572
-	 *
573
-	 * @param array $args
574
-	 *
575
-	 * @return string The rendered component.
576
-	 */
577
-	public static function select($args = array()){
578
-		$defaults = array(
579
-			'class'      => '',
580
-			'id'         => '',
581
-			'title'      => '',
582
-			'value'      => '', // can be an array or a string
583
-			'required'   => false,
584
-			'label'      => '',
585
-			'label_after'=> false,
586
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
587
-			'label_class'      => '',
588
-			'help_text'  => '',
589
-			'placeholder'=> '',
590
-			'options'    => array(),
591
-			'icon'       => '',
592
-			'multiple'   => false,
593
-			'select2'    => false,
594
-			'no_wrap'    => false,
595
-			'extra_attributes'  => array() // an array of extra attributes
596
-		);
597
-
598
-		/**
599
-		 * Parse incoming $args into an array and merge it with $defaults
600
-		 */
601
-		$args   = wp_parse_args( $args, $defaults );
602
-		$output = '';
603
-
604
-		// for now lets hide floating labels
605
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
606
-
607
-		// hidden label option needs to be empty
608
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
609
-
610
-
611
-		$label_after = $args['label_after'];
612
-
613
-		// floating labels need label after
614
-		if( $args['label_type'] == 'floating' ){
615
-			$label_after = true;
616
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
617
-		}
618
-
619
-		// Maybe setup select2
620
-		$is_select2 = false;
621
-		if(!empty($args['select2'])){
622
-			$args['class'] .= ' aui-select2';
623
-			$is_select2 = true;
624
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
625
-			$is_select2 = true;
626
-		}
627
-
628
-		// select2 tags
629
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
630
-			$args['data-tags'] = 'true';
631
-			$args['data-token-separators'] = "[',']";
632
-			$args['multiple'] = true;
633
-		}
634
-
635
-		// select2 placeholder
636
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
637
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
638
-			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
639
-		}
640
-
641
-		// label
642
-		if(!empty($args['label']) && is_array($args['label'])){
643
-		}elseif(!empty($args['label']) && !$label_after){
644
-			$label_args = array(
645
-				'title'=> $args['label'],
646
-				'for'=> $args['id'],
647
-				'class' => $args['label_class']." ",
648
-				'label_type' => $args['label_type']
649
-			);
650
-			$output .= self::label($label_args);
651
-		}
652
-
653
-		// maybe horizontal label
654
-		if($args['label_type']=='horizontal'){
655
-			$output .= '<div class="col-sm-10">';
656
-		}
657
-
658
-		// open/type
659
-		$output .= '<select ';
660
-
661
-		// style
662
-		if($is_select2){
663
-			$output .= " style='width:100%;' ";
664
-		}
665
-
666
-		// class
667
-		$class = !empty($args['class']) ? $args['class'] : '';
668
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
669
-
670
-		// name
671
-		if(!empty($args['name'])){
672
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
673
-		}
674
-
675
-		// id
676
-		if(!empty($args['id'])){
677
-			$output .= AUI_Component_Helper::id($args['id']);
678
-		}
679
-
680
-		// title
681
-		if(!empty($args['title'])){
682
-			$output .= AUI_Component_Helper::title($args['title']);
683
-		}
684
-
685
-		// data-attributes
686
-		$output .= AUI_Component_Helper::data_attributes($args);
687
-
688
-		// aria-attributes
689
-		$output .= AUI_Component_Helper::aria_attributes($args);
690
-
691
-		// extra attributes
692
-		if(!empty($args['extra_attributes'])){
693
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
694
-		}
695
-
696
-		// required
697
-		if(!empty($args['required'])){
698
-			$output .= ' required ';
699
-		}
700
-
701
-		// multiple
702
-		if(!empty($args['multiple'])){
703
-			$output .= ' multiple ';
704
-		}
705
-
706
-		// close opening tag
707
-		$output .= ' >';
708
-
709
-		// placeholder
710
-		if(!empty($args['placeholder']) && !$is_select2){
711
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
712
-		}elseif($is_select2 && !empty($args['placeholder'])){
713
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
714
-		}
715
-
716
-		// Options
717
-		if(!empty($args['options'])){
718
-
719
-			foreach($args['options'] as $val => $name){
720
-				$selected = '';
721
-				if(is_array($name)){
722
-					if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
723
-						$option_label = isset($name['label']) ? $name['label'] : '';
724
-
725
-						$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
726
-					} else {
727
-						$option_label = isset($name['label']) ? $name['label'] : '';
728
-						$option_value = isset($name['value']) ? $name['value'] : '';
729
-						if(!empty($args['multiple']) && !empty($args['value'])){
730
-							$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
731
-						} elseif(!empty($args['value'])) {
732
-							$selected = selected($option_value,stripslashes_deep($args['value']), false);
733
-						}
734
-
735
-						$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
736
-					}
737
-				}else{
738
-					if(!empty($args['value'])){
739
-						if(is_array($args['value'])){
740
-							$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
741
-						} elseif(!empty($args['value'])) {
742
-							$selected = selected( $args['value'], $val, false);
743
-						}
744
-					}
745
-					$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
746
-				}
747
-			}
748
-
749
-		}
750
-
751
-		// closing tag
752
-		$output .= '</select>';
753
-
754
-		if(!empty($args['label']) && $label_after){
755
-			$label_args = array(
756
-				'title'=> $args['label'],
757
-				'for'=> $args['id'],
758
-				'class' => $args['label_class']." ",
759
-				'label_type' => $args['label_type']
760
-			);
761
-			$output .= self::label($label_args);
762
-		}
763
-
764
-		// help text
765
-		if(!empty($args['help_text'])){
766
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
767
-		}
768
-
769
-		// maybe horizontal label
770
-		if($args['label_type']=='horizontal'){
771
-			$output .= '</div>';
772
-		}
773
-
774
-
775
-		// wrap
776
-		if(!$args['no_wrap']){
777
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
778
-			$output = self::wrap(array(
779
-				'content' => $output,
780
-				'class'   => $wrap_class,
781
-			));
782
-		}
783
-
784
-
785
-		return $output;
786
-	}
787
-
788
-	/**
789
-	 * Build the component.
790
-	 *
791
-	 * @param array $args
792
-	 *
793
-	 * @return string The rendered component.
794
-	 */
795
-	public static function radio($args = array()){
796
-		$defaults = array(
797
-			'class'      => '',
798
-			'id'         => '',
799
-			'title'      => '',
800
-			'horizontal' => false, // sets the lable horizontal
801
-			'value'      => '',
802
-			'label'      => '',
803
-			'label_class'=> '',
804
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
805
-			'inline'     => true,
806
-			'required'   => false,
807
-			'options'    => array(),
808
-			'icon'       => '',
809
-			'no_wrap'    => false,
810
-			'extra_attributes'  => array() // an array of extra attributes
811
-		);
812
-
813
-		/**
814
-		 * Parse incoming $args into an array and merge it with $defaults
815
-		 */
816
-		$args   = wp_parse_args( $args, $defaults );
817
-
818
-		// for now lets use horizontal for floating
819
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
820
-
821
-		$label_args = array(
822
-			'title'=> $args['label'],
823
-			'class' => $args['label_class']." pt-0 ",
824
-			'label_type' => $args['label_type']
825
-		);
826
-
827
-		$output = '';
828
-
829
-
830
-
831
-		// label before
832
-		if(!empty($args['label'])){
833
-			$output .= self::label( $label_args, 'radio' );
834
-		}
835
-
836
-		// maybe horizontal label
837
-		if($args['label_type']=='horizontal'){
838
-			$output .= '<div class="col-sm-10">';
839
-		}
840
-
841
-		if(!empty($args['options'])){
842
-			$count = 0;
843
-			foreach($args['options'] as $value => $label){
844
-				$option_args = $args;
845
-				$option_args['value'] = $value;
846
-				$option_args['label'] = $label;
847
-				$option_args['checked'] = $value == $args['value'] ? true : false;
848
-				$output .= self::radio_option($option_args,$count);
849
-				$count++;
850
-			}
851
-		}
852
-
853
-		// maybe horizontal label
854
-		if($args['label_type']=='horizontal'){
855
-			$output .= '</div>';
856
-		}
857
-
858
-
859
-		// wrap
860
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
861
-		$output = self::wrap(array(
862
-			'content' => $output,
863
-			'class'   => $wrap_class,
864
-		));
865
-
866
-
867
-		return $output;
868
-	}
869
-
870
-	/**
871
-	 * Build the component.
872
-	 *
873
-	 * @param array $args
874
-	 *
875
-	 * @return string The rendered component.
876
-	 */
877
-	public static function radio_option($args = array(),$count = ''){
878
-		$defaults = array(
879
-			'class'      => '',
880
-			'id'         => '',
881
-			'title'      => '',
882
-			'value'      => '',
883
-			'required'   => false,
884
-			'inline'     => true,
885
-			'label'      => '',
886
-			'options'    => array(),
887
-			'icon'       => '',
888
-			'no_wrap'    => false,
889
-			'extra_attributes'  => array() // an array of extra attributes
890
-		);
891
-
892
-		/**
893
-		 * Parse incoming $args into an array and merge it with $defaults
894
-		 */
895
-		$args   = wp_parse_args( $args, $defaults );
896
-
897
-		$output = '';
898
-
899
-		// open/type
900
-		$output .= '<input type="radio"';
901
-
902
-		// class
903
-		$output .= ' class="form-check-input" ';
904
-
905
-		// name
906
-		if(!empty($args['name'])){
907
-			$output .= AUI_Component_Helper::name($args['name']);
908
-		}
909
-
910
-		// id
911
-		if(!empty($args['id'])){
912
-			$output .= AUI_Component_Helper::id($args['id'].$count);
913
-		}
914
-
915
-		// title
916
-		if(!empty($args['title'])){
917
-			$output .= AUI_Component_Helper::title($args['title']);
918
-		}
919
-
920
-		// value
921
-		if(!empty($args['value'])){
922
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
923
-		}
924
-
925
-		// checked, for radio and checkboxes
926
-		if( $args['checked'] ){
927
-			$output .= ' checked ';
928
-		}
929
-
930
-		// data-attributes
931
-		$output .= AUI_Component_Helper::data_attributes($args);
932
-
933
-		// aria-attributes
934
-		$output .= AUI_Component_Helper::aria_attributes($args);
935
-
936
-		// extra attributes
937
-		if(!empty($args['extra_attributes'])){
938
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
939
-		}
940
-
941
-		// required
942
-		if(!empty($args['required'])){
943
-			$output .= ' required ';
944
-		}
945
-
946
-		// close opening tag
947
-		$output .= ' >';
948
-
949
-		// label
950
-		if(!empty($args['label']) && is_array($args['label'])){
951
-		}elseif(!empty($args['label'])){
952
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
953
-		}
954
-
955
-		// wrap
956
-		if(!$args['no_wrap']){
957
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
958
-			$output = self::wrap(array(
959
-				'content' => $output,
960
-				'class' => $wrap_class
961
-			));
962
-		}
963
-
964
-
965
-		return $output;
966
-	}
470
+            // maybe hide labels //@todo set a global option for visibility class
471
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
472
+                $class = $args['class'];
473
+            }else{
474
+                $class = 'sr-only '.$args['class'];
475
+            }
476
+
477
+            // maybe horizontal
478
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
479
+                $class .= ' col-sm-2 col-form-label';
480
+            }
481
+
482
+            // open
483
+            $output .= '<label ';
484
+
485
+            // for
486
+            if(!empty($args['for'])){
487
+                $output .= ' for="'.sanitize_text_field($args['for']).'" ';
488
+            }
489
+
490
+            // class
491
+            $output .= ' class="'.$class.'" ';
492
+
493
+            // close
494
+            $output .= '>';
495
+
496
+
497
+            // title, don't escape fully as can contain html
498
+            if(!empty($args['title'])){
499
+                $output .= wp_kses_post($args['title']);
500
+            }
501
+
502
+            // close wrap
503
+            $output .= '</label>';
504
+
505
+
506
+        }
507
+
508
+
509
+        return $output;
510
+    }
511
+
512
+    public static function wrap($args = array()){
513
+        $defaults = array(
514
+            'type'       => 'div',
515
+            'class'      => 'form-group',
516
+            'content'   => '',
517
+            'input_group_left' => '',
518
+            'input_group_right' => '',
519
+            'input_group_left_inside' => false,
520
+            'input_group_right_inside' => false,
521
+        );
522
+
523
+        /**
524
+         * Parse incoming $args into an array and merge it with $defaults
525
+         */
526
+        $args   = wp_parse_args( $args, $defaults );
527
+        $output = '';
528
+        if($args['type']){
529
+
530
+            // open
531
+            $output .= '<'.sanitize_html_class($args['type']);
532
+
533
+            // class
534
+            $class = !empty($args['class']) ? $args['class'] : '';
535
+            $output .= ' class="'.$class.'" ';
536
+
537
+            // close wrap
538
+            $output .= ' >';
539
+
540
+
541
+            // Input group left
542
+            if(!empty($args['input_group_left'])){
543
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
544
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
545
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
546
+            }
547
+
548
+            // content
549
+            $output .= $args['content'];
550
+
551
+            // Input group right
552
+            if(!empty($args['input_group_right'])){
553
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
554
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
555
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
556
+            }
557
+
558
+
559
+            // close wrap
560
+            $output .= '</'.sanitize_html_class($args['type']).'>';
561
+
562
+
563
+        }else{
564
+            $output = $args['content'];
565
+        }
566
+
567
+        return $output;
568
+    }
569
+
570
+    /**
571
+     * Build the component.
572
+     *
573
+     * @param array $args
574
+     *
575
+     * @return string The rendered component.
576
+     */
577
+    public static function select($args = array()){
578
+        $defaults = array(
579
+            'class'      => '',
580
+            'id'         => '',
581
+            'title'      => '',
582
+            'value'      => '', // can be an array or a string
583
+            'required'   => false,
584
+            'label'      => '',
585
+            'label_after'=> false,
586
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
587
+            'label_class'      => '',
588
+            'help_text'  => '',
589
+            'placeholder'=> '',
590
+            'options'    => array(),
591
+            'icon'       => '',
592
+            'multiple'   => false,
593
+            'select2'    => false,
594
+            'no_wrap'    => false,
595
+            'extra_attributes'  => array() // an array of extra attributes
596
+        );
597
+
598
+        /**
599
+         * Parse incoming $args into an array and merge it with $defaults
600
+         */
601
+        $args   = wp_parse_args( $args, $defaults );
602
+        $output = '';
603
+
604
+        // for now lets hide floating labels
605
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
606
+
607
+        // hidden label option needs to be empty
608
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
609
+
610
+
611
+        $label_after = $args['label_after'];
612
+
613
+        // floating labels need label after
614
+        if( $args['label_type'] == 'floating' ){
615
+            $label_after = true;
616
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
617
+        }
618
+
619
+        // Maybe setup select2
620
+        $is_select2 = false;
621
+        if(!empty($args['select2'])){
622
+            $args['class'] .= ' aui-select2';
623
+            $is_select2 = true;
624
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
625
+            $is_select2 = true;
626
+        }
627
+
628
+        // select2 tags
629
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
630
+            $args['data-tags'] = 'true';
631
+            $args['data-token-separators'] = "[',']";
632
+            $args['multiple'] = true;
633
+        }
634
+
635
+        // select2 placeholder
636
+        if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
637
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
638
+            $args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
639
+        }
640
+
641
+        // label
642
+        if(!empty($args['label']) && is_array($args['label'])){
643
+        }elseif(!empty($args['label']) && !$label_after){
644
+            $label_args = array(
645
+                'title'=> $args['label'],
646
+                'for'=> $args['id'],
647
+                'class' => $args['label_class']." ",
648
+                'label_type' => $args['label_type']
649
+            );
650
+            $output .= self::label($label_args);
651
+        }
652
+
653
+        // maybe horizontal label
654
+        if($args['label_type']=='horizontal'){
655
+            $output .= '<div class="col-sm-10">';
656
+        }
657
+
658
+        // open/type
659
+        $output .= '<select ';
660
+
661
+        // style
662
+        if($is_select2){
663
+            $output .= " style='width:100%;' ";
664
+        }
665
+
666
+        // class
667
+        $class = !empty($args['class']) ? $args['class'] : '';
668
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
669
+
670
+        // name
671
+        if(!empty($args['name'])){
672
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
673
+        }
674
+
675
+        // id
676
+        if(!empty($args['id'])){
677
+            $output .= AUI_Component_Helper::id($args['id']);
678
+        }
679
+
680
+        // title
681
+        if(!empty($args['title'])){
682
+            $output .= AUI_Component_Helper::title($args['title']);
683
+        }
684
+
685
+        // data-attributes
686
+        $output .= AUI_Component_Helper::data_attributes($args);
687
+
688
+        // aria-attributes
689
+        $output .= AUI_Component_Helper::aria_attributes($args);
690
+
691
+        // extra attributes
692
+        if(!empty($args['extra_attributes'])){
693
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
694
+        }
695
+
696
+        // required
697
+        if(!empty($args['required'])){
698
+            $output .= ' required ';
699
+        }
700
+
701
+        // multiple
702
+        if(!empty($args['multiple'])){
703
+            $output .= ' multiple ';
704
+        }
705
+
706
+        // close opening tag
707
+        $output .= ' >';
708
+
709
+        // placeholder
710
+        if(!empty($args['placeholder']) && !$is_select2){
711
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
712
+        }elseif($is_select2 && !empty($args['placeholder'])){
713
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
714
+        }
715
+
716
+        // Options
717
+        if(!empty($args['options'])){
718
+
719
+            foreach($args['options'] as $val => $name){
720
+                $selected = '';
721
+                if(is_array($name)){
722
+                    if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
723
+                        $option_label = isset($name['label']) ? $name['label'] : '';
724
+
725
+                        $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
726
+                    } else {
727
+                        $option_label = isset($name['label']) ? $name['label'] : '';
728
+                        $option_value = isset($name['value']) ? $name['value'] : '';
729
+                        if(!empty($args['multiple']) && !empty($args['value'])){
730
+                            $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
731
+                        } elseif(!empty($args['value'])) {
732
+                            $selected = selected($option_value,stripslashes_deep($args['value']), false);
733
+                        }
734
+
735
+                        $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
736
+                    }
737
+                }else{
738
+                    if(!empty($args['value'])){
739
+                        if(is_array($args['value'])){
740
+                            $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
741
+                        } elseif(!empty($args['value'])) {
742
+                            $selected = selected( $args['value'], $val, false);
743
+                        }
744
+                    }
745
+                    $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
746
+                }
747
+            }
748
+
749
+        }
750
+
751
+        // closing tag
752
+        $output .= '</select>';
753
+
754
+        if(!empty($args['label']) && $label_after){
755
+            $label_args = array(
756
+                'title'=> $args['label'],
757
+                'for'=> $args['id'],
758
+                'class' => $args['label_class']." ",
759
+                'label_type' => $args['label_type']
760
+            );
761
+            $output .= self::label($label_args);
762
+        }
763
+
764
+        // help text
765
+        if(!empty($args['help_text'])){
766
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
767
+        }
768
+
769
+        // maybe horizontal label
770
+        if($args['label_type']=='horizontal'){
771
+            $output .= '</div>';
772
+        }
773
+
774
+
775
+        // wrap
776
+        if(!$args['no_wrap']){
777
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
778
+            $output = self::wrap(array(
779
+                'content' => $output,
780
+                'class'   => $wrap_class,
781
+            ));
782
+        }
783
+
784
+
785
+        return $output;
786
+    }
787
+
788
+    /**
789
+     * Build the component.
790
+     *
791
+     * @param array $args
792
+     *
793
+     * @return string The rendered component.
794
+     */
795
+    public static function radio($args = array()){
796
+        $defaults = array(
797
+            'class'      => '',
798
+            'id'         => '',
799
+            'title'      => '',
800
+            'horizontal' => false, // sets the lable horizontal
801
+            'value'      => '',
802
+            'label'      => '',
803
+            'label_class'=> '',
804
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
805
+            'inline'     => true,
806
+            'required'   => false,
807
+            'options'    => array(),
808
+            'icon'       => '',
809
+            'no_wrap'    => false,
810
+            'extra_attributes'  => array() // an array of extra attributes
811
+        );
812
+
813
+        /**
814
+         * Parse incoming $args into an array and merge it with $defaults
815
+         */
816
+        $args   = wp_parse_args( $args, $defaults );
817
+
818
+        // for now lets use horizontal for floating
819
+        if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
820
+
821
+        $label_args = array(
822
+            'title'=> $args['label'],
823
+            'class' => $args['label_class']." pt-0 ",
824
+            'label_type' => $args['label_type']
825
+        );
826
+
827
+        $output = '';
828
+
829
+
830
+
831
+        // label before
832
+        if(!empty($args['label'])){
833
+            $output .= self::label( $label_args, 'radio' );
834
+        }
835
+
836
+        // maybe horizontal label
837
+        if($args['label_type']=='horizontal'){
838
+            $output .= '<div class="col-sm-10">';
839
+        }
840
+
841
+        if(!empty($args['options'])){
842
+            $count = 0;
843
+            foreach($args['options'] as $value => $label){
844
+                $option_args = $args;
845
+                $option_args['value'] = $value;
846
+                $option_args['label'] = $label;
847
+                $option_args['checked'] = $value == $args['value'] ? true : false;
848
+                $output .= self::radio_option($option_args,$count);
849
+                $count++;
850
+            }
851
+        }
852
+
853
+        // maybe horizontal label
854
+        if($args['label_type']=='horizontal'){
855
+            $output .= '</div>';
856
+        }
857
+
858
+
859
+        // wrap
860
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
861
+        $output = self::wrap(array(
862
+            'content' => $output,
863
+            'class'   => $wrap_class,
864
+        ));
865
+
866
+
867
+        return $output;
868
+    }
869
+
870
+    /**
871
+     * Build the component.
872
+     *
873
+     * @param array $args
874
+     *
875
+     * @return string The rendered component.
876
+     */
877
+    public static function radio_option($args = array(),$count = ''){
878
+        $defaults = array(
879
+            'class'      => '',
880
+            'id'         => '',
881
+            'title'      => '',
882
+            'value'      => '',
883
+            'required'   => false,
884
+            'inline'     => true,
885
+            'label'      => '',
886
+            'options'    => array(),
887
+            'icon'       => '',
888
+            'no_wrap'    => false,
889
+            'extra_attributes'  => array() // an array of extra attributes
890
+        );
891
+
892
+        /**
893
+         * Parse incoming $args into an array and merge it with $defaults
894
+         */
895
+        $args   = wp_parse_args( $args, $defaults );
896
+
897
+        $output = '';
898
+
899
+        // open/type
900
+        $output .= '<input type="radio"';
901
+
902
+        // class
903
+        $output .= ' class="form-check-input" ';
904
+
905
+        // name
906
+        if(!empty($args['name'])){
907
+            $output .= AUI_Component_Helper::name($args['name']);
908
+        }
909
+
910
+        // id
911
+        if(!empty($args['id'])){
912
+            $output .= AUI_Component_Helper::id($args['id'].$count);
913
+        }
914
+
915
+        // title
916
+        if(!empty($args['title'])){
917
+            $output .= AUI_Component_Helper::title($args['title']);
918
+        }
919
+
920
+        // value
921
+        if(!empty($args['value'])){
922
+            $output .= ' value="'.sanitize_text_field($args['value']).'" ';
923
+        }
924
+
925
+        // checked, for radio and checkboxes
926
+        if( $args['checked'] ){
927
+            $output .= ' checked ';
928
+        }
929
+
930
+        // data-attributes
931
+        $output .= AUI_Component_Helper::data_attributes($args);
932
+
933
+        // aria-attributes
934
+        $output .= AUI_Component_Helper::aria_attributes($args);
935
+
936
+        // extra attributes
937
+        if(!empty($args['extra_attributes'])){
938
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
939
+        }
940
+
941
+        // required
942
+        if(!empty($args['required'])){
943
+            $output .= ' required ';
944
+        }
945
+
946
+        // close opening tag
947
+        $output .= ' >';
948
+
949
+        // label
950
+        if(!empty($args['label']) && is_array($args['label'])){
951
+        }elseif(!empty($args['label'])){
952
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
953
+        }
954
+
955
+        // wrap
956
+        if(!$args['no_wrap']){
957
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
958
+            $output = self::wrap(array(
959
+                'content' => $output,
960
+                'class' => $wrap_class
961
+            ));
962
+        }
963
+
964
+
965
+        return $output;
966
+    }
967 967
 
968 968
 }
969 969
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input($args = array()){
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'text',
24 24
 			'name'       => '',
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		/**
51 51
 		 * Parse incoming $args into an array and merge it with $defaults
52 52
 		 */
53
-		$args   = wp_parse_args( $args, $defaults );
53
+		$args   = wp_parse_args($args, $defaults);
54 54
 		$output = '';
55
-		if ( ! empty( $args['type'] ) ) {
55
+		if (!empty($args['type'])) {
56 56
 			// hidden label option needs to be empty
57 57
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
58 58
 
59
-			$type = sanitize_html_class( $args['type'] );
59
+			$type = sanitize_html_class($args['type']);
60 60
 
61 61
 			$help_text = '';
62 62
 			$label = '';
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 			$label_args = array(
65 65
 				'title'=> $args['label'],
66 66
 				'for'=> $args['id'],
67
-				'class' => $args['label_class']." ",
67
+				'class' => $args['label_class'] . " ",
68 68
 				'label_type' => $args['label_type']
69 69
 			);
70 70
 
71 71
 			// floating labels need label after
72
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
72
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
73 73
 				$label_after = true;
74 74
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
75 75
 			}
76 76
 
77 77
 			// Some special sauce for files
78
-			if($type=='file' ){
78
+			if ($type == 'file') {
79 79
 				$label_after = true; // if type file we need the label after
80 80
 				$args['class'] .= ' custom-file-input ';
81
-			}elseif($type=='checkbox'){
81
+			}elseif ($type == 'checkbox') {
82 82
 				$label_after = true; // if type file we need the label after
83 83
 				$args['class'] .= ' custom-control-input ';
84
-			}elseif($type=='datepicker' || $type=='timepicker'){
84
+			}elseif ($type == 'datepicker' || $type == 'timepicker') {
85 85
 				$type = 'text';
86 86
 				$args['class'] .= ' aui-flatpickr bg-initial ';
87 87
 
@@ -95,65 +95,65 @@  discard block
 block discarded – undo
95 95
 			$output .= '<input type="' . $type . '" ';
96 96
 
97 97
 			// name
98
-			if(!empty($args['name'])){
99
-				$output .= ' name="'.esc_attr($args['name']).'" ';
98
+			if (!empty($args['name'])) {
99
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
100 100
 			}
101 101
 
102 102
 			// id
103
-			if(!empty($args['id'])){
104
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
103
+			if (!empty($args['id'])) {
104
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
105 105
 			}
106 106
 
107 107
 			// placeholder
108
-			if(!empty($args['placeholder'])){
109
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
108
+			if (!empty($args['placeholder'])) {
109
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
110 110
 			}
111 111
 
112 112
 			// title
113
-			if(!empty($args['title'])){
114
-				$output .= ' title="'.esc_attr($args['title']).'" ';
113
+			if (!empty($args['title'])) {
114
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
115 115
 			}
116 116
 
117 117
 			// value
118
-			if(!empty($args['value'])){
119
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
118
+			if (!empty($args['value'])) {
119
+				$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
120 120
 			}
121 121
 
122 122
 			// checked, for radio and checkboxes
123
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
123
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
124 124
 				$output .= ' checked ';
125 125
 			}
126 126
 
127 127
 			// validation text
128
-			if(!empty($args['validation_text'])){
129
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
128
+			if (!empty($args['validation_text'])) {
129
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
130 130
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
131 131
 			}
132 132
 
133 133
 			// validation_pattern
134
-			if(!empty($args['validation_pattern'])){
135
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
134
+			if (!empty($args['validation_pattern'])) {
135
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
136 136
 			}
137 137
 
138 138
 			// step (for numbers)
139
-			if(!empty($args['step'])){
140
-				$output .= ' step="'.$args['step'].'" ';
139
+			if (!empty($args['step'])) {
140
+				$output .= ' step="' . $args['step'] . '" ';
141 141
 			}
142 142
 
143 143
 			// required
144
-			if(!empty($args['required'])){
144
+			if (!empty($args['required'])) {
145 145
 				$output .= ' required ';
146 146
 			}
147 147
 
148 148
 			// class
149 149
 			$class = !empty($args['class']) ? $args['class'] : '';
150
-			$output .= ' class="form-control '.$class.'" ';
150
+			$output .= ' class="form-control ' . $class . '" ';
151 151
 
152 152
 			// data-attributes
153 153
 			$output .= AUI_Component_Helper::data_attributes($args);
154 154
 
155 155
 			// extra attributes
156
-			if(!empty($args['extra_attributes'])){
156
+			if (!empty($args['extra_attributes'])) {
157 157
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
158 158
 			}
159 159
 
@@ -162,40 +162,40 @@  discard block
 block discarded – undo
162 162
 
163 163
 
164 164
 			// label
165
-			if(!empty($args['label'])){
166
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
167
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
168
-				$label = self::label( $label_args, $type );
165
+			if (!empty($args['label'])) {
166
+				if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; }
167
+				elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; }
168
+				$label = self::label($label_args, $type);
169 169
 			}
170 170
 
171 171
 			// help text
172
-			if(!empty($args['help_text'])){
172
+			if (!empty($args['help_text'])) {
173 173
 				$help_text = AUI_Component_Helper::help_text($args['help_text']);
174 174
 			}
175 175
 
176 176
 
177 177
 			// set help text in the correct possition
178
-			if($label_after){
178
+			if ($label_after) {
179 179
 				$output .= $label . $help_text;
180 180
 			}
181 181
 
182 182
 			// some input types need a separate wrap
183
-			if($type == 'file') {
184
-				$output = self::wrap( array(
183
+			if ($type == 'file') {
184
+				$output = self::wrap(array(
185 185
 					'content' => $output,
186 186
 					'class'   => 'form-group custom-file'
187
-				) );
188
-			}elseif($type == 'checkbox'){
187
+				));
188
+			}elseif ($type == 'checkbox') {
189 189
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
190
-				$output = self::wrap( array(
190
+				$output = self::wrap(array(
191 191
 					'content' => $output,
192
-					'class'   => 'custom-control '.$wrap_class
193
-				) );
192
+					'class'   => 'custom-control ' . $wrap_class
193
+				));
194 194
 
195
-				if($args['label_type']=='horizontal'){
195
+				if ($args['label_type'] == 'horizontal') {
196 196
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
197 197
 				}
198
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
198
+			}elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
199 199
 
200 200
 
201 201
 				// allow password field to toggle view
@@ -209,47 +209,47 @@  discard block
 block discarded – undo
209 209
 			}
210 210
 
211 211
 			// input group wraps
212
-			if($args['input_group_left'] || $args['input_group_right']){
212
+			if ($args['input_group_left'] || $args['input_group_right']) {
213 213
 				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
214
-				if($args['input_group_left']){
215
-					$output = self::wrap( array(
214
+				if ($args['input_group_left']) {
215
+					$output = self::wrap(array(
216 216
 						'content' => $output,
217
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
217
+						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
218 218
 						'input_group_left' => $args['input_group_left'],
219 219
 						'input_group_left_inside'    => $args['input_group_left_inside']
220
-					) );
220
+					));
221 221
 				}
222
-				if($args['input_group_right']){
223
-					$output = self::wrap( array(
222
+				if ($args['input_group_right']) {
223
+					$output = self::wrap(array(
224 224
 						'content' => $output,
225
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
225
+						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
226 226
 						'input_group_right' => $args['input_group_right'],
227 227
 						'input_group_right_inside'    => $args['input_group_right_inside']
228
-					) );
228
+					));
229 229
 				}
230 230
 
231 231
 			}
232 232
 
233
-			if(!$label_after){
233
+			if (!$label_after) {
234 234
 				$output .= $help_text;
235 235
 			}
236 236
 
237 237
 
238
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
239
-				$output = self::wrap( array(
238
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
239
+				$output = self::wrap(array(
240 240
 					'content' => $output,
241 241
 					'class'   => 'col-sm-10',
242
-				) );
242
+				));
243 243
 			}
244 244
 
245
-			if(!$label_after){
245
+			if (!$label_after) {
246 246
 				$output = $label . $output;
247 247
 			}
248 248
 
249 249
 			// wrap
250
-			if(!$args['no_wrap']){
251
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
252
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
250
+			if (!$args['no_wrap']) {
251
+				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
252
+				$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
253 253
 				$output = self::wrap(array(
254 254
 					'content' => $output,
255 255
 					'class'   => $wrap_class,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return string The rendered component.
272 272
 	 */
273
-	public static function textarea($args = array()){
273
+	public static function textarea($args = array()) {
274 274
 		$defaults = array(
275 275
 			'name'       => '',
276 276
 			'class'      => '',
@@ -294,43 +294,43 @@  discard block
 block discarded – undo
294 294
 		/**
295 295
 		 * Parse incoming $args into an array and merge it with $defaults
296 296
 		 */
297
-		$args   = wp_parse_args( $args, $defaults );
297
+		$args   = wp_parse_args($args, $defaults);
298 298
 		$output = '';
299 299
 
300 300
 		// hidden label option needs to be empty
301 301
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
302 302
 
303 303
 		// floating labels don't work with wysiwyg so set it as top
304
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
304
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
305 305
 			$args['label_type'] = 'top';
306 306
 		}
307 307
 
308 308
 		$label_after = $args['label_after'];
309 309
 
310 310
 		// floating labels need label after
311
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
311
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
312 312
 			$label_after = true;
313 313
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
314 314
 		}
315 315
 
316 316
 		// label
317
-		if(!empty($args['label']) && is_array($args['label'])){
318
-		}elseif(!empty($args['label']) && !$label_after){
317
+		if (!empty($args['label']) && is_array($args['label'])) {
318
+		}elseif (!empty($args['label']) && !$label_after) {
319 319
 			$label_args = array(
320 320
 				'title'=> $args['label'],
321 321
 				'for'=> $args['id'],
322
-				'class' => $args['label_class']." ",
322
+				'class' => $args['label_class'] . " ",
323 323
 				'label_type' => $args['label_type']
324 324
 			);
325
-			$output .= self::label( $label_args );
325
+			$output .= self::label($label_args);
326 326
 		}
327 327
 
328 328
 		// maybe horizontal label
329
-		if($args['label_type']=='horizontal'){
329
+		if ($args['label_type'] == 'horizontal') {
330 330
 			$output .= '<div class="col-sm-10">';
331 331
 		}
332 332
 
333
-		if(!empty($args['wysiwyg'])){
333
+		if (!empty($args['wysiwyg'])) {
334 334
 			ob_start();
335 335
 			$content = $args['value'];
336 336
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -344,69 +344,69 @@  discard block
 block discarded – undo
344 344
 			);
345 345
 
346 346
 			// maybe set settings if array
347
-			if(is_array($args['wysiwyg'])){
348
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
347
+			if (is_array($args['wysiwyg'])) {
348
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
349 349
 			}
350 350
 
351
-			wp_editor( $content, $editor_id, $settings );
351
+			wp_editor($content, $editor_id, $settings);
352 352
 			$output .= ob_get_clean();
353
-		}else{
353
+		} else {
354 354
 
355 355
 			// open
356 356
 			$output .= '<textarea ';
357 357
 
358 358
 			// name
359
-			if(!empty($args['name'])){
360
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
359
+			if (!empty($args['name'])) {
360
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
361 361
 			}
362 362
 
363 363
 			// id
364
-			if(!empty($args['id'])){
365
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
364
+			if (!empty($args['id'])) {
365
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
366 366
 			}
367 367
 
368 368
 			// placeholder
369
-			if(!empty($args['placeholder'])){
370
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
369
+			if (!empty($args['placeholder'])) {
370
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
371 371
 			}
372 372
 
373 373
 			// title
374
-			if(!empty($args['title'])){
375
-				$output .= ' title="'.esc_attr($args['title']).'" ';
374
+			if (!empty($args['title'])) {
375
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
376 376
 			}
377 377
 
378 378
 			// validation text
379
-			if(!empty($args['validation_text'])){
380
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
379
+			if (!empty($args['validation_text'])) {
380
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
381 381
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
382 382
 			}
383 383
 
384 384
 			// validation_pattern
385
-			if(!empty($args['validation_pattern'])){
386
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
385
+			if (!empty($args['validation_pattern'])) {
386
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
387 387
 			}
388 388
 
389 389
 			// required
390
-			if(!empty($args['required'])){
390
+			if (!empty($args['required'])) {
391 391
 				$output .= ' required ';
392 392
 			}
393 393
 
394 394
 			// rows
395
-			if(!empty($args['rows'])){
396
-				$output .= ' rows="'.absint($args['rows']).'" ';
395
+			if (!empty($args['rows'])) {
396
+				$output .= ' rows="' . absint($args['rows']) . '" ';
397 397
 			}
398 398
 
399 399
 
400 400
 			// class
401 401
 			$class = !empty($args['class']) ? $args['class'] : '';
402
-			$output .= ' class="form-control '.$class.'" ';
402
+			$output .= ' class="form-control ' . $class . '" ';
403 403
 
404 404
 
405 405
 			// close tag
406 406
 			$output .= ' >';
407 407
 
408 408
 			// value
409
-			if(!empty($args['value'])){
409
+			if (!empty($args['value'])) {
410 410
 				$output .= sanitize_textarea_field($args['value']);
411 411
 			}
412 412
 
@@ -415,31 +415,31 @@  discard block
 block discarded – undo
415 415
 
416 416
 		}
417 417
 
418
-		if(!empty($args['label']) && $label_after){
418
+		if (!empty($args['label']) && $label_after) {
419 419
 			$label_args = array(
420 420
 				'title'=> $args['label'],
421 421
 				'for'=> $args['id'],
422
-				'class' => $args['label_class']." ",
422
+				'class' => $args['label_class'] . " ",
423 423
 				'label_type' => $args['label_type']
424 424
 			);
425
-			$output .= self::label( $label_args );
425
+			$output .= self::label($label_args);
426 426
 		}
427 427
 
428 428
 		// help text
429
-		if(!empty($args['help_text'])){
429
+		if (!empty($args['help_text'])) {
430 430
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
431 431
 		}
432 432
 
433 433
 		// maybe horizontal label
434
-		if($args['label_type']=='horizontal'){
434
+		if ($args['label_type'] == 'horizontal') {
435 435
 			$output .= '</div>';
436 436
 		}
437 437
 
438 438
 
439 439
 		// wrap
440
-		if(!$args['no_wrap']){
441
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
442
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
440
+		if (!$args['no_wrap']) {
441
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
442
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
443 443
 			$output = self::wrap(array(
444 444
 				'content' => $output,
445 445
 				'class'   => $wrap_class,
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		return $output;
451 451
 	}
452 452
 
453
-	public static function label($args = array(), $type = ''){
453
+	public static function label($args = array(), $type = '') {
454 454
 		//<label for="exampleInputEmail1">Email address</label>
455 455
 		$defaults = array(
456 456
 			'title'       => 'div',
@@ -462,20 +462,20 @@  discard block
 block discarded – undo
462 462
 		/**
463 463
 		 * Parse incoming $args into an array and merge it with $defaults
464 464
 		 */
465
-		$args   = wp_parse_args( $args, $defaults );
465
+		$args   = wp_parse_args($args, $defaults);
466 466
 		$output = '';
467 467
 
468
-		if($args['title']){
468
+		if ($args['title']) {
469 469
 
470 470
 			// maybe hide labels //@todo set a global option for visibility class
471
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
471
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
472 472
 				$class = $args['class'];
473
-			}else{
474
-				$class = 'sr-only '.$args['class'];
473
+			} else {
474
+				$class = 'sr-only ' . $args['class'];
475 475
 			}
476 476
 
477 477
 			// maybe horizontal
478
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
478
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
479 479
 				$class .= ' col-sm-2 col-form-label';
480 480
 			}
481 481
 
@@ -483,19 +483,19 @@  discard block
 block discarded – undo
483 483
 			$output .= '<label ';
484 484
 
485 485
 			// for
486
-			if(!empty($args['for'])){
487
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
486
+			if (!empty($args['for'])) {
487
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
488 488
 			}
489 489
 
490 490
 			// class
491
-			$output .= ' class="'.$class.'" ';
491
+			$output .= ' class="' . $class . '" ';
492 492
 
493 493
 			// close
494 494
 			$output .= '>';
495 495
 
496 496
 
497 497
 			// title, don't escape fully as can contain html
498
-			if(!empty($args['title'])){
498
+			if (!empty($args['title'])) {
499 499
 				$output .= wp_kses_post($args['title']);
500 500
 			}
501 501
 
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		return $output;
510 510
 	}
511 511
 
512
-	public static function wrap($args = array()){
512
+	public static function wrap($args = array()) {
513 513
 		$defaults = array(
514 514
 			'type'       => 'div',
515 515
 			'class'      => 'form-group',
@@ -523,44 +523,44 @@  discard block
 block discarded – undo
523 523
 		/**
524 524
 		 * Parse incoming $args into an array and merge it with $defaults
525 525
 		 */
526
-		$args   = wp_parse_args( $args, $defaults );
526
+		$args   = wp_parse_args($args, $defaults);
527 527
 		$output = '';
528
-		if($args['type']){
528
+		if ($args['type']) {
529 529
 
530 530
 			// open
531
-			$output .= '<'.sanitize_html_class($args['type']);
531
+			$output .= '<' . sanitize_html_class($args['type']);
532 532
 
533 533
 			// class
534 534
 			$class = !empty($args['class']) ? $args['class'] : '';
535
-			$output .= ' class="'.$class.'" ';
535
+			$output .= ' class="' . $class . '" ';
536 536
 
537 537
 			// close wrap
538 538
 			$output .= ' >';
539 539
 
540 540
 
541 541
 			// Input group left
542
-			if(!empty($args['input_group_left'])){
542
+			if (!empty($args['input_group_left'])) {
543 543
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
544
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
545
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
544
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
545
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
546 546
 			}
547 547
 
548 548
 			// content
549 549
 			$output .= $args['content'];
550 550
 
551 551
 			// Input group right
552
-			if(!empty($args['input_group_right'])){
552
+			if (!empty($args['input_group_right'])) {
553 553
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
554
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
555
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
554
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
555
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
556 556
 			}
557 557
 
558 558
 
559 559
 			// close wrap
560
-			$output .= '</'.sanitize_html_class($args['type']).'>';
560
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
561 561
 
562 562
 
563
-		}else{
563
+		} else {
564 564
 			$output = $args['content'];
565 565
 		}
566 566
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @return string The rendered component.
576 576
 	 */
577
-	public static function select($args = array()){
577
+	public static function select($args = array()) {
578 578
 		$defaults = array(
579 579
 			'class'      => '',
580 580
 			'id'         => '',
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
 		/**
599 599
 		 * Parse incoming $args into an array and merge it with $defaults
600 600
 		 */
601
-		$args   = wp_parse_args( $args, $defaults );
601
+		$args   = wp_parse_args($args, $defaults);
602 602
 		$output = '';
603 603
 
604 604
 		// for now lets hide floating labels
605
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
605
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
606 606
 
607 607
 		// hidden label option needs to be empty
608 608
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -611,47 +611,47 @@  discard block
 block discarded – undo
611 611
 		$label_after = $args['label_after'];
612 612
 
613 613
 		// floating labels need label after
614
-		if( $args['label_type'] == 'floating' ){
614
+		if ($args['label_type'] == 'floating') {
615 615
 			$label_after = true;
616 616
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
617 617
 		}
618 618
 
619 619
 		// Maybe setup select2
620 620
 		$is_select2 = false;
621
-		if(!empty($args['select2'])){
621
+		if (!empty($args['select2'])) {
622 622
 			$args['class'] .= ' aui-select2';
623 623
 			$is_select2 = true;
624
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
624
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
625 625
 			$is_select2 = true;
626 626
 		}
627 627
 
628 628
 		// select2 tags
629
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
629
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
630 630
 			$args['data-tags'] = 'true';
631 631
 			$args['data-token-separators'] = "[',']";
632 632
 			$args['multiple'] = true;
633 633
 		}
634 634
 
635 635
 		// select2 placeholder
636
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
636
+		if ($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])) {
637 637
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
638 638
 			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
639 639
 		}
640 640
 
641 641
 		// label
642
-		if(!empty($args['label']) && is_array($args['label'])){
643
-		}elseif(!empty($args['label']) && !$label_after){
642
+		if (!empty($args['label']) && is_array($args['label'])) {
643
+		}elseif (!empty($args['label']) && !$label_after) {
644 644
 			$label_args = array(
645 645
 				'title'=> $args['label'],
646 646
 				'for'=> $args['id'],
647
-				'class' => $args['label_class']." ",
647
+				'class' => $args['label_class'] . " ",
648 648
 				'label_type' => $args['label_type']
649 649
 			);
650 650
 			$output .= self::label($label_args);
651 651
 		}
652 652
 
653 653
 		// maybe horizontal label
654
-		if($args['label_type']=='horizontal'){
654
+		if ($args['label_type'] == 'horizontal') {
655 655
 			$output .= '<div class="col-sm-10">';
656 656
 		}
657 657
 
@@ -659,26 +659,26 @@  discard block
 block discarded – undo
659 659
 		$output .= '<select ';
660 660
 
661 661
 		// style
662
-		if($is_select2){
662
+		if ($is_select2) {
663 663
 			$output .= " style='width:100%;' ";
664 664
 		}
665 665
 
666 666
 		// class
667 667
 		$class = !empty($args['class']) ? $args['class'] : '';
668
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
668
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
669 669
 
670 670
 		// name
671
-		if(!empty($args['name'])){
672
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
671
+		if (!empty($args['name'])) {
672
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
673 673
 		}
674 674
 
675 675
 		// id
676
-		if(!empty($args['id'])){
676
+		if (!empty($args['id'])) {
677 677
 			$output .= AUI_Component_Helper::id($args['id']);
678 678
 		}
679 679
 
680 680
 		// title
681
-		if(!empty($args['title'])){
681
+		if (!empty($args['title'])) {
682 682
 			$output .= AUI_Component_Helper::title($args['title']);
683 683
 		}
684 684
 
@@ -689,17 +689,17 @@  discard block
 block discarded – undo
689 689
 		$output .= AUI_Component_Helper::aria_attributes($args);
690 690
 
691 691
 		// extra attributes
692
-		if(!empty($args['extra_attributes'])){
692
+		if (!empty($args['extra_attributes'])) {
693 693
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
694 694
 		}
695 695
 
696 696
 		// required
697
-		if(!empty($args['required'])){
697
+		if (!empty($args['required'])) {
698 698
 			$output .= ' required ';
699 699
 		}
700 700
 
701 701
 		// multiple
702
-		if(!empty($args['multiple'])){
702
+		if (!empty($args['multiple'])) {
703 703
 			$output .= ' multiple ';
704 704
 		}
705 705
 
@@ -707,18 +707,18 @@  discard block
 block discarded – undo
707 707
 		$output .= ' >';
708 708
 
709 709
 		// placeholder
710
-		if(!empty($args['placeholder']) && !$is_select2){
711
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
712
-		}elseif($is_select2 && !empty($args['placeholder'])){
710
+		if (!empty($args['placeholder']) && !$is_select2) {
711
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
712
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
713 713
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
714 714
 		}
715 715
 
716 716
 		// Options
717
-		if(!empty($args['options'])){
717
+		if (!empty($args['options'])) {
718 718
 
719
-			foreach($args['options'] as $val => $name){
719
+			foreach ($args['options'] as $val => $name) {
720 720
 				$selected = '';
721
-				if(is_array($name)){
721
+				if (is_array($name)) {
722 722
 					if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
723 723
 						$option_label = isset($name['label']) ? $name['label'] : '';
724 724
 
@@ -726,23 +726,23 @@  discard block
 block discarded – undo
726 726
 					} else {
727 727
 						$option_label = isset($name['label']) ? $name['label'] : '';
728 728
 						$option_value = isset($name['value']) ? $name['value'] : '';
729
-						if(!empty($args['multiple']) && !empty($args['value'])){
729
+						if (!empty($args['multiple']) && !empty($args['value'])) {
730 730
 							$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
731
-						} elseif(!empty($args['value'])) {
732
-							$selected = selected($option_value,stripslashes_deep($args['value']), false);
731
+						} elseif (!empty($args['value'])) {
732
+							$selected = selected($option_value, stripslashes_deep($args['value']), false);
733 733
 						}
734 734
 
735 735
 						$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
736 736
 					}
737
-				}else{
738
-					if(!empty($args['value'])){
739
-						if(is_array($args['value'])){
740
-							$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
741
-						} elseif(!empty($args['value'])) {
742
-							$selected = selected( $args['value'], $val, false);
737
+				} else {
738
+					if (!empty($args['value'])) {
739
+						if (is_array($args['value'])) {
740
+							$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
741
+						} elseif (!empty($args['value'])) {
742
+							$selected = selected($args['value'], $val, false);
743 743
 						}
744 744
 					}
745
-					$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
745
+					$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
746 746
 				}
747 747
 			}
748 748
 
@@ -751,30 +751,30 @@  discard block
 block discarded – undo
751 751
 		// closing tag
752 752
 		$output .= '</select>';
753 753
 
754
-		if(!empty($args['label']) && $label_after){
754
+		if (!empty($args['label']) && $label_after) {
755 755
 			$label_args = array(
756 756
 				'title'=> $args['label'],
757 757
 				'for'=> $args['id'],
758
-				'class' => $args['label_class']." ",
758
+				'class' => $args['label_class'] . " ",
759 759
 				'label_type' => $args['label_type']
760 760
 			);
761 761
 			$output .= self::label($label_args);
762 762
 		}
763 763
 
764 764
 		// help text
765
-		if(!empty($args['help_text'])){
765
+		if (!empty($args['help_text'])) {
766 766
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
767 767
 		}
768 768
 
769 769
 		// maybe horizontal label
770
-		if($args['label_type']=='horizontal'){
770
+		if ($args['label_type'] == 'horizontal') {
771 771
 			$output .= '</div>';
772 772
 		}
773 773
 
774 774
 
775 775
 		// wrap
776
-		if(!$args['no_wrap']){
777
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
776
+		if (!$args['no_wrap']) {
777
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
778 778
 			$output = self::wrap(array(
779 779
 				'content' => $output,
780 780
 				'class'   => $wrap_class,
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	 *
793 793
 	 * @return string The rendered component.
794 794
 	 */
795
-	public static function radio($args = array()){
795
+	public static function radio($args = array()) {
796 796
 		$defaults = array(
797 797
 			'class'      => '',
798 798
 			'id'         => '',
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 		/**
814 814
 		 * Parse incoming $args into an array and merge it with $defaults
815 815
 		 */
816
-		$args   = wp_parse_args( $args, $defaults );
816
+		$args = wp_parse_args($args, $defaults);
817 817
 
818 818
 		// for now lets use horizontal for floating
819
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
819
+		if ($args['label_type'] != 'hidden') {$args['label_type'] = 'horizontal'; }
820 820
 
821 821
 		$label_args = array(
822 822
 			'title'=> $args['label'],
823
-			'class' => $args['label_class']." pt-0 ",
823
+			'class' => $args['label_class'] . " pt-0 ",
824 824
 			'label_type' => $args['label_type']
825 825
 		);
826 826
 
@@ -829,35 +829,35 @@  discard block
 block discarded – undo
829 829
 
830 830
 
831 831
 		// label before
832
-		if(!empty($args['label'])){
833
-			$output .= self::label( $label_args, 'radio' );
832
+		if (!empty($args['label'])) {
833
+			$output .= self::label($label_args, 'radio');
834 834
 		}
835 835
 
836 836
 		// maybe horizontal label
837
-		if($args['label_type']=='horizontal'){
837
+		if ($args['label_type'] == 'horizontal') {
838 838
 			$output .= '<div class="col-sm-10">';
839 839
 		}
840 840
 
841
-		if(!empty($args['options'])){
841
+		if (!empty($args['options'])) {
842 842
 			$count = 0;
843
-			foreach($args['options'] as $value => $label){
843
+			foreach ($args['options'] as $value => $label) {
844 844
 				$option_args = $args;
845 845
 				$option_args['value'] = $value;
846 846
 				$option_args['label'] = $label;
847 847
 				$option_args['checked'] = $value == $args['value'] ? true : false;
848
-				$output .= self::radio_option($option_args,$count);
848
+				$output .= self::radio_option($option_args, $count);
849 849
 				$count++;
850 850
 			}
851 851
 		}
852 852
 
853 853
 		// maybe horizontal label
854
-		if($args['label_type']=='horizontal'){
854
+		if ($args['label_type'] == 'horizontal') {
855 855
 			$output .= '</div>';
856 856
 		}
857 857
 
858 858
 
859 859
 		// wrap
860
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
860
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
861 861
 		$output = self::wrap(array(
862 862
 			'content' => $output,
863 863
 			'class'   => $wrap_class,
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 	 *
875 875
 	 * @return string The rendered component.
876 876
 	 */
877
-	public static function radio_option($args = array(),$count = ''){
877
+	public static function radio_option($args = array(), $count = '') {
878 878
 		$defaults = array(
879 879
 			'class'      => '',
880 880
 			'id'         => '',
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		/**
893 893
 		 * Parse incoming $args into an array and merge it with $defaults
894 894
 		 */
895
-		$args   = wp_parse_args( $args, $defaults );
895
+		$args   = wp_parse_args($args, $defaults);
896 896
 
897 897
 		$output = '';
898 898
 
@@ -903,27 +903,27 @@  discard block
 block discarded – undo
903 903
 		$output .= ' class="form-check-input" ';
904 904
 
905 905
 		// name
906
-		if(!empty($args['name'])){
906
+		if (!empty($args['name'])) {
907 907
 			$output .= AUI_Component_Helper::name($args['name']);
908 908
 		}
909 909
 
910 910
 		// id
911
-		if(!empty($args['id'])){
912
-			$output .= AUI_Component_Helper::id($args['id'].$count);
911
+		if (!empty($args['id'])) {
912
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
913 913
 		}
914 914
 
915 915
 		// title
916
-		if(!empty($args['title'])){
916
+		if (!empty($args['title'])) {
917 917
 			$output .= AUI_Component_Helper::title($args['title']);
918 918
 		}
919 919
 
920 920
 		// value
921
-		if(!empty($args['value'])){
922
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
921
+		if (!empty($args['value'])) {
922
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
923 923
 		}
924 924
 
925 925
 		// checked, for radio and checkboxes
926
-		if( $args['checked'] ){
926
+		if ($args['checked']) {
927 927
 			$output .= ' checked ';
928 928
 		}
929 929
 
@@ -934,12 +934,12 @@  discard block
 block discarded – undo
934 934
 		$output .= AUI_Component_Helper::aria_attributes($args);
935 935
 
936 936
 		// extra attributes
937
-		if(!empty($args['extra_attributes'])){
937
+		if (!empty($args['extra_attributes'])) {
938 938
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
939 939
 		}
940 940
 
941 941
 		// required
942
-		if(!empty($args['required'])){
942
+		if (!empty($args['required'])) {
943 943
 			$output .= ' required ';
944 944
 		}
945 945
 
@@ -947,13 +947,13 @@  discard block
 block discarded – undo
947 947
 		$output .= ' >';
948 948
 
949 949
 		// label
950
-		if(!empty($args['label']) && is_array($args['label'])){
951
-		}elseif(!empty($args['label'])){
952
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
950
+		if (!empty($args['label']) && is_array($args['label'])) {
951
+		}elseif (!empty($args['label'])) {
952
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
953 953
 		}
954 954
 
955 955
 		// wrap
956
-		if(!$args['no_wrap']){
956
+		if (!$args['no_wrap']) {
957 957
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
958 958
 			$output = self::wrap(array(
959 959
 				'content' => $output,
Please login to merge, or discard this patch.
Braces   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
 			if($type=='file' ){
79 79
 				$label_after = true; // if type file we need the label after
80 80
 				$args['class'] .= ' custom-file-input ';
81
-			}elseif($type=='checkbox'){
81
+			} elseif($type=='checkbox'){
82 82
 				$label_after = true; // if type file we need the label after
83 83
 				$args['class'] .= ' custom-control-input ';
84
-			}elseif($type=='datepicker' || $type=='timepicker'){
84
+			} elseif($type=='datepicker' || $type=='timepicker'){
85 85
 				$type = 'text';
86 86
 				$args['class'] .= ' aui-flatpickr bg-initial ';
87 87
 
@@ -163,8 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 			// label
165 165
 			if(!empty($args['label'])){
166
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
167
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
166
+				if($type == 'file'){$label_args['class'] .= 'custom-file-label';} elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
168 167
 				$label = self::label( $label_args, $type );
169 168
 			}
170 169
 
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 					'content' => $output,
186 185
 					'class'   => 'form-group custom-file'
187 186
 				) );
188
-			}elseif($type == 'checkbox'){
187
+			} elseif($type == 'checkbox'){
189 188
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
190 189
 				$output = self::wrap( array(
191 190
 					'content' => $output,
@@ -195,7 +194,7 @@  discard block
 block discarded – undo
195 194
 				if($args['label_type']=='horizontal'){
196 195
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
197 196
 				}
198
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
197
+			} elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
199 198
 
200 199
 
201 200
 				// allow password field to toggle view
@@ -315,7 +314,7 @@  discard block
 block discarded – undo
315 314
 
316 315
 		// label
317 316
 		if(!empty($args['label']) && is_array($args['label'])){
318
-		}elseif(!empty($args['label']) && !$label_after){
317
+		} elseif(!empty($args['label']) && !$label_after){
319 318
 			$label_args = array(
320 319
 				'title'=> $args['label'],
321 320
 				'for'=> $args['id'],
@@ -350,7 +349,7 @@  discard block
 block discarded – undo
350 349
 
351 350
 			wp_editor( $content, $editor_id, $settings );
352 351
 			$output .= ob_get_clean();
353
-		}else{
352
+		} else{
354 353
 
355 354
 			// open
356 355
 			$output .= '<textarea ';
@@ -470,7 +469,7 @@  discard block
 block discarded – undo
470 469
 			// maybe hide labels //@todo set a global option for visibility class
471 470
 			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
472 471
 				$class = $args['class'];
473
-			}else{
472
+			} else{
474 473
 				$class = 'sr-only '.$args['class'];
475 474
 			}
476 475
 
@@ -560,7 +559,7 @@  discard block
 block discarded – undo
560 559
 			$output .= '</'.sanitize_html_class($args['type']).'>';
561 560
 
562 561
 
563
-		}else{
562
+		} else{
564 563
 			$output = $args['content'];
565 564
 		}
566 565
 
@@ -621,7 +620,7 @@  discard block
 block discarded – undo
621 620
 		if(!empty($args['select2'])){
622 621
 			$args['class'] .= ' aui-select2';
623 622
 			$is_select2 = true;
624
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
623
+		} elseif( strpos($args['class'], 'aui-select2') !== false){
625 624
 			$is_select2 = true;
626 625
 		}
627 626
 
@@ -640,7 +639,7 @@  discard block
 block discarded – undo
640 639
 
641 640
 		// label
642 641
 		if(!empty($args['label']) && is_array($args['label'])){
643
-		}elseif(!empty($args['label']) && !$label_after){
642
+		} elseif(!empty($args['label']) && !$label_after){
644 643
 			$label_args = array(
645 644
 				'title'=> $args['label'],
646 645
 				'for'=> $args['id'],
@@ -709,7 +708,7 @@  discard block
 block discarded – undo
709 708
 		// placeholder
710 709
 		if(!empty($args['placeholder']) && !$is_select2){
711 710
 			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
712
-		}elseif($is_select2 && !empty($args['placeholder'])){
711
+		} elseif($is_select2 && !empty($args['placeholder'])){
713 712
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
714 713
 		}
715 714
 
@@ -734,7 +733,7 @@  discard block
 block discarded – undo
734 733
 
735 734
 						$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
736 735
 					}
737
-				}else{
736
+				} else{
738 737
 					if(!empty($args['value'])){
739 738
 						if(is_array($args['value'])){
740 739
 							$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
@@ -948,7 +947,7 @@  discard block
 block discarded – undo
948 947
 
949 948
 		// label
950 949
 		if(!empty($args['label']) && is_array($args['label'])){
951
-		}elseif(!empty($args['label'])){
950
+		} elseif(!empty($args['label'])){
952 951
 			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
953 952
 		}
954 953
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-button.php 2 patches
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,143 +11,143 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Button {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'a', // a, button, badge
24
-			'href'       => '#',
25
-			'new_window' => false,
26
-			'class'      => 'btn btn-primary',
27
-			'id'         => '',
28
-			'title'      => '',
29
-			'value'      => '',
30
-			'content'    => '',
31
-			'icon'       => '',
32
-			'hover_content' => '',
33
-			'hover_icon'    => '',
34
-			'new_line_after' => true,
35
-			'no_wrap'    => true,
36
-			'onclick'    => '',
37
-			'style'  => '',
38
-			'extra_attributes'  => array(), // an array of extra attributes
39
-			'icon_extra_attributes'  => array() // an array of icon extra attributes
40
-		);
41
-
42
-		/**
43
-		 * Parse incoming $args into an array and merge it with $defaults
44
-		 */
45
-		$args   = wp_parse_args( $args, $defaults );
46
-		$output = '';
47
-		if ( ! empty( $args['type'] ) ) {
48
-			$type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49
-
50
-			// open/type
51
-			if($type=='a'){
52
-				$new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
-				$output .= '<a href="' . $args['href'] . '"'.$new_window;
54
-			}elseif($type=='badge'){
55
-				$output .= '<span ';
56
-			}else{
57
-				$output .= '<button type="' . $type . '" ';
58
-			}
59
-
60
-			// name
61
-			if(!empty($args['name'])){
62
-				$output .= AUI_Component_Helper::name($args['name']);
63
-			}
64
-
65
-			// id
66
-			if(!empty($args['id'])){
67
-				$output .= AUI_Component_Helper::id($args['id']);
68
-			}
69
-
70
-			// title
71
-			if(!empty($args['title'])){
72
-				$output .= AUI_Component_Helper::title($args['title']);
73
-			}
74
-
75
-			// value
76
-			if(!empty($args['value'])){
77
-				$output .= AUI_Component_Helper::value($args['value']);
78
-			}
79
-
80
-			// class
81
-			$class = !empty($args['class']) ? $args['class'] : '';
82
-			$output .= AUI_Component_Helper::class_attr($class);
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'a', // a, button, badge
24
+            'href'       => '#',
25
+            'new_window' => false,
26
+            'class'      => 'btn btn-primary',
27
+            'id'         => '',
28
+            'title'      => '',
29
+            'value'      => '',
30
+            'content'    => '',
31
+            'icon'       => '',
32
+            'hover_content' => '',
33
+            'hover_icon'    => '',
34
+            'new_line_after' => true,
35
+            'no_wrap'    => true,
36
+            'onclick'    => '',
37
+            'style'  => '',
38
+            'extra_attributes'  => array(), // an array of extra attributes
39
+            'icon_extra_attributes'  => array() // an array of icon extra attributes
40
+        );
41
+
42
+        /**
43
+         * Parse incoming $args into an array and merge it with $defaults
44
+         */
45
+        $args   = wp_parse_args( $args, $defaults );
46
+        $output = '';
47
+        if ( ! empty( $args['type'] ) ) {
48
+            $type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49
+
50
+            // open/type
51
+            if($type=='a'){
52
+                $new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
+                $output .= '<a href="' . $args['href'] . '"'.$new_window;
54
+            }elseif($type=='badge'){
55
+                $output .= '<span ';
56
+            }else{
57
+                $output .= '<button type="' . $type . '" ';
58
+            }
59
+
60
+            // name
61
+            if(!empty($args['name'])){
62
+                $output .= AUI_Component_Helper::name($args['name']);
63
+            }
64
+
65
+            // id
66
+            if(!empty($args['id'])){
67
+                $output .= AUI_Component_Helper::id($args['id']);
68
+            }
69
+
70
+            // title
71
+            if(!empty($args['title'])){
72
+                $output .= AUI_Component_Helper::title($args['title']);
73
+            }
74
+
75
+            // value
76
+            if(!empty($args['value'])){
77
+                $output .= AUI_Component_Helper::value($args['value']);
78
+            }
79
+
80
+            // class
81
+            $class = !empty($args['class']) ? $args['class'] : '';
82
+            $output .= AUI_Component_Helper::class_attr($class);
83 83
 			
84
-			// data-attributes
85
-			$output .= AUI_Component_Helper::data_attributes($args);
84
+            // data-attributes
85
+            $output .= AUI_Component_Helper::data_attributes($args);
86 86
 
87
-			// aria-attributes
88
-			$output .= AUI_Component_Helper::aria_attributes($args);
87
+            // aria-attributes
88
+            $output .= AUI_Component_Helper::aria_attributes($args);
89 89
 
90
-			// extra attributes
91
-			if(!empty($args['extra_attributes'])){
92
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93
-			}
90
+            // extra attributes
91
+            if(!empty($args['extra_attributes'])){
92
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93
+            }
94 94
 
95
-			// onclick, we don't escape this
96
-			if(!empty($args['onclick'])){
97
-				$output .= ' onclick="'.$args['onclick'].'" ';
98
-			}
95
+            // onclick, we don't escape this
96
+            if(!empty($args['onclick'])){
97
+                $output .= ' onclick="'.$args['onclick'].'" ';
98
+            }
99 99
 
100
-			// style, we don't escape this
101
-			if(!empty($args['style'])){
102
-				$output .= ' style="'.$args['style'].'" ';
103
-			}
100
+            // style, we don't escape this
101
+            if(!empty($args['style'])){
102
+                $output .= ' style="'.$args['style'].'" ';
103
+            }
104 104
 
105
-			// close opening tag
106
-			$output .= ' >';
105
+            // close opening tag
106
+            $output .= ' >';
107 107
 
108 108
 
109
-			// hover content
110
-			$hover_content = false;
111
-			if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
-				$output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
113
-				$hover_content = true;
114
-			}
109
+            // hover content
110
+            $hover_content = false;
111
+            if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
+                $output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
113
+                $hover_content = true;
114
+            }
115 115
 			
116
-			// content
117
-			if($hover_content){$output .= "<span class='hover-content-original'>";}
118
-			if(!empty($args['content']) || !empty($args['icon'])){
119
-				$output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
120
-			}
121
-			if($hover_content){$output .= "</span>";}
116
+            // content
117
+            if($hover_content){$output .= "<span class='hover-content-original'>";}
118
+            if(!empty($args['content']) || !empty($args['icon'])){
119
+                $output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
120
+            }
121
+            if($hover_content){$output .= "</span>";}
122 122
 					
123 123
 
124 124
 
125
-			// close
126
-			if($type=='a'){
127
-				$output .= '</a>';
128
-			}elseif($type=='badge'){
129
-				$output .= '</span>';
130
-			}else{
131
-				$output .= '</button>';
132
-			}
125
+            // close
126
+            if($type=='a'){
127
+                $output .= '</a>';
128
+            }elseif($type=='badge'){
129
+                $output .= '</span>';
130
+            }else{
131
+                $output .= '</button>';
132
+            }
133 133
 
134
-			// maybe new line after?  This adds better spacing between buttons.
135
-			if(!empty($args['new_line_after'])){
136
-				$output .= PHP_EOL;
137
-			}
134
+            // maybe new line after?  This adds better spacing between buttons.
135
+            if(!empty($args['new_line_after'])){
136
+                $output .= PHP_EOL;
137
+            }
138 138
 
139 139
 
140
-			// wrap
141
-			if(!$args['no_wrap']){
142
-				$output = AUI_Component_Input::wrap(array(
143
-					'content' => $output,
144
-				));
145
-			}
140
+            // wrap
141
+            if(!$args['no_wrap']){
142
+                $output = AUI_Component_Input::wrap(array(
143
+                    'content' => $output,
144
+                ));
145
+            }
146 146
 
147 147
 
148
-		}
148
+        }
149 149
 
150
-		return $output;
151
-	}
150
+        return $output;
151
+    }
152 152
 
153 153
 }
154 154
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function get($args = array()){
21
+	public static function get($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'a', // a, button, badge
24 24
 			'href'       => '#',
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
 		/**
43 43
 		 * Parse incoming $args into an array and merge it with $defaults
44 44
 		 */
45
-		$args   = wp_parse_args( $args, $defaults );
45
+		$args   = wp_parse_args($args, $defaults);
46 46
 		$output = '';
47
-		if ( ! empty( $args['type'] ) ) {
47
+		if (!empty($args['type'])) {
48 48
 			$type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49 49
 
50 50
 			// open/type
51
-			if($type=='a'){
51
+			if ($type == 'a') {
52 52
 				$new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
-				$output .= '<a href="' . $args['href'] . '"'.$new_window;
54
-			}elseif($type=='badge'){
53
+				$output .= '<a href="' . $args['href'] . '"' . $new_window;
54
+			}elseif ($type == 'badge') {
55 55
 				$output .= '<span ';
56
-			}else{
56
+			} else {
57 57
 				$output .= '<button type="' . $type . '" ';
58 58
 			}
59 59
 
60 60
 			// name
61
-			if(!empty($args['name'])){
61
+			if (!empty($args['name'])) {
62 62
 				$output .= AUI_Component_Helper::name($args['name']);
63 63
 			}
64 64
 
65 65
 			// id
66
-			if(!empty($args['id'])){
66
+			if (!empty($args['id'])) {
67 67
 				$output .= AUI_Component_Helper::id($args['id']);
68 68
 			}
69 69
 
70 70
 			// title
71
-			if(!empty($args['title'])){
71
+			if (!empty($args['title'])) {
72 72
 				$output .= AUI_Component_Helper::title($args['title']);
73 73
 			}
74 74
 
75 75
 			// value
76
-			if(!empty($args['value'])){
76
+			if (!empty($args['value'])) {
77 77
 				$output .= AUI_Component_Helper::value($args['value']);
78 78
 			}
79 79
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 			$output .= AUI_Component_Helper::aria_attributes($args);
89 89
 
90 90
 			// extra attributes
91
-			if(!empty($args['extra_attributes'])){
91
+			if (!empty($args['extra_attributes'])) {
92 92
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93 93
 			}
94 94
 
95 95
 			// onclick, we don't escape this
96
-			if(!empty($args['onclick'])){
97
-				$output .= ' onclick="'.$args['onclick'].'" ';
96
+			if (!empty($args['onclick'])) {
97
+				$output .= ' onclick="' . $args['onclick'] . '" ';
98 98
 			}
99 99
 
100 100
 			// style, we don't escape this
101
-			if(!empty($args['style'])){
102
-				$output .= ' style="'.$args['style'].'" ';
101
+			if (!empty($args['style'])) {
102
+				$output .= ' style="' . $args['style'] . '" ';
103 103
 			}
104 104
 
105 105
 			// close opening tag
@@ -108,37 +108,37 @@  discard block
 block discarded – undo
108 108
 
109 109
 			// hover content
110 110
 			$hover_content = false;
111
-			if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
-				$output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
111
+			if (!empty($args['hover_content']) || !empty($args['hover_icon'])) {
112
+				$output .= "<span class='hover-content'>" . AUI_Component_Helper::icon($args['hover_icon'], $args['hover_content']) . $args['hover_content'] . "</span>";
113 113
 				$hover_content = true;
114 114
 			}
115 115
 			
116 116
 			// content
117
-			if($hover_content){$output .= "<span class='hover-content-original'>";}
118
-			if(!empty($args['content']) || !empty($args['icon'])){
119
-				$output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
117
+			if ($hover_content) {$output .= "<span class='hover-content-original'>"; }
118
+			if (!empty($args['content']) || !empty($args['icon'])) {
119
+				$output .= AUI_Component_Helper::icon($args['icon'], $args['content'], $args['icon_extra_attributes']) . $args['content'];
120 120
 			}
121
-			if($hover_content){$output .= "</span>";}
121
+			if ($hover_content) {$output .= "</span>"; }
122 122
 					
123 123
 
124 124
 
125 125
 			// close
126
-			if($type=='a'){
126
+			if ($type == 'a') {
127 127
 				$output .= '</a>';
128
-			}elseif($type=='badge'){
128
+			}elseif ($type == 'badge') {
129 129
 				$output .= '</span>';
130
-			}else{
130
+			} else {
131 131
 				$output .= '</button>';
132 132
 			}
133 133
 
134 134
 			// maybe new line after?  This adds better spacing between buttons.
135
-			if(!empty($args['new_line_after'])){
135
+			if (!empty($args['new_line_after'])) {
136 136
 				$output .= PHP_EOL;
137 137
 			}
138 138
 
139 139
 
140 140
 			// wrap
141
-			if(!$args['no_wrap']){
141
+			if (!$args['no_wrap']) {
142 142
 				$output = AUI_Component_Input::wrap(array(
143 143
 					'content' => $output,
144 144
 				));
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 3 patches
Indentation   +837 added lines, -837 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,187 +21,187 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '1.0.1';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "4.3.1";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-		/**
92
-		 * Main AyeCode_UI_Settings Instance.
93
-		 *
94
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
95
-		 *
96
-		 * @since 1.0.0
97
-		 * @static
98
-		 * @return AyeCode_UI_Settings - Main instance.
99
-		 */
100
-		public static function instance() {
101
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
-				self::$instance = new AyeCode_UI_Settings;
103
-
104
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
105
-
106
-				if ( is_admin() ) {
107
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
108
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
109
-
110
-					// Maybe show example page
111
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
112
-				}
113
-
114
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
115
-
116
-				do_action( 'ayecode_ui_settings_loaded' );
117
-			}
118
-
119
-			return self::$instance;
120
-		}
121
-
122
-		/**
123
-		 * Initiate the settings and add the required action hooks.
124
-		 */
125
-		public function init() {
126
-			$this->settings = $this->get_settings();
127
-			$this->url = $this->get_url();
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '1.0.1';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
46
+
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "4.3.1";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
60
+
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
67
+
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
74
+
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
81
+
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
90
+
91
+        /**
92
+         * Main AyeCode_UI_Settings Instance.
93
+         *
94
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
95
+         *
96
+         * @since 1.0.0
97
+         * @static
98
+         * @return AyeCode_UI_Settings - Main instance.
99
+         */
100
+        public static function instance() {
101
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
+                self::$instance = new AyeCode_UI_Settings;
103
+
104
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
105
+
106
+                if ( is_admin() ) {
107
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
108
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
109
+
110
+                    // Maybe show example page
111
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
112
+                }
128 113
 
129
-			/**
130
-			 * Maybe load CSS
131
-			 *
132
-			 * We load super early in case there is a theme version that might change the colors
133
-			 */
134
-			if ( $this->settings['css'] ) {
135
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
136
-			}
137
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
138
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
139
-			}
140
-
141
-			// maybe load JS
142
-			if ( $this->settings['js'] ) {
143
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
144
-			}
145
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
146
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
147
-			}
148
-
149
-			// Maybe set the HTML font size
150
-			if ( $this->settings['html_font_size'] ) {
151
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
152
-			}
153
-
154
-
155
-		}
156
-
157
-		/**
158
-		 * Check if we should load the admin scripts or not.
159
-		 *
160
-		 * @return bool
161
-		 */
162
-		public function load_admin_scripts(){
163
-			$result = true;
164
-
165
-			if(!empty($this->settings['disable_admin'])){
166
-				$url_parts = explode("\n",$this->settings['disable_admin']);
167
-				foreach($url_parts as $part){
168
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
169
-						return false; // return early, no point checking further
170
-					}
171
-				}
172
-			}
114
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
115
+
116
+                do_action( 'ayecode_ui_settings_loaded' );
117
+            }
118
+
119
+            return self::$instance;
120
+        }
121
+
122
+        /**
123
+         * Initiate the settings and add the required action hooks.
124
+         */
125
+        public function init() {
126
+            $this->settings = $this->get_settings();
127
+            $this->url = $this->get_url();
128
+
129
+            /**
130
+             * Maybe load CSS
131
+             *
132
+             * We load super early in case there is a theme version that might change the colors
133
+             */
134
+            if ( $this->settings['css'] ) {
135
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
136
+            }
137
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
138
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
139
+            }
140
+
141
+            // maybe load JS
142
+            if ( $this->settings['js'] ) {
143
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
144
+            }
145
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
146
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
147
+            }
148
+
149
+            // Maybe set the HTML font size
150
+            if ( $this->settings['html_font_size'] ) {
151
+                add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
152
+            }
153
+
154
+
155
+        }
156
+
157
+        /**
158
+         * Check if we should load the admin scripts or not.
159
+         *
160
+         * @return bool
161
+         */
162
+        public function load_admin_scripts(){
163
+            $result = true;
164
+
165
+            if(!empty($this->settings['disable_admin'])){
166
+                $url_parts = explode("\n",$this->settings['disable_admin']);
167
+                foreach($url_parts as $part){
168
+                    if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
169
+                        return false; // return early, no point checking further
170
+                    }
171
+                }
172
+            }
173 173
 
174
-			return $result;
175
-		}
174
+            return $result;
175
+        }
176 176
 
177
-		/**
178
-		 * Add a html font size to the footer.
179
-		 */
180
-		public function html_font_size(){
181
-			$this->settings = $this->get_settings();
182
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
183
-		}
177
+        /**
178
+         * Add a html font size to the footer.
179
+         */
180
+        public function html_font_size(){
181
+            $this->settings = $this->get_settings();
182
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
183
+        }
184 184
 
185
-		/**
186
-		 * Adds the Font Awesome styles.
187
-		 */
188
-		public function enqueue_style() {
185
+        /**
186
+         * Adds the Font Awesome styles.
187
+         */
188
+        public function enqueue_style() {
189 189
 
190
-			$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
190
+            $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
191 191
 
192
-			if($this->settings[$css_setting]){
193
-				$compatibility = $this->settings[$css_setting]=='core' ? false : true;
194
-				$url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css';
195
-				wp_register_style( 'ayecode-ui', $url, array(), $this->latest );
196
-				wp_enqueue_style( 'ayecode-ui' );
192
+            if($this->settings[$css_setting]){
193
+                $compatibility = $this->settings[$css_setting]=='core' ? false : true;
194
+                $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css';
195
+                wp_register_style( 'ayecode-ui', $url, array(), $this->latest );
196
+                wp_enqueue_style( 'ayecode-ui' );
197 197
 
198
-				// flatpickr
199
-				wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest );
198
+                // flatpickr
199
+                wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest );
200 200
 
201 201
 
202
-				// fix some wp-admin issues
203
-				if(is_admin()){
204
-					$custom_css = "
202
+                // fix some wp-admin issues
203
+                if(is_admin()){
204
+                    $custom_css = "
205 205
                 body{
206 206
                     background-color: #f1f1f1;
207 207
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -237,29 +237,29 @@  discard block
 block discarded – undo
237 237
 				}
238 238
                 ";
239 239
 
240
-					// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
241
-					$custom_css .= "
240
+                    // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
241
+                    $custom_css .= "
242 242
 						.edit-post-sidebar input[type=color].components-text-control__input{
243 243
 						    padding: 0;
244 244
 						}
245 245
 					";
246
-					wp_add_inline_style( 'ayecode-ui', $custom_css );
247
-				}
246
+                    wp_add_inline_style( 'ayecode-ui', $custom_css );
247
+                }
248 248
 
249
-				// custom changes
250
-				wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
249
+                // custom changes
250
+                wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
251 251
 
252
-			}
253
-		}
252
+            }
253
+        }
254 254
 
255
-		/**
256
-		 * Get inline script used if bootstrap enqueued
257
-		 *
258
-		 * If this remains small then its best to use this than to add another JS file.
259
-		 */
260
-		public function inline_script(){
261
-			ob_start();
262
-			?>
255
+        /**
256
+         * Get inline script used if bootstrap enqueued
257
+         *
258
+         * If this remains small then its best to use this than to add another JS file.
259
+         */
260
+        public function inline_script(){
261
+            ob_start();
262
+            ?>
263 263
 			<script>
264 264
 
265 265
 				/**
@@ -478,25 +478,25 @@  discard block
 block discarded – undo
478 478
 				});
479 479
 			</script>
480 480
 			<?php
481
-			$output = ob_get_clean();
481
+            $output = ob_get_clean();
482 482
 
483
-			/*
483
+            /*
484 484
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
485 485
 			 */
486
-			return str_replace( array(
487
-				'<script>',
488
-				'</script>'
489
-			), '', $output );
490
-		}
491
-
492
-		/**
493
-		 * Get inline script used if bootstrap file browser enqueued.
494
-		 *
495
-		 * If this remains small then its best to use this than to add another JS file.
496
-		 */
497
-		public function inline_script_file_browser(){
498
-			ob_start();
499
-			?>
486
+            return str_replace( array(
487
+                '<script>',
488
+                '</script>'
489
+            ), '', $output );
490
+        }
491
+
492
+        /**
493
+         * Get inline script used if bootstrap file browser enqueued.
494
+         *
495
+         * If this remains small then its best to use this than to add another JS file.
496
+         */
497
+        public function inline_script_file_browser(){
498
+            ob_start();
499
+            ?>
500 500
 			<script>
501 501
 				// run on doc ready
502 502
 				jQuery(document).ready(function () {
@@ -504,184 +504,184 @@  discard block
 block discarded – undo
504 504
 				});
505 505
 			</script>
506 506
 			<?php
507
-			$output = ob_get_clean();
507
+            $output = ob_get_clean();
508 508
 
509
-			/*
509
+            /*
510 510
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
511 511
 			 */
512
-			return str_replace( array(
513
-				'<script>',
514
-				'</script>'
515
-			), '', $output );
516
-		}
517
-
518
-		/**
519
-		 * Adds the Font Awesome JS.
520
-		 */
521
-		public function enqueue_scripts() {
522
-
523
-			$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
524
-
525
-			// select2
526
-			wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version );
527
-
528
-			// flatpickr
529
-			wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest );
530
-
531
-			// Bootstrap file browser
532
-			wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version );
533
-			wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
534
-
535
-			$load_inline = false;
536
-
537
-			if($this->settings[$js_setting]=='core-popper'){
538
-				// Bootstrap bundle
539
-				$url = $this->url.'assets/js/bootstrap.bundle.min.js';
540
-				wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest );
541
-				// if in admin then add to footer for compatibility.
542
-				is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle');
543
-				$script = $this->inline_script();
544
-				wp_add_inline_script( 'bootstrap-js-bundle', $script );
545
-			}elseif($this->settings[$js_setting]=='popper'){
546
-				$url = $this->url.'assets/js/popper.min.js';
547
-				wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest );
548
-				wp_enqueue_script( 'bootstrap-js-popper' );
549
-				$load_inline = true;
550
-			}else{
551
-				$load_inline = true;
552
-			}
553
-
554
-			// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
555
-			if($load_inline){
556
-				wp_register_script( 'bootstrap-dummy', '',array('jquery') );
557
-				wp_enqueue_script( 'bootstrap-dummy' );
558
-				$script = $this->inline_script();
559
-				wp_add_inline_script( 'bootstrap-dummy', $script  );
560
-			}
561
-
562
-		}
563
-
564
-		/**
565
-		 * Enqueue flatpickr if called.
566
-		 */
567
-		public function enqueue_flatpickr(){
568
-			wp_enqueue_style( 'flatpickr' );
569
-			wp_enqueue_script( 'flatpickr' );
570
-		}
571
-
572
-		/**
573
-		 * Get the url path to the current folder.
574
-		 *
575
-		 * @return string
576
-		 */
577
-		public function get_url() {
578
-
579
-			$url = '';
580
-			// check if we are inside a plugin
581
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
582
-
583
-			// add check in-case user has changed wp-content dir name.
584
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
585
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
586
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
587
-
588
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
589
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
590
-			}
591
-
592
-			return $url;
593
-		}
594
-
595
-		/**
596
-		 * Register the database settings with WordPress.
597
-		 */
598
-		public function register_settings() {
599
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
600
-		}
601
-
602
-		/**
603
-		 * Add the WordPress settings menu item.
604
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
605
-		 */
606
-		public function menu_item() {
607
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
608
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
609
-				$this,
610
-				'settings_page'
611
-			) );
612
-		}
613
-
614
-		/**
615
-		 * Get a list of themes and their default JS settings.
616
-		 *
617
-		 * @return array
618
-		 */
619
-		public function theme_js_settings(){
620
-			return array(
621
-				'ayetheme' => 'popper',
622
-				'listimia' => 'required',
623
-				'listimia_backend' => 'core-popper',
624
-				'avada'    => 'required',
625
-			);
626
-		}
627
-
628
-		/**
629
-		 * Get the current Font Awesome output settings.
630
-		 *
631
-		 * @return array The array of settings.
632
-		 */
633
-		public function get_settings() {
634
-
635
-			$db_settings = get_option( 'ayecode-ui-settings' );
636
-			$js_default = 'core-popper';
637
-			$js_default_backend = $js_default;
638
-
639
-			// maybe set defaults (if no settings set)
640
-			if(empty($db_settings)){
641
-				$active_theme = strtolower( get_template() ); // active parent theme.
642
-				$theme_js_settings = self::theme_js_settings();
643
-				if(isset($theme_js_settings[$active_theme])){
644
-					$js_default = $theme_js_settings[$active_theme];
645
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
646
-				}
647
-			}
648
-
649
-			$defaults = array(
650
-				'css'       => 'compatibility', // core, compatibility
651
-				'js'        => $js_default, // js to load, core-popper, popper
652
-				'html_font_size'        => '16', // js to load, core-popper, popper
653
-				'css_backend'       => 'compatibility', // core, compatibility
654
-				'js_backend'        => $js_default_backend, // js to load, core-popper, popper
655
-				'disable_admin'     =>  '', // URL snippets to disable loading on admin
656
-			);
657
-
658
-			$settings = wp_parse_args( $db_settings, $defaults );
659
-
660
-			/**
661
-			 * Filter the Bootstrap settings.
662
-			 *
663
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
664
-			 */
665
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
666
-		}
667
-
668
-
669
-		/**
670
-		 * The settings page html output.
671
-		 */
672
-		public function settings_page() {
673
-			if ( ! current_user_can( 'manage_options' ) ) {
674
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
675
-			}
676
-			?>
512
+            return str_replace( array(
513
+                '<script>',
514
+                '</script>'
515
+            ), '', $output );
516
+        }
517
+
518
+        /**
519
+         * Adds the Font Awesome JS.
520
+         */
521
+        public function enqueue_scripts() {
522
+
523
+            $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
524
+
525
+            // select2
526
+            wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version );
527
+
528
+            // flatpickr
529
+            wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest );
530
+
531
+            // Bootstrap file browser
532
+            wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version );
533
+            wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
534
+
535
+            $load_inline = false;
536
+
537
+            if($this->settings[$js_setting]=='core-popper'){
538
+                // Bootstrap bundle
539
+                $url = $this->url.'assets/js/bootstrap.bundle.min.js';
540
+                wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest );
541
+                // if in admin then add to footer for compatibility.
542
+                is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle');
543
+                $script = $this->inline_script();
544
+                wp_add_inline_script( 'bootstrap-js-bundle', $script );
545
+            }elseif($this->settings[$js_setting]=='popper'){
546
+                $url = $this->url.'assets/js/popper.min.js';
547
+                wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest );
548
+                wp_enqueue_script( 'bootstrap-js-popper' );
549
+                $load_inline = true;
550
+            }else{
551
+                $load_inline = true;
552
+            }
553
+
554
+            // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
555
+            if($load_inline){
556
+                wp_register_script( 'bootstrap-dummy', '',array('jquery') );
557
+                wp_enqueue_script( 'bootstrap-dummy' );
558
+                $script = $this->inline_script();
559
+                wp_add_inline_script( 'bootstrap-dummy', $script  );
560
+            }
561
+
562
+        }
563
+
564
+        /**
565
+         * Enqueue flatpickr if called.
566
+         */
567
+        public function enqueue_flatpickr(){
568
+            wp_enqueue_style( 'flatpickr' );
569
+            wp_enqueue_script( 'flatpickr' );
570
+        }
571
+
572
+        /**
573
+         * Get the url path to the current folder.
574
+         *
575
+         * @return string
576
+         */
577
+        public function get_url() {
578
+
579
+            $url = '';
580
+            // check if we are inside a plugin
581
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
582
+
583
+            // add check in-case user has changed wp-content dir name.
584
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
585
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
586
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
587
+
588
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
589
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
590
+            }
591
+
592
+            return $url;
593
+        }
594
+
595
+        /**
596
+         * Register the database settings with WordPress.
597
+         */
598
+        public function register_settings() {
599
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
600
+        }
601
+
602
+        /**
603
+         * Add the WordPress settings menu item.
604
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
605
+         */
606
+        public function menu_item() {
607
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
608
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
609
+                $this,
610
+                'settings_page'
611
+            ) );
612
+        }
613
+
614
+        /**
615
+         * Get a list of themes and their default JS settings.
616
+         *
617
+         * @return array
618
+         */
619
+        public function theme_js_settings(){
620
+            return array(
621
+                'ayetheme' => 'popper',
622
+                'listimia' => 'required',
623
+                'listimia_backend' => 'core-popper',
624
+                'avada'    => 'required',
625
+            );
626
+        }
627
+
628
+        /**
629
+         * Get the current Font Awesome output settings.
630
+         *
631
+         * @return array The array of settings.
632
+         */
633
+        public function get_settings() {
634
+
635
+            $db_settings = get_option( 'ayecode-ui-settings' );
636
+            $js_default = 'core-popper';
637
+            $js_default_backend = $js_default;
638
+
639
+            // maybe set defaults (if no settings set)
640
+            if(empty($db_settings)){
641
+                $active_theme = strtolower( get_template() ); // active parent theme.
642
+                $theme_js_settings = self::theme_js_settings();
643
+                if(isset($theme_js_settings[$active_theme])){
644
+                    $js_default = $theme_js_settings[$active_theme];
645
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
646
+                }
647
+            }
648
+
649
+            $defaults = array(
650
+                'css'       => 'compatibility', // core, compatibility
651
+                'js'        => $js_default, // js to load, core-popper, popper
652
+                'html_font_size'        => '16', // js to load, core-popper, popper
653
+                'css_backend'       => 'compatibility', // core, compatibility
654
+                'js_backend'        => $js_default_backend, // js to load, core-popper, popper
655
+                'disable_admin'     =>  '', // URL snippets to disable loading on admin
656
+            );
657
+
658
+            $settings = wp_parse_args( $db_settings, $defaults );
659
+
660
+            /**
661
+             * Filter the Bootstrap settings.
662
+             *
663
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
664
+             */
665
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
666
+        }
667
+
668
+
669
+        /**
670
+         * The settings page html output.
671
+         */
672
+        public function settings_page() {
673
+            if ( ! current_user_can( 'manage_options' ) ) {
674
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
675
+            }
676
+            ?>
677 677
 			<div class="wrap">
678 678
 				<h1><?php echo $this->name; ?></h1>
679 679
 				<p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p>
680 680
 				<form method="post" action="options.php">
681 681
 					<?php
682
-					settings_fields( 'ayecode-ui-settings' );
683
-					do_settings_sections( 'ayecode-ui-settings' );
684
-					?>
682
+                    settings_fields( 'ayecode-ui-settings' );
683
+                    do_settings_sections( 'ayecode-ui-settings' );
684
+                    ?>
685 685
 
686 686
 					<h2><?php _e( 'Frontend', 'aui' ); ?></h2>
687 687
 					<table class="form-table wpbs-table-settings">
@@ -761,485 +761,485 @@  discard block
 block discarded – undo
761 761
 					</table>
762 762
 
763 763
 					<?php
764
-					submit_button();
765
-					?>
764
+                    submit_button();
765
+                    ?>
766 766
 				</form>
767 767
 
768 768
 				<div id="wpbs-version"><?php echo $this->version; ?></div>
769 769
 			</div>
770 770
 
771 771
 			<?php
772
-		}
773
-
774
-		public function customizer_settings($wp_customize){
775
-			$wp_customize->add_section('aui_settings', array(
776
-				'title'    => __('AyeCode UI'),
777
-				'priority' => 120,
778
-			));
779
-
780
-			//  =============================
781
-			//  = Color Picker              =
782
-			//  =============================
783
-			$wp_customize->add_setting('aui_options[color_primary]', array(
784
-				'default'           => '#1e73be',
785
-				'sanitize_callback' => 'sanitize_hex_color',
786
-				'capability'        => 'edit_theme_options',
787
-				'type'              => 'option',
788
-				'transport'         => 'refresh',
789
-			));
790
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
791
-				'label'    => __('Primary Color'),
792
-				'section'  => 'aui_settings',
793
-				'settings' => 'aui_options[color_primary]',
794
-			)));
795
-
796
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
797
-				'default'           => '#6c757d',
798
-				'sanitize_callback' => 'sanitize_hex_color',
799
-				'capability'        => 'edit_theme_options',
800
-				'type'              => 'option',
801
-				'transport'         => 'refresh',
802
-			));
803
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
804
-				'label'    => __('Secondary Color'),
805
-				'section'  => 'aui_settings',
806
-				'settings' => 'aui_options[color_secondary]',
807
-			)));
808
-		}
809
-
810
-
811
-		public static function custom_css($compatibility = true) {
812
-			$settings = get_option('aui_options');
813
-
814
-			ob_start();
815
-			?>
772
+        }
773
+
774
+        public function customizer_settings($wp_customize){
775
+            $wp_customize->add_section('aui_settings', array(
776
+                'title'    => __('AyeCode UI'),
777
+                'priority' => 120,
778
+            ));
779
+
780
+            //  =============================
781
+            //  = Color Picker              =
782
+            //  =============================
783
+            $wp_customize->add_setting('aui_options[color_primary]', array(
784
+                'default'           => '#1e73be',
785
+                'sanitize_callback' => 'sanitize_hex_color',
786
+                'capability'        => 'edit_theme_options',
787
+                'type'              => 'option',
788
+                'transport'         => 'refresh',
789
+            ));
790
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
791
+                'label'    => __('Primary Color'),
792
+                'section'  => 'aui_settings',
793
+                'settings' => 'aui_options[color_primary]',
794
+            )));
795
+
796
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
797
+                'default'           => '#6c757d',
798
+                'sanitize_callback' => 'sanitize_hex_color',
799
+                'capability'        => 'edit_theme_options',
800
+                'type'              => 'option',
801
+                'transport'         => 'refresh',
802
+            ));
803
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
804
+                'label'    => __('Secondary Color'),
805
+                'section'  => 'aui_settings',
806
+                'settings' => 'aui_options[color_secondary]',
807
+            )));
808
+        }
809
+
810
+
811
+        public static function custom_css($compatibility = true) {
812
+            $settings = get_option('aui_options');
813
+
814
+            ob_start();
815
+            ?>
816 816
 			<style>
817 817
 				<?php
818
-					if(!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be"){
819
-						echo self::css_primary($settings['color_primary'],$compatibility);
820
-					}
818
+                    if(!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be"){
819
+                        echo self::css_primary($settings['color_primary'],$compatibility);
820
+                    }
821 821
 
822
-					if(!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d"){
823
-						echo self::css_secondary($settings['color_secondary'],$compatibility);
824
-					}
822
+                    if(!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d"){
823
+                        echo self::css_secondary($settings['color_secondary'],$compatibility);
824
+                    }
825 825
                 ?>
826 826
 			</style>
827 827
 			<?php
828 828
 
829 829
 
830
-			/*
830
+            /*
831 831
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
832 832
 			 */
833
-			return str_replace( array(
834
-				'<style>',
835
-				'</style>'
836
-			), '', ob_get_clean());
837
-		}
838
-
839
-		public static function css_primary($color_code,$compatibility){;
840
-			$color_code = sanitize_hex_color($color_code);
841
-			if(!$color_code){return '';}
842
-			/**
843
-			 * c = color, b = background color, o = border-color, f = fill
844
-			 */
845
-			$selectors = array(
846
-				'a' => array('c'),
847
-				'.btn-primary' => array('b','o'),
848
-				'.btn-primary.disabled' => array('b','o'),
849
-				'.btn-primary:disabled' => array('b','o'),
850
-				'.btn-outline-primary' => array('c','o'),
851
-				'.btn-outline-primary:hover' => array('b','o'),
852
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
853
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
854
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
855
-				'.btn-link' => array('c'),
856
-				'.dropdown-item.active' => array('b'),
857
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
858
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
833
+            return str_replace( array(
834
+                '<style>',
835
+                '</style>'
836
+            ), '', ob_get_clean());
837
+        }
838
+
839
+        public static function css_primary($color_code,$compatibility){;
840
+            $color_code = sanitize_hex_color($color_code);
841
+            if(!$color_code){return '';}
842
+            /**
843
+             * c = color, b = background color, o = border-color, f = fill
844
+             */
845
+            $selectors = array(
846
+                'a' => array('c'),
847
+                '.btn-primary' => array('b','o'),
848
+                '.btn-primary.disabled' => array('b','o'),
849
+                '.btn-primary:disabled' => array('b','o'),
850
+                '.btn-outline-primary' => array('c','o'),
851
+                '.btn-outline-primary:hover' => array('b','o'),
852
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
853
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
854
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
855
+                '.btn-link' => array('c'),
856
+                '.dropdown-item.active' => array('b'),
857
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
858
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
859 859
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
860 860
 //				'.custom-range::-moz-range-thumb' => array('b'),
861 861
 //				'.custom-range::-ms-thumb' => array('b'),
862
-				'.nav-pills .nav-link.active' => array('b'),
863
-				'.nav-pills .show>.nav-link' => array('b'),
864
-				'.page-link' => array('c'),
865
-				'.page-item.active .page-link' => array('b','o'),
866
-				'.badge-primary' => array('b'),
867
-				'.alert-primary' => array('b','o'),
868
-				'.progress-bar' => array('b'),
869
-				'.list-group-item.active' => array('b','o'),
870
-				'.bg-primary' => array('b','f'),
871
-				'.btn-link.btn-primary' => array('c'),
872
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
873
-			);
874
-
875
-			$important_selectors = array(
876
-				'.bg-primary' => array('b','f'),
877
-				'.border-primary' => array('o'),
878
-				'.text-primary' => array('c'),
879
-			);
880
-
881
-			$color = array();
882
-			$color_i = array();
883
-			$background = array();
884
-			$background_i = array();
885
-			$border = array();
886
-			$border_i = array();
887
-			$fill = array();
888
-			$fill_i = array();
889
-
890
-			$output = '';
891
-
892
-			// build rules into each type
893
-			foreach($selectors as $selector => $types){
894
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
895
-				$types = array_combine($types,$types);
896
-				if(isset($types['c'])){$color[] = $selector;}
897
-				if(isset($types['b'])){$background[] = $selector;}
898
-				if(isset($types['o'])){$border[] = $selector;}
899
-				if(isset($types['f'])){$fill[] = $selector;}
900
-			}
901
-
902
-			// build rules into each type
903
-			foreach($important_selectors as $selector => $types){
904
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
905
-				$types = array_combine($types,$types);
906
-				if(isset($types['c'])){$color_i[] = $selector;}
907
-				if(isset($types['b'])){$background_i[] = $selector;}
908
-				if(isset($types['o'])){$border_i[] = $selector;}
909
-				if(isset($types['f'])){$fill_i[] = $selector;}
910
-			}
911
-
912
-			// add any color rules
913
-			if(!empty($color)){
914
-				$output .= implode(",",$color) . "{color: $color_code;} ";
915
-			}
916
-			if(!empty($color_i)){
917
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
918
-			}
919
-
920
-			// add any background color rules
921
-			if(!empty($background)){
922
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
923
-			}
924
-			if(!empty($background_i)){
925
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
926
-			}
927
-
928
-			// add any border color rules
929
-			if(!empty($border)){
930
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
931
-			}
932
-			if(!empty($border_i)){
933
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
934
-			}
935
-
936
-			// add any fill color rules
937
-			if(!empty($fill)){
938
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
939
-			}
940
-			if(!empty($fill_i)){
941
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
942
-			}
943
-
944
-
945
-			$prefix = $compatibility ? ".bsui " : "";
946
-
947
-			// darken
948
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
949
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
950
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
951
-
952
-			// lighten
953
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
954
-
955
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
956
-			$op_25 = $color_code."40"; // 25% opacity
957
-
958
-
959
-			// button states
960
-			$output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
961
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
962
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
963
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
964
-
965
-
966
-			// dropdown's
967
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
968
-
969
-
970
-			// input states
971
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
972
-
973
-			// page link
974
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
975
-
976
-			return $output;
977
-		}
978
-
979
-		public static function css_secondary($color_code,$compatibility){;
980
-			$color_code = sanitize_hex_color($color_code);
981
-			if(!$color_code){return '';}
982
-			/**
983
-			 * c = color, b = background color, o = border-color, f = fill
984
-			 */
985
-			$selectors = array(
986
-				'.btn-secondary' => array('b','o'),
987
-				'.btn-secondary.disabled' => array('b','o'),
988
-				'.btn-secondary:disabled' => array('b','o'),
989
-				'.btn-outline-secondary' => array('c','o'),
990
-				'.btn-outline-secondary:hover' => array('b','o'),
991
-				'.btn-outline-secondary.disabled' => array('c'),
992
-				'.btn-outline-secondary:disabled' => array('c'),
993
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
994
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
995
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
996
-				'.badge-secondary' => array('b'),
997
-				'.alert-secondary' => array('b','o'),
998
-				'.btn-link.btn-secondary' => array('c'),
999
-			);
1000
-
1001
-			$important_selectors = array(
1002
-				'.bg-secondary' => array('b','f'),
1003
-				'.border-secondary' => array('o'),
1004
-				'.text-secondary' => array('c'),
1005
-			);
1006
-
1007
-			$color = array();
1008
-			$color_i = array();
1009
-			$background = array();
1010
-			$background_i = array();
1011
-			$border = array();
1012
-			$border_i = array();
1013
-			$fill = array();
1014
-			$fill_i = array();
1015
-
1016
-			$output = '';
1017
-
1018
-			// build rules into each type
1019
-			foreach($selectors as $selector => $types){
1020
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1021
-				$types = array_combine($types,$types);
1022
-				if(isset($types['c'])){$color[] = $selector;}
1023
-				if(isset($types['b'])){$background[] = $selector;}
1024
-				if(isset($types['o'])){$border[] = $selector;}
1025
-				if(isset($types['f'])){$fill[] = $selector;}
1026
-			}
1027
-
1028
-			// build rules into each type
1029
-			foreach($important_selectors as $selector => $types){
1030
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1031
-				$types = array_combine($types,$types);
1032
-				if(isset($types['c'])){$color_i[] = $selector;}
1033
-				if(isset($types['b'])){$background_i[] = $selector;}
1034
-				if(isset($types['o'])){$border_i[] = $selector;}
1035
-				if(isset($types['f'])){$fill_i[] = $selector;}
1036
-			}
1037
-
1038
-			// add any color rules
1039
-			if(!empty($color)){
1040
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1041
-			}
1042
-			if(!empty($color_i)){
1043
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1044
-			}
1045
-
1046
-			// add any background color rules
1047
-			if(!empty($background)){
1048
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1049
-			}
1050
-			if(!empty($background_i)){
1051
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1052
-			}
1053
-
1054
-			// add any border color rules
1055
-			if(!empty($border)){
1056
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1057
-			}
1058
-			if(!empty($border_i)){
1059
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1060
-			}
1061
-
1062
-			// add any fill color rules
1063
-			if(!empty($fill)){
1064
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1065
-			}
1066
-			if(!empty($fill_i)){
1067
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1068
-			}
1069
-
1070
-
1071
-			$prefix = $compatibility ? ".bsui " : "";
1072
-
1073
-			// darken
1074
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1075
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1076
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1077
-
1078
-			// lighten
1079
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1080
-
1081
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1082
-			$op_25 = $color_code."40"; // 25% opacity
1083
-
1084
-
1085
-			// button states
1086
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1087
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1088
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1089
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1090
-
1091
-
1092
-			return $output;
1093
-		}
1094
-
1095
-		/**
1096
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
1097
-		 *
1098
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
1099
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
1100
-		 *
1101
-		 * @return  string
1102
-		 */
1103
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
1104
-			$hexCode = ltrim($hexCode, '#');
1105
-
1106
-			if (strlen($hexCode) == 3) {
1107
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
1108
-			}
1109
-
1110
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
1111
-
1112
-			foreach ($hexCode as & $color) {
1113
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
1114
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
1115
-
1116
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
1117
-			}
1118
-
1119
-			return '#' . implode($hexCode);
1120
-		}
1121
-
1122
-		/**
1123
-		 * Check if we should display examples.
1124
-		 */
1125
-		public function maybe_show_examples(){
1126
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
1127
-				echo "<head>";
1128
-				wp_head();
1129
-				echo "</head>";
1130
-				echo "<body>";
1131
-				echo $this->get_examples();
1132
-				echo "</body>";
1133
-				exit;
1134
-			}
1135
-		}
1136
-
1137
-		/**
1138
-		 * Get developer examples.
1139
-		 *
1140
-		 * @return string
1141
-		 */
1142
-		public function get_examples(){
1143
-			$output = '';
1144
-
1145
-
1146
-			// open form
1147
-			$output .= "<form class='p-5 m-5 border rounded'>";
1148
-
1149
-			// input example
1150
-			$output .= aui()->input(array(
1151
-				'type'  =>  'text',
1152
-				'id'    =>  'text-example',
1153
-				'name'    =>  'text-example',
1154
-				'placeholder'   => 'text placeholder',
1155
-				'title'   => 'Text input example',
1156
-				'value' =>  '',
1157
-				'required'  => false,
1158
-				'help_text' => 'help text',
1159
-				'label' => 'Text input example label'
1160
-			));
1161
-
1162
-			// input example
1163
-			$output .= aui()->input(array(
1164
-				'type'  =>  'url',
1165
-				'id'    =>  'text-example2',
1166
-				'name'    =>  'text-example',
1167
-				'placeholder'   => 'url placeholder',
1168
-				'title'   => 'Text input example',
1169
-				'value' =>  '',
1170
-				'required'  => false,
1171
-				'help_text' => 'help text',
1172
-				'label' => 'Text input example label'
1173
-			));
1174
-
1175
-			// checkbox example
1176
-			$output .= aui()->input(array(
1177
-				'type'  =>  'checkbox',
1178
-				'id'    =>  'checkbox-example',
1179
-				'name'    =>  'checkbox-example',
1180
-				'placeholder'   => 'checkbox-example',
1181
-				'title'   => 'Checkbox example',
1182
-				'value' =>  '1',
1183
-				'checked'   => true,
1184
-				'required'  => false,
1185
-				'help_text' => 'help text',
1186
-				'label' => 'Checkbox checked'
1187
-			));
1188
-
1189
-			// checkbox example
1190
-			$output .= aui()->input(array(
1191
-				'type'  =>  'checkbox',
1192
-				'id'    =>  'checkbox-example2',
1193
-				'name'    =>  'checkbox-example2',
1194
-				'placeholder'   => 'checkbox-example',
1195
-				'title'   => 'Checkbox example',
1196
-				'value' =>  '1',
1197
-				'checked'   => false,
1198
-				'required'  => false,
1199
-				'help_text' => 'help text',
1200
-				'label' => 'Checkbox un-checked'
1201
-			));
1202
-
1203
-			// switch example
1204
-			$output .= aui()->input(array(
1205
-				'type'  =>  'checkbox',
1206
-				'id'    =>  'switch-example',
1207
-				'name'    =>  'switch-example',
1208
-				'placeholder'   => 'checkbox-example',
1209
-				'title'   => 'Switch example',
1210
-				'value' =>  '1',
1211
-				'checked'   => true,
1212
-				'switch'    => true,
1213
-				'required'  => false,
1214
-				'help_text' => 'help text',
1215
-				'label' => 'Switch on'
1216
-			));
1217
-
1218
-			// switch example
1219
-			$output .= aui()->input(array(
1220
-				'type'  =>  'checkbox',
1221
-				'id'    =>  'switch-example2',
1222
-				'name'    =>  'switch-example2',
1223
-				'placeholder'   => 'checkbox-example',
1224
-				'title'   => 'Switch example',
1225
-				'value' =>  '1',
1226
-				'checked'   => false,
1227
-				'switch'    => true,
1228
-				'required'  => false,
1229
-				'help_text' => 'help text',
1230
-				'label' => 'Switch off'
1231
-			));
1232
-
1233
-			// close form
1234
-			$output .= "</form>";
1235
-
1236
-			return $output;
1237
-		}
1238
-
1239
-	}
1240
-
1241
-	/**
1242
-	 * Run the class if found.
1243
-	 */
1244
-	AyeCode_UI_Settings::instance();
862
+                '.nav-pills .nav-link.active' => array('b'),
863
+                '.nav-pills .show>.nav-link' => array('b'),
864
+                '.page-link' => array('c'),
865
+                '.page-item.active .page-link' => array('b','o'),
866
+                '.badge-primary' => array('b'),
867
+                '.alert-primary' => array('b','o'),
868
+                '.progress-bar' => array('b'),
869
+                '.list-group-item.active' => array('b','o'),
870
+                '.bg-primary' => array('b','f'),
871
+                '.btn-link.btn-primary' => array('c'),
872
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
873
+            );
874
+
875
+            $important_selectors = array(
876
+                '.bg-primary' => array('b','f'),
877
+                '.border-primary' => array('o'),
878
+                '.text-primary' => array('c'),
879
+            );
880
+
881
+            $color = array();
882
+            $color_i = array();
883
+            $background = array();
884
+            $background_i = array();
885
+            $border = array();
886
+            $border_i = array();
887
+            $fill = array();
888
+            $fill_i = array();
889
+
890
+            $output = '';
891
+
892
+            // build rules into each type
893
+            foreach($selectors as $selector => $types){
894
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
895
+                $types = array_combine($types,$types);
896
+                if(isset($types['c'])){$color[] = $selector;}
897
+                if(isset($types['b'])){$background[] = $selector;}
898
+                if(isset($types['o'])){$border[] = $selector;}
899
+                if(isset($types['f'])){$fill[] = $selector;}
900
+            }
901
+
902
+            // build rules into each type
903
+            foreach($important_selectors as $selector => $types){
904
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
905
+                $types = array_combine($types,$types);
906
+                if(isset($types['c'])){$color_i[] = $selector;}
907
+                if(isset($types['b'])){$background_i[] = $selector;}
908
+                if(isset($types['o'])){$border_i[] = $selector;}
909
+                if(isset($types['f'])){$fill_i[] = $selector;}
910
+            }
911
+
912
+            // add any color rules
913
+            if(!empty($color)){
914
+                $output .= implode(",",$color) . "{color: $color_code;} ";
915
+            }
916
+            if(!empty($color_i)){
917
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
918
+            }
919
+
920
+            // add any background color rules
921
+            if(!empty($background)){
922
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
923
+            }
924
+            if(!empty($background_i)){
925
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
926
+            }
927
+
928
+            // add any border color rules
929
+            if(!empty($border)){
930
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
931
+            }
932
+            if(!empty($border_i)){
933
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
934
+            }
935
+
936
+            // add any fill color rules
937
+            if(!empty($fill)){
938
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
939
+            }
940
+            if(!empty($fill_i)){
941
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
942
+            }
943
+
944
+
945
+            $prefix = $compatibility ? ".bsui " : "";
946
+
947
+            // darken
948
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
949
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
950
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
951
+
952
+            // lighten
953
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
954
+
955
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
956
+            $op_25 = $color_code."40"; // 25% opacity
957
+
958
+
959
+            // button states
960
+            $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
961
+            $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
962
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
963
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
964
+
965
+
966
+            // dropdown's
967
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
968
+
969
+
970
+            // input states
971
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
972
+
973
+            // page link
974
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
975
+
976
+            return $output;
977
+        }
978
+
979
+        public static function css_secondary($color_code,$compatibility){;
980
+            $color_code = sanitize_hex_color($color_code);
981
+            if(!$color_code){return '';}
982
+            /**
983
+             * c = color, b = background color, o = border-color, f = fill
984
+             */
985
+            $selectors = array(
986
+                '.btn-secondary' => array('b','o'),
987
+                '.btn-secondary.disabled' => array('b','o'),
988
+                '.btn-secondary:disabled' => array('b','o'),
989
+                '.btn-outline-secondary' => array('c','o'),
990
+                '.btn-outline-secondary:hover' => array('b','o'),
991
+                '.btn-outline-secondary.disabled' => array('c'),
992
+                '.btn-outline-secondary:disabled' => array('c'),
993
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
994
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
995
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
996
+                '.badge-secondary' => array('b'),
997
+                '.alert-secondary' => array('b','o'),
998
+                '.btn-link.btn-secondary' => array('c'),
999
+            );
1000
+
1001
+            $important_selectors = array(
1002
+                '.bg-secondary' => array('b','f'),
1003
+                '.border-secondary' => array('o'),
1004
+                '.text-secondary' => array('c'),
1005
+            );
1006
+
1007
+            $color = array();
1008
+            $color_i = array();
1009
+            $background = array();
1010
+            $background_i = array();
1011
+            $border = array();
1012
+            $border_i = array();
1013
+            $fill = array();
1014
+            $fill_i = array();
1015
+
1016
+            $output = '';
1017
+
1018
+            // build rules into each type
1019
+            foreach($selectors as $selector => $types){
1020
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1021
+                $types = array_combine($types,$types);
1022
+                if(isset($types['c'])){$color[] = $selector;}
1023
+                if(isset($types['b'])){$background[] = $selector;}
1024
+                if(isset($types['o'])){$border[] = $selector;}
1025
+                if(isset($types['f'])){$fill[] = $selector;}
1026
+            }
1027
+
1028
+            // build rules into each type
1029
+            foreach($important_selectors as $selector => $types){
1030
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1031
+                $types = array_combine($types,$types);
1032
+                if(isset($types['c'])){$color_i[] = $selector;}
1033
+                if(isset($types['b'])){$background_i[] = $selector;}
1034
+                if(isset($types['o'])){$border_i[] = $selector;}
1035
+                if(isset($types['f'])){$fill_i[] = $selector;}
1036
+            }
1037
+
1038
+            // add any color rules
1039
+            if(!empty($color)){
1040
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1041
+            }
1042
+            if(!empty($color_i)){
1043
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1044
+            }
1045
+
1046
+            // add any background color rules
1047
+            if(!empty($background)){
1048
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1049
+            }
1050
+            if(!empty($background_i)){
1051
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1052
+            }
1053
+
1054
+            // add any border color rules
1055
+            if(!empty($border)){
1056
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1057
+            }
1058
+            if(!empty($border_i)){
1059
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1060
+            }
1061
+
1062
+            // add any fill color rules
1063
+            if(!empty($fill)){
1064
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1065
+            }
1066
+            if(!empty($fill_i)){
1067
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1068
+            }
1069
+
1070
+
1071
+            $prefix = $compatibility ? ".bsui " : "";
1072
+
1073
+            // darken
1074
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1075
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1076
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1077
+
1078
+            // lighten
1079
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1080
+
1081
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1082
+            $op_25 = $color_code."40"; // 25% opacity
1083
+
1084
+
1085
+            // button states
1086
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1087
+            $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1088
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1089
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1090
+
1091
+
1092
+            return $output;
1093
+        }
1094
+
1095
+        /**
1096
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
1097
+         *
1098
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
1099
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
1100
+         *
1101
+         * @return  string
1102
+         */
1103
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
1104
+            $hexCode = ltrim($hexCode, '#');
1105
+
1106
+            if (strlen($hexCode) == 3) {
1107
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
1108
+            }
1109
+
1110
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
1111
+
1112
+            foreach ($hexCode as & $color) {
1113
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
1114
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
1115
+
1116
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
1117
+            }
1118
+
1119
+            return '#' . implode($hexCode);
1120
+        }
1121
+
1122
+        /**
1123
+         * Check if we should display examples.
1124
+         */
1125
+        public function maybe_show_examples(){
1126
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
1127
+                echo "<head>";
1128
+                wp_head();
1129
+                echo "</head>";
1130
+                echo "<body>";
1131
+                echo $this->get_examples();
1132
+                echo "</body>";
1133
+                exit;
1134
+            }
1135
+        }
1136
+
1137
+        /**
1138
+         * Get developer examples.
1139
+         *
1140
+         * @return string
1141
+         */
1142
+        public function get_examples(){
1143
+            $output = '';
1144
+
1145
+
1146
+            // open form
1147
+            $output .= "<form class='p-5 m-5 border rounded'>";
1148
+
1149
+            // input example
1150
+            $output .= aui()->input(array(
1151
+                'type'  =>  'text',
1152
+                'id'    =>  'text-example',
1153
+                'name'    =>  'text-example',
1154
+                'placeholder'   => 'text placeholder',
1155
+                'title'   => 'Text input example',
1156
+                'value' =>  '',
1157
+                'required'  => false,
1158
+                'help_text' => 'help text',
1159
+                'label' => 'Text input example label'
1160
+            ));
1161
+
1162
+            // input example
1163
+            $output .= aui()->input(array(
1164
+                'type'  =>  'url',
1165
+                'id'    =>  'text-example2',
1166
+                'name'    =>  'text-example',
1167
+                'placeholder'   => 'url placeholder',
1168
+                'title'   => 'Text input example',
1169
+                'value' =>  '',
1170
+                'required'  => false,
1171
+                'help_text' => 'help text',
1172
+                'label' => 'Text input example label'
1173
+            ));
1174
+
1175
+            // checkbox example
1176
+            $output .= aui()->input(array(
1177
+                'type'  =>  'checkbox',
1178
+                'id'    =>  'checkbox-example',
1179
+                'name'    =>  'checkbox-example',
1180
+                'placeholder'   => 'checkbox-example',
1181
+                'title'   => 'Checkbox example',
1182
+                'value' =>  '1',
1183
+                'checked'   => true,
1184
+                'required'  => false,
1185
+                'help_text' => 'help text',
1186
+                'label' => 'Checkbox checked'
1187
+            ));
1188
+
1189
+            // checkbox example
1190
+            $output .= aui()->input(array(
1191
+                'type'  =>  'checkbox',
1192
+                'id'    =>  'checkbox-example2',
1193
+                'name'    =>  'checkbox-example2',
1194
+                'placeholder'   => 'checkbox-example',
1195
+                'title'   => 'Checkbox example',
1196
+                'value' =>  '1',
1197
+                'checked'   => false,
1198
+                'required'  => false,
1199
+                'help_text' => 'help text',
1200
+                'label' => 'Checkbox un-checked'
1201
+            ));
1202
+
1203
+            // switch example
1204
+            $output .= aui()->input(array(
1205
+                'type'  =>  'checkbox',
1206
+                'id'    =>  'switch-example',
1207
+                'name'    =>  'switch-example',
1208
+                'placeholder'   => 'checkbox-example',
1209
+                'title'   => 'Switch example',
1210
+                'value' =>  '1',
1211
+                'checked'   => true,
1212
+                'switch'    => true,
1213
+                'required'  => false,
1214
+                'help_text' => 'help text',
1215
+                'label' => 'Switch on'
1216
+            ));
1217
+
1218
+            // switch example
1219
+            $output .= aui()->input(array(
1220
+                'type'  =>  'checkbox',
1221
+                'id'    =>  'switch-example2',
1222
+                'name'    =>  'switch-example2',
1223
+                'placeholder'   => 'checkbox-example',
1224
+                'title'   => 'Switch example',
1225
+                'value' =>  '1',
1226
+                'checked'   => false,
1227
+                'switch'    => true,
1228
+                'required'  => false,
1229
+                'help_text' => 'help text',
1230
+                'label' => 'Switch off'
1231
+            ));
1232
+
1233
+            // close form
1234
+            $output .= "</form>";
1235
+
1236
+            return $output;
1237
+        }
1238
+
1239
+    }
1240
+
1241
+    /**
1242
+     * Run the class if found.
1243
+     */
1244
+    AyeCode_UI_Settings::instance();
1245 1245
 }
1246 1246
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
22
+if (!class_exists('AyeCode_UI_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -98,22 +98,22 @@  discard block
 block discarded – undo
98 98
 		 * @return AyeCode_UI_Settings - Main instance.
99 99
 		 */
100 100
 		public static function instance() {
101
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
101
+			if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) {
102 102
 				self::$instance = new AyeCode_UI_Settings;
103 103
 
104
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
104
+				add_action('init', array(self::$instance, 'init')); // set settings
105 105
 
106
-				if ( is_admin() ) {
107
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
108
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
106
+				if (is_admin()) {
107
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
108
+					add_action('admin_init', array(self::$instance, 'register_settings'));
109 109
 
110 110
 					// Maybe show example page
111
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
111
+					add_action('template_redirect', array(self::$instance, 'maybe_show_examples'));
112 112
 				}
113 113
 
114
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
114
+				add_action('customize_register', array(self::$instance, 'customizer_settings'));
115 115
 
116
-				do_action( 'ayecode_ui_settings_loaded' );
116
+				do_action('ayecode_ui_settings_loaded');
117 117
 			}
118 118
 
119 119
 			return self::$instance;
@@ -131,24 +131,24 @@  discard block
 block discarded – undo
131 131
 			 *
132 132
 			 * We load super early in case there is a theme version that might change the colors
133 133
 			 */
134
-			if ( $this->settings['css'] ) {
135
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
134
+			if ($this->settings['css']) {
135
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1);
136 136
 			}
137
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
138
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
137
+			if ($this->settings['css_backend'] && $this->load_admin_scripts()) {
138
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1);
139 139
 			}
140 140
 
141 141
 			// maybe load JS
142
-			if ( $this->settings['js'] ) {
143
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
142
+			if ($this->settings['js']) {
143
+				add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
144 144
 			}
145
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
146
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
145
+			if ($this->settings['js_backend'] && $this->load_admin_scripts()) {
146
+				add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1);
147 147
 			}
148 148
 
149 149
 			// Maybe set the HTML font size
150
-			if ( $this->settings['html_font_size'] ) {
151
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
150
+			if ($this->settings['html_font_size']) {
151
+				add_action('wp_footer', array($this, 'html_font_size'), 10);
152 152
 			}
153 153
 
154 154
 
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 		 *
160 160
 		 * @return bool
161 161
 		 */
162
-		public function load_admin_scripts(){
162
+		public function load_admin_scripts() {
163 163
 			$result = true;
164 164
 
165
-			if(!empty($this->settings['disable_admin'])){
166
-				$url_parts = explode("\n",$this->settings['disable_admin']);
167
-				foreach($url_parts as $part){
168
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
165
+			if (!empty($this->settings['disable_admin'])) {
166
+				$url_parts = explode("\n", $this->settings['disable_admin']);
167
+				foreach ($url_parts as $part) {
168
+					if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) {
169 169
 						return false; // return early, no point checking further
170 170
 					}
171 171
 				}
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 		/**
178 178
 		 * Add a html font size to the footer.
179 179
 		 */
180
-		public function html_font_size(){
180
+		public function html_font_size() {
181 181
 			$this->settings = $this->get_settings();
182
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
182
+			echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>";
183 183
 		}
184 184
 
185 185
 		/**
@@ -189,18 +189,18 @@  discard block
 block discarded – undo
189 189
 
190 190
 			$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
191 191
 
192
-			if($this->settings[$css_setting]){
193
-				$compatibility = $this->settings[$css_setting]=='core' ? false : true;
194
-				$url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui.css' : $this->url.'assets/css/ayecode-ui-compatibility.css';
195
-				wp_register_style( 'ayecode-ui', $url, array(), $this->latest );
196
-				wp_enqueue_style( 'ayecode-ui' );
192
+			if ($this->settings[$css_setting]) {
193
+				$compatibility = $this->settings[$css_setting] == 'core' ? false : true;
194
+				$url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui.css' : $this->url . 'assets/css/ayecode-ui-compatibility.css';
195
+				wp_register_style('ayecode-ui', $url, array(), $this->latest);
196
+				wp_enqueue_style('ayecode-ui');
197 197
 
198 198
 				// flatpickr
199
-				wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest );
199
+				wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest);
200 200
 
201 201
 
202 202
 				// fix some wp-admin issues
203
-				if(is_admin()){
203
+				if (is_admin()) {
204 204
 					$custom_css = "
205 205
                 body{
206 206
                     background-color: #f1f1f1;
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 						    padding: 0;
244 244
 						}
245 245
 					";
246
-					wp_add_inline_style( 'ayecode-ui', $custom_css );
246
+					wp_add_inline_style('ayecode-ui', $custom_css);
247 247
 				}
248 248
 
249 249
 				// custom changes
250
-				wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
250
+				wp_add_inline_style('ayecode-ui', self::custom_css($compatibility));
251 251
 
252 252
 			}
253 253
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * If this remains small then its best to use this than to add another JS file.
259 259
 		 */
260
-		public function inline_script(){
260
+		public function inline_script() {
261 261
 			ob_start();
262 262
 			?>
263 263
 			<script>
@@ -483,10 +483,10 @@  discard block
 block discarded – undo
483 483
 			/*
484 484
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
485 485
 			 */
486
-			return str_replace( array(
486
+			return str_replace(array(
487 487
 				'<script>',
488 488
 				'</script>'
489
-			), '', $output );
489
+			), '', $output);
490 490
 		}
491 491
 
492 492
 		/**
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		 *
495 495
 		 * If this remains small then its best to use this than to add another JS file.
496 496
 		 */
497
-		public function inline_script_file_browser(){
497
+		public function inline_script_file_browser() {
498 498
 			ob_start();
499 499
 			?>
500 500
 			<script>
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 			/*
510 510
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
511 511
 			 */
512
-			return str_replace( array(
512
+			return str_replace(array(
513 513
 				'<script>',
514 514
 				'</script>'
515
-			), '', $output );
515
+			), '', $output);
516 516
 		}
517 517
 
518 518
 		/**
@@ -523,40 +523,40 @@  discard block
 block discarded – undo
523 523
 			$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
524 524
 
525 525
 			// select2
526
-			wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version );
526
+			wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version);
527 527
 
528 528
 			// flatpickr
529
-			wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest );
529
+			wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest);
530 530
 
531 531
 			// Bootstrap file browser
532
-			wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version );
533
-			wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
532
+			wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version);
533
+			wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser());
534 534
 
535 535
 			$load_inline = false;
536 536
 
537
-			if($this->settings[$js_setting]=='core-popper'){
537
+			if ($this->settings[$js_setting] == 'core-popper') {
538 538
 				// Bootstrap bundle
539
-				$url = $this->url.'assets/js/bootstrap.bundle.min.js';
540
-				wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest );
539
+				$url = $this->url . 'assets/js/bootstrap.bundle.min.js';
540
+				wp_register_script('bootstrap-js-bundle', $url, array('select2', 'jquery'), $this->latest);
541 541
 				// if in admin then add to footer for compatibility.
542
-				is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle');
542
+				is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle');
543 543
 				$script = $this->inline_script();
544
-				wp_add_inline_script( 'bootstrap-js-bundle', $script );
545
-			}elseif($this->settings[$js_setting]=='popper'){
546
-				$url = $this->url.'assets/js/popper.min.js';
547
-				wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest );
548
-				wp_enqueue_script( 'bootstrap-js-popper' );
544
+				wp_add_inline_script('bootstrap-js-bundle', $script);
545
+			}elseif ($this->settings[$js_setting] == 'popper') {
546
+				$url = $this->url . 'assets/js/popper.min.js';
547
+				wp_register_script('bootstrap-js-popper', $url, array('jquery'), $this->latest);
548
+				wp_enqueue_script('bootstrap-js-popper');
549 549
 				$load_inline = true;
550
-			}else{
550
+			} else {
551 551
 				$load_inline = true;
552 552
 			}
553 553
 
554 554
 			// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
555
-			if($load_inline){
556
-				wp_register_script( 'bootstrap-dummy', '',array('jquery') );
557
-				wp_enqueue_script( 'bootstrap-dummy' );
555
+			if ($load_inline) {
556
+				wp_register_script('bootstrap-dummy', '', array('jquery'));
557
+				wp_enqueue_script('bootstrap-dummy');
558 558
 				$script = $this->inline_script();
559
-				wp_add_inline_script( 'bootstrap-dummy', $script  );
559
+				wp_add_inline_script('bootstrap-dummy', $script);
560 560
 			}
561 561
 
562 562
 		}
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 		/**
565 565
 		 * Enqueue flatpickr if called.
566 566
 		 */
567
-		public function enqueue_flatpickr(){
568
-			wp_enqueue_style( 'flatpickr' );
569
-			wp_enqueue_script( 'flatpickr' );
567
+		public function enqueue_flatpickr() {
568
+			wp_enqueue_style('flatpickr');
569
+			wp_enqueue_script('flatpickr');
570 570
 		}
571 571
 
572 572
 		/**
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 
579 579
 			$url = '';
580 580
 			// check if we are inside a plugin
581
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
581
+			$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
582 582
 
583 583
 			// add check in-case user has changed wp-content dir name.
584 584
 			$wp_content_folder_name = basename(WP_CONTENT_DIR);
585
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
586
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
585
+			$dir_parts = explode("/$wp_content_folder_name/", $file_dir);
586
+			$url_parts = explode("/$wp_content_folder_name/", plugins_url());
587 587
 
588
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
589
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
588
+			if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
589
+				$url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]);
590 590
 			}
591 591
 
592 592
 			return $url;
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 		 * Register the database settings with WordPress.
597 597
 		 */
598 598
 		public function register_settings() {
599
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
599
+			register_setting('ayecode-ui-settings', 'ayecode-ui-settings');
600 600
 		}
601 601
 
602 602
 		/**
@@ -605,10 +605,10 @@  discard block
 block discarded – undo
605 605
 		 */
606 606
 		public function menu_item() {
607 607
 			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
608
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
608
+			call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
609 609
 				$this,
610 610
 				'settings_page'
611
-			) );
611
+			));
612 612
 		}
613 613
 
614 614
 		/**
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 *
617 617
 		 * @return array
618 618
 		 */
619
-		public function theme_js_settings(){
619
+		public function theme_js_settings() {
620 620
 			return array(
621 621
 				'ayetheme' => 'popper',
622 622
 				'listimia' => 'required',
@@ -632,17 +632,17 @@  discard block
 block discarded – undo
632 632
 		 */
633 633
 		public function get_settings() {
634 634
 
635
-			$db_settings = get_option( 'ayecode-ui-settings' );
635
+			$db_settings = get_option('ayecode-ui-settings');
636 636
 			$js_default = 'core-popper';
637 637
 			$js_default_backend = $js_default;
638 638
 
639 639
 			// maybe set defaults (if no settings set)
640
-			if(empty($db_settings)){
641
-				$active_theme = strtolower( get_template() ); // active parent theme.
640
+			if (empty($db_settings)) {
641
+				$active_theme = strtolower(get_template()); // active parent theme.
642 642
 				$theme_js_settings = self::theme_js_settings();
643
-				if(isset($theme_js_settings[$active_theme])){
643
+				if (isset($theme_js_settings[$active_theme])) {
644 644
 					$js_default = $theme_js_settings[$active_theme];
645
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
645
+					$js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default;
646 646
 				}
647 647
 			}
648 648
 
@@ -655,14 +655,14 @@  discard block
 block discarded – undo
655 655
 				'disable_admin'     =>  '', // URL snippets to disable loading on admin
656 656
 			);
657 657
 
658
-			$settings = wp_parse_args( $db_settings, $defaults );
658
+			$settings = wp_parse_args($db_settings, $defaults);
659 659
 
660 660
 			/**
661 661
 			 * Filter the Bootstrap settings.
662 662
 			 *
663 663
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
664 664
 			 */
665
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
665
+			return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults);
666 666
 		}
667 667
 
668 668
 
@@ -670,90 +670,90 @@  discard block
 block discarded – undo
670 670
 		 * The settings page html output.
671 671
 		 */
672 672
 		public function settings_page() {
673
-			if ( ! current_user_can( 'manage_options' ) ) {
674
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
673
+			if (!current_user_can('manage_options')) {
674
+				wp_die(__('You do not have sufficient permissions to access this page.', 'aui'));
675 675
 			}
676 676
 			?>
677 677
 			<div class="wrap">
678 678
 				<h1><?php echo $this->name; ?></h1>
679
-				<p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p>
679
+				<p><?php _e("Here you can adjust settings if you are having compatibility issues.", "aui"); ?></p>
680 680
 				<form method="post" action="options.php">
681 681
 					<?php
682
-					settings_fields( 'ayecode-ui-settings' );
683
-					do_settings_sections( 'ayecode-ui-settings' );
682
+					settings_fields('ayecode-ui-settings');
683
+					do_settings_sections('ayecode-ui-settings');
684 684
 					?>
685 685
 
686
-					<h2><?php _e( 'Frontend', 'aui' ); ?></h2>
686
+					<h2><?php _e('Frontend', 'aui'); ?></h2>
687 687
 					<table class="form-table wpbs-table-settings">
688 688
 						<tr valign="top">
689 689
 							<th scope="row"><label
690
-									for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
690
+									for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th>
691 691
 							<td>
692 692
 								<select name="ayecode-ui-settings[css]" id="wpbs-css">
693
-									<option	value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option>
694
-									<option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option>
695
-									<option	value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
693
+									<option	value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option>
694
+									<option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option>
695
+									<option	value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
696 696
 								</select>
697 697
 							</td>
698 698
 						</tr>
699 699
 
700 700
 						<tr valign="top">
701 701
 							<th scope="row"><label
702
-									for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th>
702
+									for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th>
703 703
 							<td>
704 704
 								<select name="ayecode-ui-settings[js]" id="wpbs-js">
705
-									<option	value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
706
-									<option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
707
-									<option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
708
-									<option	value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
705
+									<option	value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
706
+									<option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
707
+									<option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
708
+									<option	value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
709 709
 								</select>
710 710
 							</td>
711 711
 						</tr>
712 712
 
713 713
 						<tr valign="top">
714 714
 							<th scope="row"><label
715
-									for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th>
715
+									for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th>
716 716
 							<td>
717
-								<input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" />
718
-								<p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.","aui");?></p>
717
+								<input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" />
718
+								<p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", "aui"); ?></p>
719 719
 							</td>
720 720
 						</tr>
721 721
 
722 722
 					</table>
723 723
 
724
-					<h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2>
724
+					<h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2>
725 725
 					<table class="form-table wpbs-table-settings">
726 726
 						<tr valign="top">
727 727
 							<th scope="row"><label
728
-									for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th>
728
+									for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th>
729 729
 							<td>
730 730
 								<select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin">
731
-									<option	value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode', 'aui' ); ?></option>
732
-									<option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option>
733
-									<option	value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option>
731
+									<option	value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode', 'aui'); ?></option>
732
+									<option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option>
733
+									<option	value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option>
734 734
 								</select>
735 735
 							</td>
736 736
 						</tr>
737 737
 
738 738
 						<tr valign="top">
739 739
 							<th scope="row"><label
740
-									for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th>
740
+									for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th>
741 741
 							<td>
742 742
 								<select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin">
743
-									<option	value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option>
744
-									<option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option>
745
-									<option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option>
746
-									<option	value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option>
743
+									<option	value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option>
744
+									<option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option>
745
+									<option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option>
746
+									<option	value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option>
747 747
 								</select>
748 748
 							</td>
749 749
 						</tr>
750 750
 
751 751
 						<tr valign="top">
752 752
 							<th scope="row"><label
753
-									for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th>
753
+									for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th>
754 754
 							<td>
755
-								<p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p>
756
-								<textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin'];?></textarea>
755
+								<p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p>
756
+								<textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php &#10;action=go"><?php echo $this->settings['disable_admin']; ?></textarea>
757 757
 
758 758
 							</td>
759 759
 						</tr>
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 			<?php
772 772
 		}
773 773
 
774
-		public function customizer_settings($wp_customize){
774
+		public function customizer_settings($wp_customize) {
775 775
 			$wp_customize->add_section('aui_settings', array(
776 776
 				'title'    => __('AyeCode UI'),
777 777
 				'priority' => 120,
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 				'type'              => 'option',
788 788
 				'transport'         => 'refresh',
789 789
 			));
790
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
790
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
791 791
 				'label'    => __('Primary Color'),
792 792
 				'section'  => 'aui_settings',
793 793
 				'settings' => 'aui_options[color_primary]',
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 				'type'              => 'option',
801 801
 				'transport'         => 'refresh',
802 802
 			));
803
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
803
+			$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
804 804
 				'label'    => __('Secondary Color'),
805 805
 				'section'  => 'aui_settings',
806 806
 				'settings' => 'aui_options[color_secondary]',
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
 			?>
816 816
 			<style>
817 817
 				<?php
818
-					if(!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be"){
819
-						echo self::css_primary($settings['color_primary'],$compatibility);
818
+					if (!empty($settings['color_primary']) && $settings['color_primary'] != "#1e73be") {
819
+						echo self::css_primary($settings['color_primary'], $compatibility);
820 820
 					}
821 821
 
822
-					if(!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d"){
823
-						echo self::css_secondary($settings['color_secondary'],$compatibility);
822
+					if (!empty($settings['color_secondary']) && $settings['color_secondary'] != "#6c757d") {
823
+						echo self::css_secondary($settings['color_secondary'], $compatibility);
824 824
 					}
825 825
                 ?>
826 826
 			</style>
@@ -830,50 +830,50 @@  discard block
 block discarded – undo
830 830
 			/*
831 831
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
832 832
 			 */
833
-			return str_replace( array(
833
+			return str_replace(array(
834 834
 				'<style>',
835 835
 				'</style>'
836 836
 			), '', ob_get_clean());
837 837
 		}
838 838
 
839
-		public static function css_primary($color_code,$compatibility){;
839
+		public static function css_primary($color_code, $compatibility) {;
840 840
 			$color_code = sanitize_hex_color($color_code);
841
-			if(!$color_code){return '';}
841
+			if (!$color_code) {return ''; }
842 842
 			/**
843 843
 			 * c = color, b = background color, o = border-color, f = fill
844 844
 			 */
845 845
 			$selectors = array(
846 846
 				'a' => array('c'),
847
-				'.btn-primary' => array('b','o'),
848
-				'.btn-primary.disabled' => array('b','o'),
849
-				'.btn-primary:disabled' => array('b','o'),
850
-				'.btn-outline-primary' => array('c','o'),
851
-				'.btn-outline-primary:hover' => array('b','o'),
852
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
853
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
854
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
847
+				'.btn-primary' => array('b', 'o'),
848
+				'.btn-primary.disabled' => array('b', 'o'),
849
+				'.btn-primary:disabled' => array('b', 'o'),
850
+				'.btn-outline-primary' => array('c', 'o'),
851
+				'.btn-outline-primary:hover' => array('b', 'o'),
852
+				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'),
853
+				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'),
854
+				'.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'),
855 855
 				'.btn-link' => array('c'),
856 856
 				'.dropdown-item.active' => array('b'),
857
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
858
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
857
+				'.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'),
858
+				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'),
859 859
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
860 860
 //				'.custom-range::-moz-range-thumb' => array('b'),
861 861
 //				'.custom-range::-ms-thumb' => array('b'),
862 862
 				'.nav-pills .nav-link.active' => array('b'),
863 863
 				'.nav-pills .show>.nav-link' => array('b'),
864 864
 				'.page-link' => array('c'),
865
-				'.page-item.active .page-link' => array('b','o'),
865
+				'.page-item.active .page-link' => array('b', 'o'),
866 866
 				'.badge-primary' => array('b'),
867
-				'.alert-primary' => array('b','o'),
867
+				'.alert-primary' => array('b', 'o'),
868 868
 				'.progress-bar' => array('b'),
869
-				'.list-group-item.active' => array('b','o'),
870
-				'.bg-primary' => array('b','f'),
869
+				'.list-group-item.active' => array('b', 'o'),
870
+				'.bg-primary' => array('b', 'f'),
871 871
 				'.btn-link.btn-primary' => array('c'),
872 872
 				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
873 873
 			);
874 874
 
875 875
 			$important_selectors = array(
876
-				'.bg-primary' => array('b','f'),
876
+				'.bg-primary' => array('b', 'f'),
877 877
 				'.border-primary' => array('o'),
878 878
 				'.text-primary' => array('c'),
879 879
 			);
@@ -890,116 +890,116 @@  discard block
 block discarded – undo
890 890
 			$output = '';
891 891
 
892 892
 			// build rules into each type
893
-			foreach($selectors as $selector => $types){
894
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
895
-				$types = array_combine($types,$types);
896
-				if(isset($types['c'])){$color[] = $selector;}
897
-				if(isset($types['b'])){$background[] = $selector;}
898
-				if(isset($types['o'])){$border[] = $selector;}
899
-				if(isset($types['f'])){$fill[] = $selector;}
893
+			foreach ($selectors as $selector => $types) {
894
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
895
+				$types = array_combine($types, $types);
896
+				if (isset($types['c'])) {$color[] = $selector; }
897
+				if (isset($types['b'])) {$background[] = $selector; }
898
+				if (isset($types['o'])) {$border[] = $selector; }
899
+				if (isset($types['f'])) {$fill[] = $selector; }
900 900
 			}
901 901
 
902 902
 			// build rules into each type
903
-			foreach($important_selectors as $selector => $types){
904
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
905
-				$types = array_combine($types,$types);
906
-				if(isset($types['c'])){$color_i[] = $selector;}
907
-				if(isset($types['b'])){$background_i[] = $selector;}
908
-				if(isset($types['o'])){$border_i[] = $selector;}
909
-				if(isset($types['f'])){$fill_i[] = $selector;}
903
+			foreach ($important_selectors as $selector => $types) {
904
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
905
+				$types = array_combine($types, $types);
906
+				if (isset($types['c'])) {$color_i[] = $selector; }
907
+				if (isset($types['b'])) {$background_i[] = $selector; }
908
+				if (isset($types['o'])) {$border_i[] = $selector; }
909
+				if (isset($types['f'])) {$fill_i[] = $selector; }
910 910
 			}
911 911
 
912 912
 			// add any color rules
913
-			if(!empty($color)){
914
-				$output .= implode(",",$color) . "{color: $color_code;} ";
913
+			if (!empty($color)) {
914
+				$output .= implode(",", $color) . "{color: $color_code;} ";
915 915
 			}
916
-			if(!empty($color_i)){
917
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
916
+			if (!empty($color_i)) {
917
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
918 918
 			}
919 919
 
920 920
 			// add any background color rules
921
-			if(!empty($background)){
922
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
921
+			if (!empty($background)) {
922
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
923 923
 			}
924
-			if(!empty($background_i)){
925
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
924
+			if (!empty($background_i)) {
925
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
926 926
 			}
927 927
 
928 928
 			// add any border color rules
929
-			if(!empty($border)){
930
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
929
+			if (!empty($border)) {
930
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
931 931
 			}
932
-			if(!empty($border_i)){
933
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
932
+			if (!empty($border_i)) {
933
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
934 934
 			}
935 935
 
936 936
 			// add any fill color rules
937
-			if(!empty($fill)){
938
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
937
+			if (!empty($fill)) {
938
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
939 939
 			}
940
-			if(!empty($fill_i)){
941
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
940
+			if (!empty($fill_i)) {
941
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
942 942
 			}
943 943
 
944 944
 
945 945
 			$prefix = $compatibility ? ".bsui " : "";
946 946
 
947 947
 			// darken
948
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
949
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
950
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
948
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
949
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
950
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
951 951
 
952 952
 			// lighten
953
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
953
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
954 954
 
955 955
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
956
-			$op_25 = $color_code."40"; // 25% opacity
956
+			$op_25 = $color_code . "40"; // 25% opacity
957 957
 
958 958
 
959 959
 			// button states
960
-			$output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
961
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
962
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
963
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
960
+			$output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
961
+			$output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
962
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
963
+			$output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
964 964
 
965 965
 
966 966
 			// dropdown's
967
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
967
+			$output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
968 968
 
969 969
 
970 970
 			// input states
971
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
971
+			$output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} ";
972 972
 
973 973
 			// page link
974
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
974
+			$output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
975 975
 
976 976
 			return $output;
977 977
 		}
978 978
 
979
-		public static function css_secondary($color_code,$compatibility){;
979
+		public static function css_secondary($color_code, $compatibility) {;
980 980
 			$color_code = sanitize_hex_color($color_code);
981
-			if(!$color_code){return '';}
981
+			if (!$color_code) {return ''; }
982 982
 			/**
983 983
 			 * c = color, b = background color, o = border-color, f = fill
984 984
 			 */
985 985
 			$selectors = array(
986
-				'.btn-secondary' => array('b','o'),
987
-				'.btn-secondary.disabled' => array('b','o'),
988
-				'.btn-secondary:disabled' => array('b','o'),
989
-				'.btn-outline-secondary' => array('c','o'),
990
-				'.btn-outline-secondary:hover' => array('b','o'),
986
+				'.btn-secondary' => array('b', 'o'),
987
+				'.btn-secondary.disabled' => array('b', 'o'),
988
+				'.btn-secondary:disabled' => array('b', 'o'),
989
+				'.btn-outline-secondary' => array('c', 'o'),
990
+				'.btn-outline-secondary:hover' => array('b', 'o'),
991 991
 				'.btn-outline-secondary.disabled' => array('c'),
992 992
 				'.btn-outline-secondary:disabled' => array('c'),
993
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
994
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
995
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
993
+				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'),
994
+				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'),
995
+				'.btn-outline-secondary.dropdown-toggle' => array('b', 'o'),
996 996
 				'.badge-secondary' => array('b'),
997
-				'.alert-secondary' => array('b','o'),
997
+				'.alert-secondary' => array('b', 'o'),
998 998
 				'.btn-link.btn-secondary' => array('c'),
999 999
 			);
1000 1000
 
1001 1001
 			$important_selectors = array(
1002
-				'.bg-secondary' => array('b','f'),
1002
+				'.bg-secondary' => array('b', 'f'),
1003 1003
 				'.border-secondary' => array('o'),
1004 1004
 				'.text-secondary' => array('c'),
1005 1005
 			);
@@ -1016,77 +1016,77 @@  discard block
 block discarded – undo
1016 1016
 			$output = '';
1017 1017
 
1018 1018
 			// build rules into each type
1019
-			foreach($selectors as $selector => $types){
1020
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1021
-				$types = array_combine($types,$types);
1022
-				if(isset($types['c'])){$color[] = $selector;}
1023
-				if(isset($types['b'])){$background[] = $selector;}
1024
-				if(isset($types['o'])){$border[] = $selector;}
1025
-				if(isset($types['f'])){$fill[] = $selector;}
1019
+			foreach ($selectors as $selector => $types) {
1020
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1021
+				$types = array_combine($types, $types);
1022
+				if (isset($types['c'])) {$color[] = $selector; }
1023
+				if (isset($types['b'])) {$background[] = $selector; }
1024
+				if (isset($types['o'])) {$border[] = $selector; }
1025
+				if (isset($types['f'])) {$fill[] = $selector; }
1026 1026
 			}
1027 1027
 
1028 1028
 			// build rules into each type
1029
-			foreach($important_selectors as $selector => $types){
1030
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1031
-				$types = array_combine($types,$types);
1032
-				if(isset($types['c'])){$color_i[] = $selector;}
1033
-				if(isset($types['b'])){$background_i[] = $selector;}
1034
-				if(isset($types['o'])){$border_i[] = $selector;}
1035
-				if(isset($types['f'])){$fill_i[] = $selector;}
1029
+			foreach ($important_selectors as $selector => $types) {
1030
+				$selector = $compatibility ? ".bsui " . $selector : $selector;
1031
+				$types = array_combine($types, $types);
1032
+				if (isset($types['c'])) {$color_i[] = $selector; }
1033
+				if (isset($types['b'])) {$background_i[] = $selector; }
1034
+				if (isset($types['o'])) {$border_i[] = $selector; }
1035
+				if (isset($types['f'])) {$fill_i[] = $selector; }
1036 1036
 			}
1037 1037
 
1038 1038
 			// add any color rules
1039
-			if(!empty($color)){
1040
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1039
+			if (!empty($color)) {
1040
+				$output .= implode(",", $color) . "{color: $color_code;} ";
1041 1041
 			}
1042
-			if(!empty($color_i)){
1043
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1042
+			if (!empty($color_i)) {
1043
+				$output .= implode(",", $color_i) . "{color: $color_code !important;} ";
1044 1044
 			}
1045 1045
 
1046 1046
 			// add any background color rules
1047
-			if(!empty($background)){
1048
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1047
+			if (!empty($background)) {
1048
+				$output .= implode(",", $background) . "{background-color: $color_code;} ";
1049 1049
 			}
1050
-			if(!empty($background_i)){
1051
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1050
+			if (!empty($background_i)) {
1051
+				$output .= implode(",", $background_i) . "{background-color: $color_code !important;} ";
1052 1052
 			}
1053 1053
 
1054 1054
 			// add any border color rules
1055
-			if(!empty($border)){
1056
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1055
+			if (!empty($border)) {
1056
+				$output .= implode(",", $border) . "{border-color: $color_code;} ";
1057 1057
 			}
1058
-			if(!empty($border_i)){
1059
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1058
+			if (!empty($border_i)) {
1059
+				$output .= implode(",", $border_i) . "{border-color: $color_code !important;} ";
1060 1060
 			}
1061 1061
 
1062 1062
 			// add any fill color rules
1063
-			if(!empty($fill)){
1064
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1063
+			if (!empty($fill)) {
1064
+				$output .= implode(",", $fill) . "{fill: $color_code;} ";
1065 1065
 			}
1066
-			if(!empty($fill_i)){
1067
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1066
+			if (!empty($fill_i)) {
1067
+				$output .= implode(",", $fill_i) . "{fill: $color_code !important;} ";
1068 1068
 			}
1069 1069
 
1070 1070
 
1071 1071
 			$prefix = $compatibility ? ".bsui " : "";
1072 1072
 
1073 1073
 			// darken
1074
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1075
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1076
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1074
+			$darker_075 = self::css_hex_lighten_darken($color_code, "-0.075");
1075
+			$darker_10 = self::css_hex_lighten_darken($color_code, "-0.10");
1076
+			$darker_125 = self::css_hex_lighten_darken($color_code, "-0.125");
1077 1077
 
1078 1078
 			// lighten
1079
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1079
+			$lighten_25 = self::css_hex_lighten_darken($color_code, "0.25");
1080 1080
 
1081 1081
 			// opacity see https://css-tricks.com/8-digit-hex-codes/
1082
-			$op_25 = $color_code."40"; // 25% opacity
1082
+			$op_25 = $color_code . "40"; // 25% opacity
1083 1083
 
1084 1084
 
1085 1085
 			// button states
1086
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1087
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1088
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1089
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1086
+			$output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . ";    border-color: " . $darker_10 . ";} ";
1087
+			$output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1088
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . ";    border-color: " . $darker_125 . ";} ";
1089
+			$output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1090 1090
 
1091 1091
 
1092 1092
 			return $output;
@@ -1122,8 +1122,8 @@  discard block
 block discarded – undo
1122 1122
 		/**
1123 1123
 		 * Check if we should display examples.
1124 1124
 		 */
1125
-		public function maybe_show_examples(){
1126
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
1125
+		public function maybe_show_examples() {
1126
+			if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
1127 1127
 				echo "<head>";
1128 1128
 				wp_head();
1129 1129
 				echo "</head>";
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 		 *
1140 1140
 		 * @return string
1141 1141
 		 */
1142
-		public function get_examples(){
1142
+		public function get_examples() {
1143 1143
 			$output = '';
1144 1144
 
1145 1145
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -542,12 +542,12 @@
 block discarded – undo
542 542
 				is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle');
543 543
 				$script = $this->inline_script();
544 544
 				wp_add_inline_script( 'bootstrap-js-bundle', $script );
545
-			}elseif($this->settings[$js_setting]=='popper'){
545
+			} elseif($this->settings[$js_setting]=='popper'){
546 546
 				$url = $this->url.'assets/js/popper.min.js';
547 547
 				wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest );
548 548
 				wp_enqueue_script( 'bootstrap-js-popper' );
549 549
 				$load_inline = true;
550
-			}else{
550
+			} else{
551 551
 				$load_inline = true;
552 552
 			}
553 553
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.22";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.22";
19
+    if(version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.22";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 3 patches
Indentation   +1787 added lines, -1787 removed lines patch added patch discarded remove patch
@@ -1,262 +1,262 @@  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 8
 
9
-	/**
10
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
-	 *
12
-	 * Should not be called direct but extended instead.
13
-	 *
14
-	 * Class WP_Super_Duper
15
-	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
16
-	 * @ver 1.0.19
17
-	 */
18
-	class WP_Super_Duper extends WP_Widget {
19
-
20
-		public $version = "1.0.21";
21
-		public $font_awesome_icon_version = "5.11.2";
22
-		public $block_code;
23
-		public $options;
24
-		public $base_id;
25
-		public $settings_hash;
26
-		public $arguments = array();
27
-		public $instance = array();
28
-		private $class_name;
29
-
30
-		/**
31
-		 * The relative url to the current folder.
32
-		 *
33
-		 * @var string
34
-		 */
35
-		public $url = '';
36
-
37
-		/**
38
-		 * Take the array options and use them to build.
39
-		 */
40
-		public function __construct( $options ) {
41
-			global $sd_widgets;
42
-
43
-			$sd_widgets[ $options['base_id'] ] = array(
44
-				'name'       => $options['name'],
45
-				'class_name' => $options['class_name']
46
-			);
47
-			$this->base_id                     = $options['base_id'];
48
-			// lets filter the options before we do anything
49
-			$options       = apply_filters( "wp_super_duper_options", $options );
50
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
51
-			$options       = $this->add_name_from_key( $options );
52
-			$this->options = $options;
53
-
54
-			$this->base_id   = $options['base_id'];
55
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
56
-
57
-			// init parent
58
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
59
-
60
-			if ( isset( $options['class_name'] ) ) {
61
-				// register widget
62
-				$this->class_name = $options['class_name'];
63
-
64
-				// register shortcode
65
-				$this->register_shortcode();
66
-
67
-				// Fusion Builder (avada) support
68
-				if ( function_exists( 'fusion_builder_map' ) ) {
69
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
70
-				}
71
-
72
-				// register block
73
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
74
-			}
75
-
76
-			// add the CSS and JS we need ONCE
77
-			global $sd_widget_scripts;
78
-
79
-			if ( ! $sd_widget_scripts ) {
80
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
81
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
82
-				wp_add_inline_style( 'widgets', $this->widget_css() );
83
-
84
-				// maybe add elementor editor styles
85
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
86
-
87
-				$sd_widget_scripts = true;
88
-
89
-				// add shortcode insert button once
90
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
91
-				// generatepress theme sections compatibility
92
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
93
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
94
-				}
95
-				if ( $this->is_preview() ) {
96
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
97
-					// this makes the insert button work for elementor
98
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
99
-						$this,
100
-						'shortcode_insert_button_script'
101
-					) ); // for elementor
102
-				}
103
-				// this makes the insert button work for cornerstone
104
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
105
-
106
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
107
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
108
-
109
-				// add generator text to admin head
110
-				add_action( 'admin_head', array( $this, 'generator' ) );
111
-			}
112
-
113
-			do_action( 'wp_super_duper_widget_init', $options, $this );
114
-		}
115
-
116
-		/**
117
-		 * Add our widget CSS to elementor editor.
118
-		 */
119
-		public function elementor_editor_styles() {
120
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
121
-		}
122
-
123
-		public function register_fusion_element() {
124
-
125
-			$options = $this->options;
126
-
127
-			if ( $this->base_id ) {
128
-
129
-				$params = $this->get_fusion_params();
130
-
131
-				$args = array(
132
-					'name'            => $options['name'],
133
-					'shortcode'       => $this->base_id,
134
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
135
-					'allow_generator' => true,
136
-				);
137
-
138
-				if ( ! empty( $params ) ) {
139
-					$args['params'] = $params;
140
-				}
141
-
142
-				fusion_builder_map( $args );
143
-			}
144
-
145
-		}
146
-
147
-		public function get_fusion_params() {
148
-			$params    = array();
149
-			$arguments = $this->get_arguments();
150
-
151
-			if ( ! empty( $arguments ) ) {
152
-				foreach ( $arguments as $key => $val ) {
153
-					$param = array();
154
-					// type
155
-					$param['type'] = str_replace(
156
-						array(
157
-							"text",
158
-							"number",
159
-							"email",
160
-							"color",
161
-							"checkbox"
162
-						),
163
-						array(
164
-							"textfield",
165
-							"textfield",
166
-							"textfield",
167
-							"colorpicker",
168
-							"select",
169
-
170
-						),
171
-						$val['type'] );
172
-
173
-					// multiselect
174
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
175
-						$param['type']     = 'multiple_select';
176
-						$param['multiple'] = true;
177
-					}
178
-
179
-					// heading
180
-					$param['heading'] = $val['title'];
181
-
182
-					// description
183
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
184
-
185
-					// param_name
186
-					$param['param_name'] = $key;
187
-
188
-					// Default
189
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
190
-
191
-					// Group
192
-					if ( isset( $val['group'] ) ) {
193
-						$param['group'] = $val['group'];
194
-					}
195
-
196
-					// value
197
-					if ( $val['type'] == 'checkbox' ) {
198
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
199
-							unset( $param['default'] );
200
-						}
201
-						$param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
202
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
203
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
204
-					} else {
205
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
206
-					}
207
-
208
-					// setup the param
209
-					$params[] = $param;
210
-
211
-				}
212
-			}
213
-
214
-
215
-			return $params;
216
-		}
217
-
218
-		/**
219
-		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
220
-		 */
221
-		public static function maybe_cornerstone_builder() {
222
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
223
-				self::shortcode_insert_button_script();
224
-			}
225
-		}
226
-
227
-		/**
228
-		 * A function to ge the shortcode builder picker html.
229
-		 *
230
-		 * @param string $editor_id
231
-		 *
232
-		 * @return string
233
-		 */
234
-		public static function get_picker( $editor_id = '' ) {
235
-
236
-			ob_start();
237
-			if ( isset( $_POST['editor_id'] ) ) {
238
-				$editor_id = esc_attr( $_POST['editor_id'] );
239
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
240
-				$editor_id = 'main_content_content_vb_tiny_mce';
241
-			}
242
-
243
-			global $sd_widgets;
244
-			?>
9
+    /**
10
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
+     *
12
+     * Should not be called direct but extended instead.
13
+     *
14
+     * Class WP_Super_Duper
15
+     * @since 1.0.16 change log moved to file change-log.txt - CHANGED
16
+     * @ver 1.0.19
17
+     */
18
+    class WP_Super_Duper extends WP_Widget {
19
+
20
+        public $version = "1.0.21";
21
+        public $font_awesome_icon_version = "5.11.2";
22
+        public $block_code;
23
+        public $options;
24
+        public $base_id;
25
+        public $settings_hash;
26
+        public $arguments = array();
27
+        public $instance = array();
28
+        private $class_name;
29
+
30
+        /**
31
+         * The relative url to the current folder.
32
+         *
33
+         * @var string
34
+         */
35
+        public $url = '';
36
+
37
+        /**
38
+         * Take the array options and use them to build.
39
+         */
40
+        public function __construct( $options ) {
41
+            global $sd_widgets;
42
+
43
+            $sd_widgets[ $options['base_id'] ] = array(
44
+                'name'       => $options['name'],
45
+                'class_name' => $options['class_name']
46
+            );
47
+            $this->base_id                     = $options['base_id'];
48
+            // lets filter the options before we do anything
49
+            $options       = apply_filters( "wp_super_duper_options", $options );
50
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
51
+            $options       = $this->add_name_from_key( $options );
52
+            $this->options = $options;
53
+
54
+            $this->base_id   = $options['base_id'];
55
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
56
+
57
+            // init parent
58
+            parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
59
+
60
+            if ( isset( $options['class_name'] ) ) {
61
+                // register widget
62
+                $this->class_name = $options['class_name'];
63
+
64
+                // register shortcode
65
+                $this->register_shortcode();
66
+
67
+                // Fusion Builder (avada) support
68
+                if ( function_exists( 'fusion_builder_map' ) ) {
69
+                    add_action( 'init', array( $this, 'register_fusion_element' ) );
70
+                }
71
+
72
+                // register block
73
+                add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
74
+            }
75
+
76
+            // add the CSS and JS we need ONCE
77
+            global $sd_widget_scripts;
78
+
79
+            if ( ! $sd_widget_scripts ) {
80
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
81
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
82
+                wp_add_inline_style( 'widgets', $this->widget_css() );
83
+
84
+                // maybe add elementor editor styles
85
+                add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
86
+
87
+                $sd_widget_scripts = true;
88
+
89
+                // add shortcode insert button once
90
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
91
+                // generatepress theme sections compatibility
92
+                if ( function_exists( 'generate_sections_sections_metabox' ) ) {
93
+                    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
94
+                }
95
+                if ( $this->is_preview() ) {
96
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
97
+                    // this makes the insert button work for elementor
98
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
99
+                        $this,
100
+                        'shortcode_insert_button_script'
101
+                    ) ); // for elementor
102
+                }
103
+                // this makes the insert button work for cornerstone
104
+                add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
105
+
106
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
107
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
108
+
109
+                // add generator text to admin head
110
+                add_action( 'admin_head', array( $this, 'generator' ) );
111
+            }
112
+
113
+            do_action( 'wp_super_duper_widget_init', $options, $this );
114
+        }
115
+
116
+        /**
117
+         * Add our widget CSS to elementor editor.
118
+         */
119
+        public function elementor_editor_styles() {
120
+            wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
121
+        }
122
+
123
+        public function register_fusion_element() {
124
+
125
+            $options = $this->options;
126
+
127
+            if ( $this->base_id ) {
128
+
129
+                $params = $this->get_fusion_params();
130
+
131
+                $args = array(
132
+                    'name'            => $options['name'],
133
+                    'shortcode'       => $this->base_id,
134
+                    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
135
+                    'allow_generator' => true,
136
+                );
137
+
138
+                if ( ! empty( $params ) ) {
139
+                    $args['params'] = $params;
140
+                }
141
+
142
+                fusion_builder_map( $args );
143
+            }
144
+
145
+        }
146
+
147
+        public function get_fusion_params() {
148
+            $params    = array();
149
+            $arguments = $this->get_arguments();
150
+
151
+            if ( ! empty( $arguments ) ) {
152
+                foreach ( $arguments as $key => $val ) {
153
+                    $param = array();
154
+                    // type
155
+                    $param['type'] = str_replace(
156
+                        array(
157
+                            "text",
158
+                            "number",
159
+                            "email",
160
+                            "color",
161
+                            "checkbox"
162
+                        ),
163
+                        array(
164
+                            "textfield",
165
+                            "textfield",
166
+                            "textfield",
167
+                            "colorpicker",
168
+                            "select",
169
+
170
+                        ),
171
+                        $val['type'] );
172
+
173
+                    // multiselect
174
+                    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
175
+                        $param['type']     = 'multiple_select';
176
+                        $param['multiple'] = true;
177
+                    }
178
+
179
+                    // heading
180
+                    $param['heading'] = $val['title'];
181
+
182
+                    // description
183
+                    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
184
+
185
+                    // param_name
186
+                    $param['param_name'] = $key;
187
+
188
+                    // Default
189
+                    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
190
+
191
+                    // Group
192
+                    if ( isset( $val['group'] ) ) {
193
+                        $param['group'] = $val['group'];
194
+                    }
195
+
196
+                    // value
197
+                    if ( $val['type'] == 'checkbox' ) {
198
+                        if ( isset( $val['default'] ) && $val['default'] == '0' ) {
199
+                            unset( $param['default'] );
200
+                        }
201
+                        $param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
202
+                    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
203
+                        $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
204
+                    } else {
205
+                        $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
206
+                    }
207
+
208
+                    // setup the param
209
+                    $params[] = $param;
210
+
211
+                }
212
+            }
213
+
214
+
215
+            return $params;
216
+        }
217
+
218
+        /**
219
+         * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
220
+         */
221
+        public static function maybe_cornerstone_builder() {
222
+            if ( did_action( 'cornerstone_before_boot_app' ) ) {
223
+                self::shortcode_insert_button_script();
224
+            }
225
+        }
226
+
227
+        /**
228
+         * A function to ge the shortcode builder picker html.
229
+         *
230
+         * @param string $editor_id
231
+         *
232
+         * @return string
233
+         */
234
+        public static function get_picker( $editor_id = '' ) {
235
+
236
+            ob_start();
237
+            if ( isset( $_POST['editor_id'] ) ) {
238
+                $editor_id = esc_attr( $_POST['editor_id'] );
239
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
240
+                $editor_id = 'main_content_content_vb_tiny_mce';
241
+            }
242
+
243
+            global $sd_widgets;
244
+            ?>
245 245
 
246 246
 			<div class="sd-shortcode-left-wrap">
247 247
 				<?php
248
-				ksort( $sd_widgets );
249
-				//				print_r($sd_widgets);exit;
250
-				if ( ! empty( $sd_widgets ) ) {
251
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
252
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
253
-					foreach ( $sd_widgets as $shortcode => $class ) {
254
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
255
-					}
256
-					echo "</select>";
257
-
258
-				}
259
-				?>
248
+                ksort( $sd_widgets );
249
+                //				print_r($sd_widgets);exit;
250
+                if ( ! empty( $sd_widgets ) ) {
251
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
252
+                    echo "<option>" . __( 'Select shortcode' ) . "</option>";
253
+                    foreach ( $sd_widgets as $shortcode => $class ) {
254
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
255
+                    }
256
+                    echo "</select>";
257
+
258
+                }
259
+                ?>
260 260
 				<div class="sd-shortcode-settings"></div>
261 261
 
262 262
 			</div>
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 					<?php if ( $editor_id != '' ) { ?>
268 268
 						<button class="button sd-insert-shortcode-button"
269 269
 						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
270
-							        echo "'" . $editor_id . "'";
271
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
270
+                                    echo "'" . $editor_id . "'";
271
+                                } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
272 272
 					<?php } ?>
273 273
 					<button class="button"
274 274
 					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -276,134 +276,134 @@  discard block
 block discarded – undo
276 276
 			</div>
277 277
 			<?php
278 278
 
279
-			$html = ob_get_clean();
280
-
281
-			if ( wp_doing_ajax() ) {
282
-				echo $html;
283
-				$should_die = true;
284
-
285
-				// some builder get the editor via ajax so we should not die on those ocasions
286
-				$dont_die = array(
287
-					'parent_tag',// WP Bakery
288
-					'avia_request' // enfold
289
-				);
290
-
291
-				foreach ( $dont_die as $request ) {
292
-					if ( isset( $_REQUEST[ $request ] ) ) {
293
-						$should_die = false;
294
-					}
295
-				}
296
-
297
-				if ( $should_die ) {
298
-					wp_die();
299
-				}
300
-
301
-			} else {
302
-				return $html;
303
-			}
304
-
305
-			return '';
306
-
307
-		}
308
-
309
-		/**
310
-		 * Output the version in the admin header.
311
-		 */
312
-		public function generator() {
313
-			echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
314
-		}
315
-
316
-		/**
317
-		 * Get widget settings.
318
-		 *
319
-		 * @since 1.0.0
320
-		 */
321
-		public static function get_widget_settings() {
322
-			global $sd_widgets;
323
-
324
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
325
-			if ( ! $shortcode ) {
326
-				wp_die();
327
-			}
328
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
329
-			if ( ! $widget_args ) {
330
-				wp_die();
331
-			}
332
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
333
-			if ( ! $class_name ) {
334
-				wp_die();
335
-			}
336
-
337
-			// invoke an instance method
338
-			$widget = new $class_name;
339
-
340
-			ob_start();
341
-			$widget->form( array() );
342
-			$form = ob_get_clean();
343
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
344
-			echo "<style>" . $widget->widget_css() . "</style>";
345
-			echo "<script>" . $widget->widget_js() . "</script>";
346
-			?>
279
+            $html = ob_get_clean();
280
+
281
+            if ( wp_doing_ajax() ) {
282
+                echo $html;
283
+                $should_die = true;
284
+
285
+                // some builder get the editor via ajax so we should not die on those ocasions
286
+                $dont_die = array(
287
+                    'parent_tag',// WP Bakery
288
+                    'avia_request' // enfold
289
+                );
290
+
291
+                foreach ( $dont_die as $request ) {
292
+                    if ( isset( $_REQUEST[ $request ] ) ) {
293
+                        $should_die = false;
294
+                    }
295
+                }
296
+
297
+                if ( $should_die ) {
298
+                    wp_die();
299
+                }
300
+
301
+            } else {
302
+                return $html;
303
+            }
304
+
305
+            return '';
306
+
307
+        }
308
+
309
+        /**
310
+         * Output the version in the admin header.
311
+         */
312
+        public function generator() {
313
+            echo '<meta name="generator" content="WP Super Duper v' . $this->version . '" />';
314
+        }
315
+
316
+        /**
317
+         * Get widget settings.
318
+         *
319
+         * @since 1.0.0
320
+         */
321
+        public static function get_widget_settings() {
322
+            global $sd_widgets;
323
+
324
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
325
+            if ( ! $shortcode ) {
326
+                wp_die();
327
+            }
328
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
329
+            if ( ! $widget_args ) {
330
+                wp_die();
331
+            }
332
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
333
+            if ( ! $class_name ) {
334
+                wp_die();
335
+            }
336
+
337
+            // invoke an instance method
338
+            $widget = new $class_name;
339
+
340
+            ob_start();
341
+            $widget->form( array() );
342
+            $form = ob_get_clean();
343
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
344
+            echo "<style>" . $widget->widget_css() . "</style>";
345
+            echo "<script>" . $widget->widget_js() . "</script>";
346
+            ?>
347 347
 			<?php
348
-			wp_die();
349
-		}
350
-
351
-		/**
352
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
353
-		 *
354
-		 * @since 1.0.0
355
-		 *
356
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
357
-		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
358
-		 */
359
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
360
-			global $sd_widgets, $shortcode_insert_button_once;
361
-			if ( $shortcode_insert_button_once ) {
362
-				return;
363
-			}
364
-			add_thickbox();
365
-
366
-
367
-			/**
368
-			 * Cornerstone makes us play dirty tricks :/
369
-			 * 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.
370
-			 */
371
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
372
-				echo '<span id="insert-media-button">';
373
-			}
374
-
375
-			echo self::shortcode_button( 'this', 'true' );
376
-
377
-			// see opening note
378
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
379
-				echo '</span>'; // end #insert-media-button
380
-			}
381
-
382
-			// Add separate script for generatepress theme sections
383
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
384
-			} else {
385
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
386
-			}
387
-
388
-			$shortcode_insert_button_once = true;
389
-		}
390
-
391
-		/**
392
-		 * Gets the shortcode insert button html.
393
-		 *
394
-		 * @param string $id
395
-		 * @param string $search_for_id
396
-		 *
397
-		 * @return mixed
398
-		 */
399
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
400
-			ob_start();
401
-			?>
348
+            wp_die();
349
+        }
350
+
351
+        /**
352
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
353
+         *
354
+         * @since 1.0.0
355
+         *
356
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
357
+         * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
358
+         */
359
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
360
+            global $sd_widgets, $shortcode_insert_button_once;
361
+            if ( $shortcode_insert_button_once ) {
362
+                return;
363
+            }
364
+            add_thickbox();
365
+
366
+
367
+            /**
368
+             * Cornerstone makes us play dirty tricks :/
369
+             * 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.
370
+             */
371
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
372
+                echo '<span id="insert-media-button">';
373
+            }
374
+
375
+            echo self::shortcode_button( 'this', 'true' );
376
+
377
+            // see opening note
378
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
379
+                echo '</span>'; // end #insert-media-button
380
+            }
381
+
382
+            // Add separate script for generatepress theme sections
383
+            if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
384
+            } else {
385
+                self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
386
+            }
387
+
388
+            $shortcode_insert_button_once = true;
389
+        }
390
+
391
+        /**
392
+         * Gets the shortcode insert button html.
393
+         *
394
+         * @param string $id
395
+         * @param string $search_for_id
396
+         *
397
+         * @return mixed
398
+         */
399
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
400
+            ob_start();
401
+            ?>
402 402
 			<span class="sd-lable-shortcode-inserter">
403 403
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
404
-				if ( $search_for_id ) {
405
-					echo "," . $search_for_id;
406
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
404
+                if ( $search_for_id ) {
405
+                    echo "," . $search_for_id;
406
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
407 407
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
408 408
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
409 409
 					      class="dashicons dashicons-screenoptions"></span>
@@ -414,21 +414,21 @@  discard block
 block discarded – undo
414 414
 			</span>
415 415
 
416 416
 			<?php
417
-			$html = ob_get_clean();
418
-
419
-			// remove line breaks so we can use it in js
420
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
421
-		}
422
-
423
-		/**
424
-		 * Makes SD work with the siteOrigin page builder.
425
-		 *
426
-		 * @since 1.0.6
427
-		 * @return mixed
428
-		 */
429
-		public static function siteorigin_js() {
430
-			ob_start();
431
-			?>
417
+            $html = ob_get_clean();
418
+
419
+            // remove line breaks so we can use it in js
420
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
421
+        }
422
+
423
+        /**
424
+         * Makes SD work with the siteOrigin page builder.
425
+         *
426
+         * @since 1.0.6
427
+         * @return mixed
428
+         */
429
+        public static function siteorigin_js() {
430
+            ob_start();
431
+            ?>
432 432
 			<script>
433 433
 				/**
434 434
 				 * Check a form to see what items shoudl be shown or hidden.
@@ -506,28 +506,28 @@  discard block
 block discarded – undo
506 506
 				});
507 507
 			</script>
508 508
 			<?php
509
-			$output = ob_get_clean();
509
+            $output = ob_get_clean();
510 510
 
511
-			/*
511
+            /*
512 512
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
513 513
 			 */
514 514
 
515
-			return str_replace( array(
516
-				'<script>',
517
-				'</script>'
518
-			), '', $output );
519
-		}
520
-
521
-		/**
522
-		 * Output the JS and CSS for the shortcode insert button.
523
-		 *
524
-		 * @since 1.0.6
525
-		 *
526
-		 * @param string $editor_id
527
-		 * @param string $insert_shortcode_function
528
-		 */
529
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
530
-			?>
515
+            return str_replace( array(
516
+                '<script>',
517
+                '</script>'
518
+            ), '', $output );
519
+        }
520
+
521
+        /**
522
+         * Output the JS and CSS for the shortcode insert button.
523
+         *
524
+         * @since 1.0.6
525
+         *
526
+         * @param string $editor_id
527
+         * @param string $insert_shortcode_function
528
+         */
529
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
530
+            ?>
531 531
 			<style>
532 532
 				.sd-shortcode-left-wrap {
533 533
 					float: left;
@@ -653,35 +653,35 @@  discard block
 block discarded – undo
653 653
 				<?php } ?>
654 654
 			</style>
655 655
 			<?php
656
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
657
-				echo "<script>" . self::siteorigin_js() . "</script>";
658
-			}
659
-			?>
656
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
657
+                echo "<script>" . self::siteorigin_js() . "</script>";
658
+            }
659
+            ?>
660 660
 			<script>
661 661
 				<?php
662
-				if(! empty( $insert_shortcode_function )){
663
-					echo $insert_shortcode_function;
664
-				}else{
665
-
666
-				/**
667
-				 * Function for super duper insert shortcode.
668
-				 *
669
-				 * @since 1.0.0
670
-				 */
671
-				?>
662
+                if(! empty( $insert_shortcode_function )){
663
+                    echo $insert_shortcode_function;
664
+                }else{
665
+
666
+                /**
667
+                 * Function for super duper insert shortcode.
668
+                 *
669
+                 * @since 1.0.0
670
+                 */
671
+                ?>
672 672
 				function sd_insert_shortcode($editor_id) {
673 673
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
674 674
 					if ($shortcode) {
675 675
 						if (!$editor_id) {
676 676
 							<?php
677
-							if ( isset( $_REQUEST['et_fb'] ) ) {
678
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
679
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
680
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
681
-							} else {
682
-								echo '$editor_id = "#wp-content-editor-container textarea";';
683
-							}
684
-							?>
677
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
678
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
679
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
680
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
681
+                            } else {
682
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
683
+                            }
684
+                            ?>
685 685
 						} else {
686 686
 							$editor_id = '#' + $editor_id;
687 687
 						}
@@ -1007,18 +1007,18 @@  discard block
 block discarded – undo
1007 1007
 
1008 1008
 			</script>
1009 1009
 			<?php
1010
-		}
1011
-
1012
-		/**
1013
-		 * Gets some CSS for the widgets screen.
1014
-		 *
1015
-		 * @param bool $advanced If we should include advanced CSS.
1016
-		 *
1017
-		 * @return mixed
1018
-		 */
1019
-		public function widget_css( $advanced = true ) {
1020
-			ob_start();
1021
-			?>
1010
+        }
1011
+
1012
+        /**
1013
+         * Gets some CSS for the widgets screen.
1014
+         *
1015
+         * @param bool $advanced If we should include advanced CSS.
1016
+         *
1017
+         * @return mixed
1018
+         */
1019
+        public function widget_css( $advanced = true ) {
1020
+            ob_start();
1021
+            ?>
1022 1022
 			<style>
1023 1023
 				<?php if( $advanced ){ ?>
1024 1024
 				.sd-advanced-setting {
@@ -1056,26 +1056,26 @@  discard block
 block discarded – undo
1056 1056
 				}
1057 1057
 			</style>
1058 1058
 			<?php
1059
-			$output = ob_get_clean();
1059
+            $output = ob_get_clean();
1060 1060
 
1061
-			/*
1061
+            /*
1062 1062
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1063 1063
 			 */
1064 1064
 
1065
-			return str_replace( array(
1066
-				'<style>',
1067
-				'</style>'
1068
-			), '', $output );
1069
-		}
1070
-
1071
-		/**
1072
-		 * Gets some JS for the widgets screen.
1073
-		 *
1074
-		 * @return mixed
1075
-		 */
1076
-		public function widget_js() {
1077
-			ob_start();
1078
-			?>
1065
+            return str_replace( array(
1066
+                '<style>',
1067
+                '</style>'
1068
+            ), '', $output );
1069
+        }
1070
+
1071
+        /**
1072
+         * Gets some JS for the widgets screen.
1073
+         *
1074
+         * @return mixed
1075
+         */
1076
+        public function widget_js() {
1077
+            ob_start();
1078
+            ?>
1079 1079
 			<script>
1080 1080
 
1081 1081
 				/**
@@ -1230,400 +1230,400 @@  discard block
 block discarded – undo
1230 1230
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1231 1231
 			</script>
1232 1232
 			<?php
1233
-			$output = ob_get_clean();
1233
+            $output = ob_get_clean();
1234 1234
 
1235
-			/*
1235
+            /*
1236 1236
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1237 1237
 			 */
1238 1238
 
1239
-			return str_replace( array(
1240
-				'<script>',
1241
-				'</script>'
1242
-			), '', $output );
1243
-		}
1244
-
1245
-
1246
-		/**
1247
-		 * Set the name from the argument key.
1248
-		 *
1249
-		 * @param $options
1250
-		 *
1251
-		 * @return mixed
1252
-		 */
1253
-		private function add_name_from_key( $options, $arguments = false ) {
1254
-			if ( ! empty( $options['arguments'] ) ) {
1255
-				foreach ( $options['arguments'] as $key => $val ) {
1256
-					$options['arguments'][ $key ]['name'] = $key;
1257
-				}
1258
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1259
-				foreach ( $options as $key => $val ) {
1260
-					$options[ $key ]['name'] = $key;
1261
-				}
1262
-			}
1263
-
1264
-			return $options;
1265
-		}
1266
-
1267
-		/**
1268
-		 * Register the parent shortcode.
1269
-		 *
1270
-		 * @since 1.0.0
1271
-		 */
1272
-		public function register_shortcode() {
1273
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1274
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1275
-		}
1276
-
1277
-		/**
1278
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1279
-		 *
1280
-		 * @since 1.0.0
1281
-		 */
1282
-		public static function render_shortcode() {
1283
-
1284
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1285
-			if ( ! current_user_can( 'manage_options' ) ) {
1286
-				wp_die();
1287
-			}
1288
-
1289
-			// we might need the $post value here so lets set it.
1290
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1291
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1292
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1293
-					global $post;
1294
-					$post = $post_obj;
1295
-				}
1296
-			}
1297
-
1298
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1299
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1300
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1301
-				$attributes       = '';
1302
-				if ( ! empty( $attributes_array ) ) {
1303
-					foreach ( $attributes_array as $key => $value ) {
1304
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1305
-					}
1306
-				}
1307
-
1308
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1309
-
1310
-				echo do_shortcode( $shortcode );
1311
-
1312
-			}
1313
-			wp_die();
1314
-		}
1315
-
1316
-		/**
1317
-		 * Output the shortcode.
1318
-		 *
1319
-		 * @param array $args
1320
-		 * @param string $content
1321
-		 *
1322
-		 * @return string
1323
-		 */
1324
-		public function shortcode_output( $args = array(), $content = '' ) {
1325
-			$args = $this->argument_values( $args );
1326
-
1327
-			// add extra argument so we know its a output to gutenberg
1328
-			//$args
1329
-			$args = $this->string_to_bool( $args );
1330
-
1331
-			// if we have a enclosed shortcode we add it to the special `html` argument
1332
-			if ( ! empty( $content ) ) {
1333
-				$args['html'] = $content;
1334
-			}
1335
-
1336
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1337
-			$class .= " sdel-".$this->get_instance_hash();
1338
-
1339
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1340
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1341
-
1342
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1343
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran?
1344
-
1345
-			$shortcode_args = array();
1346
-			$output         = '';
1347
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1348
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1349
-				$no_wrap = true;
1350
-			}
1351
-			$main_content = $this->output( $args, $shortcode_args, $content );
1352
-			if ( $main_content && ! $no_wrap ) {
1353
-				// wrap the shortcode in a div with the same class as the widget
1354
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1355
-				if ( ! empty( $args['title'] ) ) {
1356
-					// if its a shortcode and there is a title try to grab the title wrappers
1357
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1358
-					if ( empty( $instance ) ) {
1359
-						global $wp_registered_sidebars;
1360
-						if ( ! empty( $wp_registered_sidebars ) ) {
1361
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1362
-								if ( ! empty( $sidebar['before_title'] ) ) {
1363
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1364
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1365
-									break;
1366
-								}
1367
-							}
1368
-						}
1369
-					}
1370
-					$output .= $this->output_title( $shortcode_args, $args );
1371
-				}
1372
-				$output .= $main_content;
1373
-				$output .= '</div>';
1374
-			} elseif ( $main_content && $no_wrap ) {
1375
-				$output .= $main_content;
1376
-			}
1377
-
1378
-			// if preview show a placeholder if empty
1379
-			if ( $this->is_preview() && $output == '' ) {
1380
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1381
-			}
1382
-
1383
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1384
-		}
1385
-
1386
-		/**
1387
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1388
-		 *
1389
-		 * @param string $name
1390
-		 *
1391
-		 * @return string
1392
-		 */
1393
-		public function preview_placeholder_text( $name = '' ) {
1394
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1395
-		}
1396
-
1397
-		/**
1398
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1399
-		 *
1400
-		 * @param $options
1401
-		 *
1402
-		 * @return mixed
1403
-		 */
1404
-		public function string_to_bool( $options ) {
1405
-			// convert bool strings to booleans
1406
-			foreach ( $options as $key => $val ) {
1407
-				if ( $val == 'false' ) {
1408
-					$options[ $key ] = false;
1409
-				} elseif ( $val == 'true' ) {
1410
-					$options[ $key ] = true;
1411
-				}
1412
-			}
1413
-
1414
-			return $options;
1415
-		}
1416
-
1417
-		/**
1418
-		 * Get the argument values that are also filterable.
1419
-		 *
1420
-		 * @param $instance
1421
-		 *
1422
-		 * @since 1.0.12 Don't set checkbox default value if the value is empty.
1423
-		 *
1424
-		 * @return array
1425
-		 */
1426
-		public function argument_values( $instance ) {
1427
-			$argument_values = array();
1428
-
1429
-			// set widget instance
1430
-			$this->instance = $instance;
1431
-
1432
-			if ( empty( $this->arguments ) ) {
1433
-				$this->arguments = $this->get_arguments();
1434
-			}
1435
-
1436
-			if ( ! empty( $this->arguments ) ) {
1437
-				foreach ( $this->arguments as $key => $args ) {
1438
-					// set the input name from the key
1439
-					$args['name'] = $key;
1440
-					//
1441
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1442
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1443
-						// don't set default for an empty checkbox
1444
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1445
-						$argument_values[ $key ] = $args['default'];
1446
-					}
1447
-				}
1448
-			}
1449
-
1450
-			return $argument_values;
1451
-		}
1452
-
1453
-		/**
1454
-		 * Set arguments in super duper.
1455
-		 *
1456
-		 * @since 1.0.0
1457
-		 *
1458
-		 * @return array Set arguments.
1459
-		 */
1460
-		public function set_arguments() {
1461
-			return $this->arguments;
1462
-		}
1463
-
1464
-		/**
1465
-		 * Get arguments in super duper.
1466
-		 *
1467
-		 * @since 1.0.0
1468
-		 *
1469
-		 * @return array Get arguments.
1470
-		 */
1471
-		public function get_arguments() {
1472
-			if ( empty( $this->arguments ) ) {
1473
-				$this->arguments = $this->set_arguments();
1474
-			}
1475
-
1476
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1477
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1478
-
1479
-			return $this->arguments;
1480
-		}
1481
-
1482
-		/**
1483
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1484
-		 *
1485
-		 * @param array $args
1486
-		 * @param array $widget_args
1487
-		 * @param string $content
1488
-		 */
1489
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1490
-
1491
-		}
1492
-
1493
-		/**
1494
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1495
-		 */
1496
-		public function register_block() {
1497
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1498
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1499
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1500
-			}
1501
-		}
1502
-
1503
-		/**
1504
-		 * Check if we need to show advanced options.
1505
-		 *
1506
-		 * @return bool
1507
-		 */
1508
-		public function block_show_advanced() {
1509
-
1510
-			$show      = false;
1511
-			$arguments = $this->arguments;
1512
-
1513
-			if ( empty( $arguments ) ) {
1514
-				$arguments = $this->get_arguments();
1515
-			}
1516
-
1517
-			if ( ! empty( $arguments ) ) {
1518
-				foreach ( $arguments as $argument ) {
1519
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1520
-						$show = true;
1521
-						break; // no need to continue if we know we have it
1522
-					}
1523
-				}
1524
-			}
1525
-
1526
-			return $show;
1527
-		}
1528
-
1529
-		/**
1530
-		 * Get the url path to the current folder.
1531
-		 *
1532
-		 * @return string
1533
-		 */
1534
-		public function get_url() {
1535
-
1536
-			$url = $this->url;
1537
-
1538
-			if ( ! $url ) {
1539
-				// check if we are inside a plugin
1540
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1541
-
1542
-				$dir_parts = explode( "/wp-content/", $file_dir );
1543
-				$url_parts = explode( "/wp-content/", plugins_url() );
1544
-
1545
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1546
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1547
-					$this->url = $url;
1548
-				}
1549
-			}
1550
-
1551
-
1552
-			return $url;
1553
-		}
1554
-
1555
-		/**
1556
-		 * Generate the block icon.
1557
-		 *
1558
-		 * Enables the use of Font Awesome icons.
1559
-		 *
1560
-		 * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1561
-		 *
1562
-		 * @param $icon
1563
-		 *
1564
-		 * @since 1.1.0
1565
-		 * @return string
1566
-		 */
1567
-		public function get_block_icon( $icon ) {
1568
-
1569
-			// check if we have a Font Awesome icon
1570
-			$fa_type = '';
1571
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1572
-				$fa_type = 'solid';
1573
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1574
-				$fa_type = 'regular';
1575
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1576
-				$fa_type = 'brands';
1577
-			} else {
1578
-				$icon = "'" . $icon . "'";
1579
-			}
1580
-
1581
-			// set the icon if we found one
1582
-			if ( $fa_type ) {
1583
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1584
-				$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 . "'}))";
1585
-			}
1586
-
1587
-			return $icon;
1588
-		}
1589
-
1590
-		public function group_arguments( $arguments ) {
1239
+            return str_replace( array(
1240
+                '<script>',
1241
+                '</script>'
1242
+            ), '', $output );
1243
+        }
1244
+
1245
+
1246
+        /**
1247
+         * Set the name from the argument key.
1248
+         *
1249
+         * @param $options
1250
+         *
1251
+         * @return mixed
1252
+         */
1253
+        private function add_name_from_key( $options, $arguments = false ) {
1254
+            if ( ! empty( $options['arguments'] ) ) {
1255
+                foreach ( $options['arguments'] as $key => $val ) {
1256
+                    $options['arguments'][ $key ]['name'] = $key;
1257
+                }
1258
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1259
+                foreach ( $options as $key => $val ) {
1260
+                    $options[ $key ]['name'] = $key;
1261
+                }
1262
+            }
1263
+
1264
+            return $options;
1265
+        }
1266
+
1267
+        /**
1268
+         * Register the parent shortcode.
1269
+         *
1270
+         * @since 1.0.0
1271
+         */
1272
+        public function register_shortcode() {
1273
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1274
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1275
+        }
1276
+
1277
+        /**
1278
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1279
+         *
1280
+         * @since 1.0.0
1281
+         */
1282
+        public static function render_shortcode() {
1283
+
1284
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1285
+            if ( ! current_user_can( 'manage_options' ) ) {
1286
+                wp_die();
1287
+            }
1288
+
1289
+            // we might need the $post value here so lets set it.
1290
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1291
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1292
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1293
+                    global $post;
1294
+                    $post = $post_obj;
1295
+                }
1296
+            }
1297
+
1298
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1299
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1300
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1301
+                $attributes       = '';
1302
+                if ( ! empty( $attributes_array ) ) {
1303
+                    foreach ( $attributes_array as $key => $value ) {
1304
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1305
+                    }
1306
+                }
1307
+
1308
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1309
+
1310
+                echo do_shortcode( $shortcode );
1311
+
1312
+            }
1313
+            wp_die();
1314
+        }
1315
+
1316
+        /**
1317
+         * Output the shortcode.
1318
+         *
1319
+         * @param array $args
1320
+         * @param string $content
1321
+         *
1322
+         * @return string
1323
+         */
1324
+        public function shortcode_output( $args = array(), $content = '' ) {
1325
+            $args = $this->argument_values( $args );
1326
+
1327
+            // add extra argument so we know its a output to gutenberg
1328
+            //$args
1329
+            $args = $this->string_to_bool( $args );
1330
+
1331
+            // if we have a enclosed shortcode we add it to the special `html` argument
1332
+            if ( ! empty( $content ) ) {
1333
+                $args['html'] = $content;
1334
+            }
1335
+
1336
+            $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1337
+            $class .= " sdel-".$this->get_instance_hash();
1338
+
1339
+            $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1340
+            $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1341
+
1342
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1343
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran?
1344
+
1345
+            $shortcode_args = array();
1346
+            $output         = '';
1347
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1348
+            if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1349
+                $no_wrap = true;
1350
+            }
1351
+            $main_content = $this->output( $args, $shortcode_args, $content );
1352
+            if ( $main_content && ! $no_wrap ) {
1353
+                // wrap the shortcode in a div with the same class as the widget
1354
+                $output .= '<div class="' . $class . '" ' . $attrs . '>';
1355
+                if ( ! empty( $args['title'] ) ) {
1356
+                    // if its a shortcode and there is a title try to grab the title wrappers
1357
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1358
+                    if ( empty( $instance ) ) {
1359
+                        global $wp_registered_sidebars;
1360
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1361
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1362
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1363
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1364
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1365
+                                    break;
1366
+                                }
1367
+                            }
1368
+                        }
1369
+                    }
1370
+                    $output .= $this->output_title( $shortcode_args, $args );
1371
+                }
1372
+                $output .= $main_content;
1373
+                $output .= '</div>';
1374
+            } elseif ( $main_content && $no_wrap ) {
1375
+                $output .= $main_content;
1376
+            }
1377
+
1378
+            // if preview show a placeholder if empty
1379
+            if ( $this->is_preview() && $output == '' ) {
1380
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1381
+            }
1382
+
1383
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1384
+        }
1385
+
1386
+        /**
1387
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1388
+         *
1389
+         * @param string $name
1390
+         *
1391
+         * @return string
1392
+         */
1393
+        public function preview_placeholder_text( $name = '' ) {
1394
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1395
+        }
1396
+
1397
+        /**
1398
+         * Sometimes booleans values can be turned to strings, so we fix that.
1399
+         *
1400
+         * @param $options
1401
+         *
1402
+         * @return mixed
1403
+         */
1404
+        public function string_to_bool( $options ) {
1405
+            // convert bool strings to booleans
1406
+            foreach ( $options as $key => $val ) {
1407
+                if ( $val == 'false' ) {
1408
+                    $options[ $key ] = false;
1409
+                } elseif ( $val == 'true' ) {
1410
+                    $options[ $key ] = true;
1411
+                }
1412
+            }
1413
+
1414
+            return $options;
1415
+        }
1416
+
1417
+        /**
1418
+         * Get the argument values that are also filterable.
1419
+         *
1420
+         * @param $instance
1421
+         *
1422
+         * @since 1.0.12 Don't set checkbox default value if the value is empty.
1423
+         *
1424
+         * @return array
1425
+         */
1426
+        public function argument_values( $instance ) {
1427
+            $argument_values = array();
1428
+
1429
+            // set widget instance
1430
+            $this->instance = $instance;
1431
+
1432
+            if ( empty( $this->arguments ) ) {
1433
+                $this->arguments = $this->get_arguments();
1434
+            }
1435
+
1436
+            if ( ! empty( $this->arguments ) ) {
1437
+                foreach ( $this->arguments as $key => $args ) {
1438
+                    // set the input name from the key
1439
+                    $args['name'] = $key;
1440
+                    //
1441
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1442
+                    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1443
+                        // don't set default for an empty checkbox
1444
+                    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1445
+                        $argument_values[ $key ] = $args['default'];
1446
+                    }
1447
+                }
1448
+            }
1449
+
1450
+            return $argument_values;
1451
+        }
1452
+
1453
+        /**
1454
+         * Set arguments in super duper.
1455
+         *
1456
+         * @since 1.0.0
1457
+         *
1458
+         * @return array Set arguments.
1459
+         */
1460
+        public function set_arguments() {
1461
+            return $this->arguments;
1462
+        }
1463
+
1464
+        /**
1465
+         * Get arguments in super duper.
1466
+         *
1467
+         * @since 1.0.0
1468
+         *
1469
+         * @return array Get arguments.
1470
+         */
1471
+        public function get_arguments() {
1472
+            if ( empty( $this->arguments ) ) {
1473
+                $this->arguments = $this->set_arguments();
1474
+            }
1475
+
1476
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1477
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1478
+
1479
+            return $this->arguments;
1480
+        }
1481
+
1482
+        /**
1483
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1484
+         *
1485
+         * @param array $args
1486
+         * @param array $widget_args
1487
+         * @param string $content
1488
+         */
1489
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1490
+
1491
+        }
1492
+
1493
+        /**
1494
+         * Add the dynamic block code inline when the wp-block in enqueued.
1495
+         */
1496
+        public function register_block() {
1497
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1498
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1499
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1500
+            }
1501
+        }
1502
+
1503
+        /**
1504
+         * Check if we need to show advanced options.
1505
+         *
1506
+         * @return bool
1507
+         */
1508
+        public function block_show_advanced() {
1509
+
1510
+            $show      = false;
1511
+            $arguments = $this->arguments;
1512
+
1513
+            if ( empty( $arguments ) ) {
1514
+                $arguments = $this->get_arguments();
1515
+            }
1516
+
1517
+            if ( ! empty( $arguments ) ) {
1518
+                foreach ( $arguments as $argument ) {
1519
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1520
+                        $show = true;
1521
+                        break; // no need to continue if we know we have it
1522
+                    }
1523
+                }
1524
+            }
1525
+
1526
+            return $show;
1527
+        }
1528
+
1529
+        /**
1530
+         * Get the url path to the current folder.
1531
+         *
1532
+         * @return string
1533
+         */
1534
+        public function get_url() {
1535
+
1536
+            $url = $this->url;
1537
+
1538
+            if ( ! $url ) {
1539
+                // check if we are inside a plugin
1540
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1541
+
1542
+                $dir_parts = explode( "/wp-content/", $file_dir );
1543
+                $url_parts = explode( "/wp-content/", plugins_url() );
1544
+
1545
+                if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1546
+                    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1547
+                    $this->url = $url;
1548
+                }
1549
+            }
1550
+
1551
+
1552
+            return $url;
1553
+        }
1554
+
1555
+        /**
1556
+         * Generate the block icon.
1557
+         *
1558
+         * Enables the use of Font Awesome icons.
1559
+         *
1560
+         * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1561
+         *
1562
+         * @param $icon
1563
+         *
1564
+         * @since 1.1.0
1565
+         * @return string
1566
+         */
1567
+        public function get_block_icon( $icon ) {
1568
+
1569
+            // check if we have a Font Awesome icon
1570
+            $fa_type = '';
1571
+            if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1572
+                $fa_type = 'solid';
1573
+            } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1574
+                $fa_type = 'regular';
1575
+            } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1576
+                $fa_type = 'brands';
1577
+            } else {
1578
+                $icon = "'" . $icon . "'";
1579
+            }
1580
+
1581
+            // set the icon if we found one
1582
+            if ( $fa_type ) {
1583
+                $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1584
+                $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 . "'}))";
1585
+            }
1586
+
1587
+            return $icon;
1588
+        }
1589
+
1590
+        public function group_arguments( $arguments ) {
1591 1591
 //			echo '###';print_r($arguments);
1592
-			if ( ! empty( $arguments ) ) {
1593
-				$temp_arguments = array();
1594
-				$general        = __( "General" );
1595
-				$add_sections   = false;
1596
-				foreach ( $arguments as $key => $args ) {
1597
-					if ( isset( $args['group'] ) ) {
1598
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1599
-						$add_sections                             = true;
1600
-					} else {
1601
-						$temp_arguments[ $general ][ $key ] = $args;
1602
-					}
1603
-				}
1604
-
1605
-				// only add sections if more than one
1606
-				if ( $add_sections ) {
1607
-					$arguments = $temp_arguments;
1608
-				}
1609
-			}
1592
+            if ( ! empty( $arguments ) ) {
1593
+                $temp_arguments = array();
1594
+                $general        = __( "General" );
1595
+                $add_sections   = false;
1596
+                foreach ( $arguments as $key => $args ) {
1597
+                    if ( isset( $args['group'] ) ) {
1598
+                        $temp_arguments[ $args['group'] ][ $key ] = $args;
1599
+                        $add_sections                             = true;
1600
+                    } else {
1601
+                        $temp_arguments[ $general ][ $key ] = $args;
1602
+                    }
1603
+                }
1604
+
1605
+                // only add sections if more than one
1606
+                if ( $add_sections ) {
1607
+                    $arguments = $temp_arguments;
1608
+                }
1609
+            }
1610 1610
 
1611 1611
 //			echo '###';print_r($arguments);
1612
-			return $arguments;
1613
-		}
1614
-
1615
-
1616
-		/**
1617
-		 * Output the JS for building the dynamic Guntenberg block.
1618
-		 *
1619
-		 * @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.
1620
-		 * @since 1.0.9 Save numbers as numbers and not strings.
1621
-		 * @since 1.1.0 Font Awesome classes can be used for icons.
1622
-		 * @return mixed
1623
-		 */
1624
-		public function block() {
1625
-			ob_start();
1626
-			?>
1612
+            return $arguments;
1613
+        }
1614
+
1615
+
1616
+        /**
1617
+         * Output the JS for building the dynamic Guntenberg block.
1618
+         *
1619
+         * @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.
1620
+         * @since 1.0.9 Save numbers as numbers and not strings.
1621
+         * @since 1.1.0 Font Awesome classes can be used for icons.
1622
+         * @return mixed
1623
+         */
1624
+        public function block() {
1625
+            ob_start();
1626
+            ?>
1627 1627
 			<script>
1628 1628
 				/**
1629 1629
 				 * BLOCK: Basic
@@ -1666,97 +1666,97 @@  discard block
 block discarded – undo
1666 1666
 						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/.
1667 1667
 						supports: {
1668 1668
 							<?php
1669
-							if ( isset( $this->options['block-supports'] ) ) {
1670
-								echo $this->array_to_attributes( $this->options['block-supports'] );
1671
-							}
1672
-							?>
1669
+                            if ( isset( $this->options['block-supports'] ) ) {
1670
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
1671
+                            }
1672
+                            ?>
1673 1673
 						},
1674 1674
 						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.
1675 1675
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
1676
-						echo "keywords : " . $this->options['block-keywords'] . ",";
1677
-					}?>
1676
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
1677
+                    }?>
1678 1678
 
1679 1679
 						<?php
1680 1680
 
1681
-						// maybe set no_wrap
1682
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1683
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
1684
-							$no_wrap = true;
1685
-						}
1686
-						if ( $no_wrap ) {
1687
-							$this->options['block-wrap'] = '';
1688
-						}
1681
+                        // maybe set no_wrap
1682
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1683
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
1684
+                            $no_wrap = true;
1685
+                        }
1686
+                        if ( $no_wrap ) {
1687
+                            $this->options['block-wrap'] = '';
1688
+                        }
1689 1689
 
1690
-						$show_advanced = $this->block_show_advanced();
1690
+                        $show_advanced = $this->block_show_advanced();
1691 1691
 
1692
-						$show_alignment = false;
1693
-						// align feature
1694
-						/*echo "supports: {";
1692
+                        $show_alignment = false;
1693
+                        // align feature
1694
+                        /*echo "supports: {";
1695 1695
 						echo "	align: true,";
1696 1696
 						echo "  html: false";
1697 1697
 						echo "},";*/
1698 1698
 
1699
-						if ( ! empty( $this->arguments ) ) {
1700
-							echo "attributes : {";
1701
-
1702
-							if ( $show_advanced ) {
1703
-								echo "show_advanced: {";
1704
-								echo "	type: 'boolean',";
1705
-								echo "  default: false,";
1706
-								echo "},";
1707
-							}
1708
-
1709
-							// block wrap element
1710
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1711
-								echo "block_wrap: {";
1712
-								echo "	type: 'string',";
1713
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1714
-								echo "},";
1715
-							}
1716
-
1717
-							foreach ( $this->arguments as $key => $args ) {
1718
-
1719
-								// set if we should show alignment
1720
-								if ( $key == 'alignment' ) {
1721
-									$show_alignment = true;
1722
-								}
1723
-
1724
-								$extra = '';
1725
-
1726
-								if ( $args['type'] == 'checkbox' ) {
1727
-									$type    = 'boolean';
1728
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1729
-								} elseif ( $args['type'] == 'number' ) {
1730
-									$type    = 'number';
1731
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1732
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1733
-									$type = 'array';
1734
-									if ( is_array( $args['default'] ) ) {
1735
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1736
-									} else {
1737
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1738
-									}
1739
-								} elseif ( $args['type'] == 'multiselect' ) {
1740
-									$type    = 'array';
1741
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1742
-								} else {
1743
-									$type    = 'string';
1744
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1745
-								}
1746
-								echo $key . " : {";
1747
-								echo "type : '$type',";
1748
-								echo "default : $default,";
1749
-								echo "},";
1750
-							}
1751
-
1752
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1753
-							echo "className: { type: 'string', default: '' },";
1754
-
1755
-							echo "},";
1756
-
1757
-						}
1758
-
1759
-						?>
1699
+                        if ( ! empty( $this->arguments ) ) {
1700
+                            echo "attributes : {";
1701
+
1702
+                            if ( $show_advanced ) {
1703
+                                echo "show_advanced: {";
1704
+                                echo "	type: 'boolean',";
1705
+                                echo "  default: false,";
1706
+                                echo "},";
1707
+                            }
1708
+
1709
+                            // block wrap element
1710
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1711
+                                echo "block_wrap: {";
1712
+                                echo "	type: 'string',";
1713
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1714
+                                echo "},";
1715
+                            }
1716
+
1717
+                            foreach ( $this->arguments as $key => $args ) {
1718
+
1719
+                                // set if we should show alignment
1720
+                                if ( $key == 'alignment' ) {
1721
+                                    $show_alignment = true;
1722
+                                }
1723
+
1724
+                                $extra = '';
1725
+
1726
+                                if ( $args['type'] == 'checkbox' ) {
1727
+                                    $type    = 'boolean';
1728
+                                    $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1729
+                                } elseif ( $args['type'] == 'number' ) {
1730
+                                    $type    = 'number';
1731
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1732
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1733
+                                    $type = 'array';
1734
+                                    if ( is_array( $args['default'] ) ) {
1735
+                                        $default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1736
+                                    } else {
1737
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1738
+                                    }
1739
+                                } elseif ( $args['type'] == 'multiselect' ) {
1740
+                                    $type    = 'array';
1741
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1742
+                                } else {
1743
+                                    $type    = 'string';
1744
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1745
+                                }
1746
+                                echo $key . " : {";
1747
+                                echo "type : '$type',";
1748
+                                echo "default : $default,";
1749
+                                echo "},";
1750
+                            }
1751
+
1752
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
1753
+                            echo "className: { type: 'string', default: '' },";
1754
+
1755
+                            echo "},";
1756
+
1757
+                        }
1758
+
1759
+                        ?>
1760 1760
 
1761 1761
 						// The "edit" property must be a valid function.
1762 1762
 						edit: function (props) {
@@ -1764,9 +1764,9 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
 
1766 1766
 							<?php
1767
-							// if we have a post_type and a category then link them
1768
-							if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked']) ){
1769
-							?>
1767
+                            // if we have a post_type and a category then link them
1768
+                            if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked']) ){
1769
+                            ?>
1770 1770
 							if(typeof(prev_attributes[props.id]) != 'undefined' ){
1771 1771
 								$pt = props.attributes.post_type;
1772 1772
 								if(post_type_rest_slugs.length){
@@ -1817,8 +1817,8 @@  discard block
 block discarded – undo
1817 1817
 										'shortcode': '<?php echo $this->options['base_id'];?>',
1818 1818
 										'attributes': props.attributes,
1819 1819
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1820
-										echo $post->ID;
1821
-									}?>,
1820
+                                        echo $post->ID;
1821
+                                    }?>,
1822 1822
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1823 1823
 									};
1824 1824
 
@@ -1870,10 +1870,10 @@  discard block
 block discarded – undo
1870 1870
 
1871 1871
 									<?php
1872 1872
 
1873
-									if(! empty( $this->arguments )){
1873
+                                    if(! empty( $this->arguments )){
1874 1874
 
1875
-									if ( $show_advanced ) {
1876
-									?>
1875
+                                    if ( $show_advanced ) {
1876
+                                    ?>
1877 1877
 									el('div', {
1878 1878
 											style: {'padding-left': '16px','padding-right': '16px'}
1879 1879
 										},
@@ -1891,72 +1891,72 @@  discard block
 block discarded – undo
1891 1891
 									,
1892 1892
 									<?php
1893 1893
 
1894
-									}
1894
+                                    }
1895 1895
 
1896
-									$arguments = $this->group_arguments( $this->arguments );
1896
+                                    $arguments = $this->group_arguments( $this->arguments );
1897 1897
 
1898
-									// Do we have sections?
1899
-									$has_sections = $arguments == $this->arguments ? false : true;
1898
+                                    // Do we have sections?
1899
+                                    $has_sections = $arguments == $this->arguments ? false : true;
1900 1900
 
1901 1901
 
1902
-									if($has_sections){
1903
-									$panel_count = 0;
1904
-									foreach($arguments as $key => $args){
1905
-									?>
1902
+                                    if($has_sections){
1903
+                                    $panel_count = 0;
1904
+                                    foreach($arguments as $key => $args){
1905
+                                    ?>
1906 1906
 									el(wp.components.PanelBody, {
1907 1907
 											title: '<?php esc_attr_e( $key ); ?>',
1908 1908
 											initialOpen: <?php if ( $panel_count ) {
1909
-											echo "false";
1910
-										} else {
1911
-											echo "true";
1912
-										}?>
1909
+                                            echo "false";
1910
+                                        } else {
1911
+                                            echo "true";
1912
+                                        }?>
1913 1913
 										},
1914 1914
 										<?php
1915 1915
 
1916
-										foreach ( $args as $k => $a ) {
1917
-											$this->build_block_arguments( $k, $a );
1918
-										}
1919
-										?>
1916
+                                        foreach ( $args as $k => $a ) {
1917
+                                            $this->build_block_arguments( $k, $a );
1918
+                                        }
1919
+                                        ?>
1920 1920
 									),
1921 1921
 									<?php
1922
-									$panel_count ++;
1922
+                                    $panel_count ++;
1923 1923
 
1924
-									}
1925
-									}else {
1926
-									?>
1924
+                                    }
1925
+                                    }else {
1926
+                                    ?>
1927 1927
 									el(wp.components.PanelBody, {
1928 1928
 											title: '<?php esc_attr_e( "Settings" ); ?>',
1929 1929
 											initialOpen: true
1930 1930
 										},
1931 1931
 										<?php
1932
-										foreach ( $this->arguments as $key => $args ) {
1933
-											$this->build_block_arguments( $key, $args );
1934
-										}
1935
-										?>
1932
+                                        foreach ( $this->arguments as $key => $args ) {
1933
+                                            $this->build_block_arguments( $key, $args );
1934
+                                        }
1935
+                                        ?>
1936 1936
 									),
1937 1937
 									<?php
1938
-									}
1938
+                                    }
1939 1939
 
1940
-									}
1941
-									?>
1940
+                                    }
1941
+                                    ?>
1942 1942
 
1943 1943
 								),
1944 1944
 
1945 1945
 								<?php
1946
-								// If the user sets block-output array then build it
1947
-								if ( ! empty( $this->options['block-output'] ) ) {
1948
-								$this->block_element( $this->options['block-output'] );
1949
-							}else{
1950
-								// if no block-output is set then we try and get the shortcode html output via ajax.
1951
-								?>
1946
+                                // If the user sets block-output array then build it
1947
+                                if ( ! empty( $this->options['block-output'] ) ) {
1948
+                                $this->block_element( $this->options['block-output'] );
1949
+                            }else{
1950
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
1951
+                                ?>
1952 1952
 								el('div', {
1953 1953
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
1954 1954
 									className: props.className,
1955 1955
 									style: {'minHeight': '30px'}
1956 1956
 								})
1957 1957
 								<?php
1958
-								}
1959
-								?>
1958
+                                }
1959
+                                ?>
1960 1960
 							]; // end return
1961 1961
 						},
1962 1962
 
@@ -1974,10 +1974,10 @@  discard block
 block discarded – undo
1974 1974
 							$html = '';
1975 1975
 							<?php
1976 1976
 
1977
-							if(! empty( $this->arguments )){
1977
+                            if(! empty( $this->arguments )){
1978 1978
 
1979
-							foreach($this->arguments as $key => $args){
1980
-							?>
1979
+                            foreach($this->arguments as $key => $args){
1980
+                            ?>
1981 1981
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1982 1982
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
1983 1983
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -1986,10 +1986,10 @@  discard block
 block discarded – undo
1986 1986
 								}
1987 1987
 							}
1988 1988
 							<?php
1989
-							}
1990
-							}
1989
+                            }
1990
+                            }
1991 1991
 
1992
-							?>
1992
+                            ?>
1993 1993
 							content += "]";
1994 1994
 
1995 1995
 							// if has html element
@@ -2012,20 +2012,20 @@  discard block
 block discarded – undo
2012 2012
 							}
2013 2013
 
2014 2014
 							<?php
2015
-							if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2016
-							?>
2015
+                            if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2016
+                            ?>
2017 2017
 							return content;
2018 2018
 							<?php
2019
-							}else{
2020
-							?>
2019
+                            }else{
2020
+                            ?>
2021 2021
 							var block_wrap = 'div';
2022 2022
 							if (attr.hasOwnProperty("block_wrap")) {
2023 2023
 								block_wrap = attr.block_wrap;
2024 2024
 							}
2025 2025
 							return el(block_wrap, {dangerouslySetInnerHTML: {__html: content}, className: align});
2026 2026
 							<?php
2027
-							}
2028
-							?>
2027
+                            }
2028
+                            ?>
2029 2029
 
2030 2030
 
2031 2031
 						}
@@ -2033,47 +2033,47 @@  discard block
 block discarded – undo
2033 2033
 				})();
2034 2034
 			</script>
2035 2035
 			<?php
2036
-			$output = ob_get_clean();
2036
+            $output = ob_get_clean();
2037 2037
 
2038
-			/*
2038
+            /*
2039 2039
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2040 2040
 			 */
2041 2041
 
2042
-			return str_replace( array(
2043
-				'<script>',
2044
-				'</script>'
2045
-			), '', $output );
2046
-		}
2047
-
2048
-		public function build_block_arguments( $key, $args ) {
2049
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
2050
-			$options           = '';
2051
-			$extra             = '';
2052
-			$require           = '';
2053
-
2054
-			// `content` is a protected and special argument
2055
-			if ( $key == 'content' ) {
2056
-				return;
2057
-			}
2058
-
2059
-			// require advanced
2060
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
2061
-
2062
-			// element require
2063
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2064
-
2065
-
2066
-			$onchange  = "props.setAttributes({ $key: $key } )";
2067
-			$onchangecomplete  = "";
2068
-			$value     = "props.attributes.$key";
2069
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx' );
2070
-			if ( in_array( $args['type'], $text_type ) ) {
2071
-				$type = 'TextControl';
2072
-				// Save numbers as numbers and not strings
2073
-				if ( $args['type'] == 'number' ) {
2074
-					$onchange = "props.setAttributes({ $key: Number($key) } )";
2075
-				}
2076
-			}
2042
+            return str_replace( array(
2043
+                '<script>',
2044
+                '</script>'
2045
+            ), '', $output );
2046
+        }
2047
+
2048
+        public function build_block_arguments( $key, $args ) {
2049
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
2050
+            $options           = '';
2051
+            $extra             = '';
2052
+            $require           = '';
2053
+
2054
+            // `content` is a protected and special argument
2055
+            if ( $key == 'content' ) {
2056
+                return;
2057
+            }
2058
+
2059
+            // require advanced
2060
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
2061
+
2062
+            // element require
2063
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2064
+
2065
+
2066
+            $onchange  = "props.setAttributes({ $key: $key } )";
2067
+            $onchangecomplete  = "";
2068
+            $value     = "props.attributes.$key";
2069
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx' );
2070
+            if ( in_array( $args['type'], $text_type ) ) {
2071
+                $type = 'TextControl';
2072
+                // Save numbers as numbers and not strings
2073
+                if ( $args['type'] == 'number' ) {
2074
+                    $onchange = "props.setAttributes({ $key: Number($key) } )";
2075
+                }
2076
+            }
2077 2077
 /*
2078 2078
  * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
2079 2079
 			elseif($args['type']=='tabs'){
@@ -2108,78 +2108,78 @@  discard block
 block discarded – undo
2108 2108
 				return;
2109 2109
 			}
2110 2110
 */
2111
-			elseif ( $args['type'] == 'color' ) {
2112
-				$type = 'ColorPicker';
2113
-				$onchange = "";
2114
-				$extra = "color: $value,";
2115
-				if(!empty($args['disable_alpha'])){
2116
-					$extra .= "disableAlpha: true,";
2117
-				}
2118
-				$onchangecomplete = "onChangeComplete: function($key) {
2111
+            elseif ( $args['type'] == 'color' ) {
2112
+                $type = 'ColorPicker';
2113
+                $onchange = "";
2114
+                $extra = "color: $value,";
2115
+                if(!empty($args['disable_alpha'])){
2116
+                    $extra .= "disableAlpha: true,";
2117
+                }
2118
+                $onchangecomplete = "onChangeComplete: function($key) {
2119 2119
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
2120 2120
                         props.setAttributes({
2121 2121
                             $key: value
2122 2122
                         });
2123 2123
                     },";
2124
-			}
2125
-			elseif ( $args['type'] == 'checkbox' ) {
2126
-				$type = 'CheckboxControl';
2127
-				$extra .= "checked: props.attributes.$key,";
2128
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
2129
-			} elseif ( $args['type'] == 'textarea' ) {
2130
-				$type = 'TextareaControl';
2131
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
2132
-				$type = 'SelectControl';
2133
-
2134
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
2135
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
2136
-				}else {
2137
-
2138
-					if ( ! empty( $args['options'] ) ) {
2139
-						$options .= "options: [";
2140
-						foreach ( $args['options'] as $option_val => $option_label ) {
2141
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
2142
-						}
2143
-						$options .= "],";
2144
-					}
2145
-				}
2146
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
2147
-					$extra .= ' multiple: true, ';
2148
-				}
2149
-			} elseif ( $args['type'] == 'alignment' ) {
2150
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
2151
-			} else {
2152
-				return;// if we have not implemented the control then don't break the JS.
2153
-			}
2154
-
2155
-
2156
-
2157
-			// color input does not show the labels so we add them
2158
-			if($args['type']=='color'){
2159
-				// add show only if advanced
2160
-				echo $require_advanced;
2161
-				// add setting require if defined
2162
-				echo $element_require;
2163
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
2164
-			}
2165
-
2166
-			// add show only if advanced
2167
-			echo $require_advanced;
2168
-			// add setting require if defined
2169
-			echo $element_require;
2170
-			?>
2124
+            }
2125
+            elseif ( $args['type'] == 'checkbox' ) {
2126
+                $type = 'CheckboxControl';
2127
+                $extra .= "checked: props.attributes.$key,";
2128
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
2129
+            } elseif ( $args['type'] == 'textarea' ) {
2130
+                $type = 'TextareaControl';
2131
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
2132
+                $type = 'SelectControl';
2133
+
2134
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
2135
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
2136
+                }else {
2137
+
2138
+                    if ( ! empty( $args['options'] ) ) {
2139
+                        $options .= "options: [";
2140
+                        foreach ( $args['options'] as $option_val => $option_label ) {
2141
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
2142
+                        }
2143
+                        $options .= "],";
2144
+                    }
2145
+                }
2146
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
2147
+                    $extra .= ' multiple: true, ';
2148
+                }
2149
+            } elseif ( $args['type'] == 'alignment' ) {
2150
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
2151
+            } else {
2152
+                return;// if we have not implemented the control then don't break the JS.
2153
+            }
2154
+
2155
+
2156
+
2157
+            // color input does not show the labels so we add them
2158
+            if($args['type']=='color'){
2159
+                // add show only if advanced
2160
+                echo $require_advanced;
2161
+                // add setting require if defined
2162
+                echo $element_require;
2163
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
2164
+            }
2165
+
2166
+            // add show only if advanced
2167
+            echo $require_advanced;
2168
+            // add setting require if defined
2169
+            echo $element_require;
2170
+            ?>
2171 2171
 			el( wp.components.<?php echo $type; ?>, {
2172 2172
 			label: '<?php echo addslashes( $args['title'] ); ?>',
2173 2173
 			help: '<?php if ( isset( $args['desc'] ) ) {
2174
-				echo addslashes( $args['desc'] );
2175
-			} ?>',
2174
+                echo addslashes( $args['desc'] );
2175
+            } ?>',
2176 2176
 			value: <?php echo $value; ?>,
2177 2177
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
2178
-				echo "type: '" . addslashes( $args['type'] ) . "',";
2179
-			} ?>
2178
+                echo "type: '" . addslashes( $args['type'] ) . "',";
2179
+            } ?>
2180 2180
 			<?php if ( ! empty( $args['placeholder'] ) ) {
2181
-				echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
2182
-			} ?>
2181
+                echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
2182
+            } ?>
2183 2183
 			<?php echo $options; ?>
2184 2184
 			<?php echo $extra; ?>
2185 2185
 			<?php echo $custom_attributes; ?>
@@ -2190,534 +2190,534 @@  discard block
 block discarded – undo
2190 2190
 			} ),
2191 2191
 			<?php
2192 2192
 
2193
-		}
2194
-
2195
-		/**
2196
-		 * Convert an array of attributes to block string.
2197
-		 *
2198
-		 * @todo there is prob a faster way to do this, also we could add some validation here.
2199
-		 *
2200
-		 * @param $custom_attributes
2201
-		 *
2202
-		 * @return string
2203
-		 */
2204
-		public function array_to_attributes( $custom_attributes, $html = false ) {
2205
-			$attributes = '';
2206
-			if ( ! empty( $custom_attributes ) ) {
2207
-
2208
-				if ( $html ) {
2209
-					foreach ( $custom_attributes as $key => $val ) {
2210
-						$attributes .= " $key='$val' ";
2211
-					}
2212
-				} else {
2213
-					foreach ( $custom_attributes as $key => $val ) {
2214
-						$attributes .= "'$key': '$val',";
2215
-					}
2216
-				}
2217
-			}
2218
-
2219
-			return $attributes;
2220
-		}
2221
-
2222
-		/**
2223
-		 * A self looping function to create the output for JS block elements.
2224
-		 *
2225
-		 * This is what is output in the WP Editor visual view.
2226
-		 *
2227
-		 * @param $args
2228
-		 */
2229
-		public function block_element( $args ) {
2230
-
2231
-
2232
-			if ( ! empty( $args ) ) {
2233
-				foreach ( $args as $element => $new_args ) {
2234
-
2235
-					if ( is_array( $new_args ) ) { // its an element
2236
-
2237
-
2238
-						if ( isset( $new_args['element'] ) ) {
2239
-
2240
-							if ( isset( $new_args['element_require'] ) ) {
2241
-								echo str_replace( array(
2242
-										"'+",
2243
-										"+'"
2244
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
2245
-								unset( $new_args['element_require'] );
2246
-							}
2247
-
2248
-							echo "\n el( '" . $new_args['element'] . "', {";
2249
-
2250
-							// get the attributes
2251
-							foreach ( $new_args as $new_key => $new_value ) {
2252
-
2253
-
2254
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
2255
-									// do nothing
2256
-								} else {
2257
-									echo $this->block_element( array( $new_key => $new_value ) );
2258
-								}
2259
-							}
2260
-
2261
-							echo "},";// end attributes
2262
-
2263
-							// get the content
2264
-							$first_item = 0;
2265
-							foreach ( $new_args as $new_key => $new_value ) {
2266
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
2267
-
2268
-									if ( $new_key === 'content' ) {
2269
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
2270
-									}
2271
-
2272
-									if ( is_array( $new_value ) ) {
2273
-
2274
-										if ( isset( $new_value['element_require'] ) ) {
2275
-											echo str_replace( array(
2276
-													"'+",
2277
-													"+'"
2278
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
2279
-											unset( $new_value['element_require'] );
2280
-										}
2281
-
2282
-										if ( isset( $new_value['element_repeat'] ) ) {
2283
-											$x = 1;
2284
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
2285
-												$this->block_element( array( '' => $new_value ) );
2286
-												$x ++;
2287
-											}
2288
-										} else {
2289
-											$this->block_element( array( '' => $new_value ) );
2290
-										}
2291
-									}
2292
-									$first_item ++;
2293
-								}
2294
-							}
2295
-
2296
-							echo ")";// end content
2297
-
2298
-							echo ", \n";
2299
-
2300
-						}
2301
-					} else {
2302
-
2303
-						if ( substr( $element, 0, 3 ) === "if_" ) {
2304
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
2305
-						} elseif ( $element == 'style' ) {
2306
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
2307
-						} else {
2308
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
2309
-						}
2310
-
2311
-					}
2312
-				}
2313
-			}
2314
-		}
2315
-
2316
-		/**
2317
-		 * Replace block attributes placeholders with the proper naming.
2318
-		 *
2319
-		 * @param $string
2320
-		 *
2321
-		 * @return mixed
2322
-		 */
2323
-		public function block_props_replace( $string, $no_wrap = false ) {
2324
-
2325
-			if ( $no_wrap ) {
2326
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
2327
-			} else {
2328
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
2329
-			}
2330
-
2331
-			return $string;
2332
-		}
2333
-
2334
-		/**
2335
-		 * Outputs the content of the widget
2336
-		 *
2337
-		 * @param array $args
2338
-		 * @param array $instance
2339
-		 */
2340
-		public function widget( $args, $instance ) {
2341
-
2342
-			// get the filtered values
2343
-			$argument_values = $this->argument_values( $instance );
2344
-			$argument_values = $this->string_to_bool( $argument_values );
2345
-			$output          = $this->output( $argument_values, $args );
2346
-
2347
-			$no_wrap = false;
2348
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
2349
-				$no_wrap = true;
2350
-			}
2351
-
2352
-			ob_start();
2353
-			if ( $output && ! $no_wrap ) {
2354
-
2355
-				$class_original = $this->options['widget_ops']['classname'];
2356
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
2357
-
2358
-				// Before widget
2359
-				$before_widget = $args['before_widget'];
2360
-				$before_widget = str_replace($class_original,$class,$before_widget);
2361
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
2362
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
2363
-
2364
-				// After widget
2365
-				$after_widget = $args['after_widget'];
2366
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
2367
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
2368
-
2369
-				echo $before_widget;
2370
-				// elementor strips the widget wrapping div so we check for and add it back if needed
2371
-				if ( $this->is_elementor_widget_output() ) {
2372
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $class  ) . "'>" : '';
2373
-				}
2374
-				echo $this->output_title( $args, $instance );
2375
-				echo $output;
2376
-				if ( $this->is_elementor_widget_output() ) {
2377
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
2378
-				}
2379
-				echo $after_widget;
2380
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
2381
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
2382
-				echo $output;
2383
-			} elseif ( $output && $no_wrap ) {
2384
-				echo $output;
2385
-			}
2386
-			$output = ob_get_clean();
2387
-
2388
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
2389
-
2390
-			echo $output;
2391
-		}
2392
-
2393
-		/**
2394
-		 * Tests if the current output is inside a elementor container.
2395
-		 *
2396
-		 * @since 1.0.4
2397
-		 * @return bool
2398
-		 */
2399
-		public function is_elementor_widget_output() {
2400
-			$result = false;
2401
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
2402
-				$result = true;
2403
-			}
2404
-
2405
-			return $result;
2406
-		}
2407
-
2408
-		/**
2409
-		 * Tests if the current output is inside a elementor preview.
2410
-		 *
2411
-		 * @since 1.0.4
2412
-		 * @return bool
2413
-		 */
2414
-		public function is_elementor_preview() {
2415
-			$result = false;
2416
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
2417
-				$result = true;
2418
-			}
2419
-
2420
-			return $result;
2421
-		}
2422
-
2423
-		/**
2424
-		 * Tests if the current output is inside a Divi preview.
2425
-		 *
2426
-		 * @since 1.0.6
2427
-		 * @return bool
2428
-		 */
2429
-		public function is_divi_preview() {
2430
-			$result = false;
2431
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
2432
-				$result = true;
2433
-			}
2434
-
2435
-			return $result;
2436
-		}
2437
-
2438
-		/**
2439
-		 * Tests if the current output is inside a Beaver builder preview.
2440
-		 *
2441
-		 * @since 1.0.6
2442
-		 * @return bool
2443
-		 */
2444
-		public function is_beaver_preview() {
2445
-			$result = false;
2446
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
2447
-				$result = true;
2448
-			}
2449
-
2450
-			return $result;
2451
-		}
2452
-
2453
-		/**
2454
-		 * Tests if the current output is inside a siteorigin builder preview.
2455
-		 *
2456
-		 * @since 1.0.6
2457
-		 * @return bool
2458
-		 */
2459
-		public function is_siteorigin_preview() {
2460
-			$result = false;
2461
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
2462
-				$result = true;
2463
-			}
2464
-
2465
-			return $result;
2466
-		}
2467
-
2468
-		/**
2469
-		 * Tests if the current output is inside a cornerstone builder preview.
2470
-		 *
2471
-		 * @since 1.0.8
2472
-		 * @return bool
2473
-		 */
2474
-		public function is_cornerstone_preview() {
2475
-			$result = false;
2476
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
2477
-				$result = true;
2478
-			}
2479
-
2480
-			return $result;
2481
-		}
2482
-
2483
-		/**
2484
-		 * Tests if the current output is inside a fusion builder preview.
2485
-		 *
2486
-		 * @since 1.1.0
2487
-		 * @return bool
2488
-		 */
2489
-		public function is_fusion_preview() {
2490
-			$result = false;
2491
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
2492
-				$result = true;
2493
-			}
2494
-
2495
-			return $result;
2496
-		}
2497
-
2498
-		/**
2499
-		 * Tests if the current output is inside a Oxygen builder preview.
2500
-		 *
2501
-		 * @since 1.0.18
2502
-		 * @return bool
2503
-		 */
2504
-		public function is_oxygen_preview() {
2505
-			$result = false;
2506
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
2507
-				$result = true;
2508
-			}
2509
-
2510
-			return $result;
2511
-		}
2512
-
2513
-		/**
2514
-		 * General function to check if we are in a preview situation.
2515
-		 *
2516
-		 * @since 1.0.6
2517
-		 * @return bool
2518
-		 */
2519
-		public function is_preview() {
2520
-			$preview = false;
2521
-			if ( $this->is_divi_preview() ) {
2522
-				$preview = true;
2523
-			} elseif ( $this->is_elementor_preview() ) {
2524
-				$preview = true;
2525
-			} elseif ( $this->is_beaver_preview() ) {
2526
-				$preview = true;
2527
-			} elseif ( $this->is_siteorigin_preview() ) {
2528
-				$preview = true;
2529
-			} elseif ( $this->is_cornerstone_preview() ) {
2530
-				$preview = true;
2531
-			} elseif ( $this->is_fusion_preview() ) {
2532
-				$preview = true;
2533
-			} elseif ( $this->is_oxygen_preview() ) {
2534
-				$preview = true;
2535
-			} elseif( $this->is_block_content_call() ) {
2536
-				$preview = true;
2537
-			}
2538
-
2539
-			return $preview;
2540
-		}
2541
-
2542
-		/**
2543
-		 * Output the super title.
2544
-		 *
2545
-		 * @param $args
2546
-		 * @param array $instance
2547
-		 *
2548
-		 * @return string
2549
-		 */
2550
-		public function output_title( $args, $instance = array() ) {
2551
-			$output = '';
2552
-			if ( ! empty( $instance['title'] ) ) {
2553
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2554
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2555
-				$output = $args['before_title'] . $title . $args['after_title'];
2556
-			}
2557
-
2558
-			return $output;
2559
-		}
2560
-
2561
-		/**
2562
-		 * Outputs the options form inputs for the widget.
2563
-		 *
2564
-		 * @param array $instance The widget options.
2565
-		 */
2566
-		public function form( $instance ) {
2567
-
2568
-			// set widget instance
2569
-			$this->instance = $instance;
2570
-
2571
-			// set it as a SD widget
2572
-			echo $this->widget_advanced_toggle();
2573
-
2574
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2575
-			$arguments_raw = $this->get_arguments();
2576
-
2577
-			if ( is_array( $arguments_raw ) ) {
2578
-
2579
-				$arguments = $this->group_arguments( $arguments_raw );
2580
-
2581
-				// Do we have sections?
2582
-				$has_sections = $arguments == $arguments_raw ? false : true;
2583
-
2584
-
2585
-				if ( $has_sections ) {
2586
-					$panel_count = 0;
2587
-					foreach ( $arguments as $key => $args ) {
2588
-
2589
-						?>
2193
+        }
2194
+
2195
+        /**
2196
+         * Convert an array of attributes to block string.
2197
+         *
2198
+         * @todo there is prob a faster way to do this, also we could add some validation here.
2199
+         *
2200
+         * @param $custom_attributes
2201
+         *
2202
+         * @return string
2203
+         */
2204
+        public function array_to_attributes( $custom_attributes, $html = false ) {
2205
+            $attributes = '';
2206
+            if ( ! empty( $custom_attributes ) ) {
2207
+
2208
+                if ( $html ) {
2209
+                    foreach ( $custom_attributes as $key => $val ) {
2210
+                        $attributes .= " $key='$val' ";
2211
+                    }
2212
+                } else {
2213
+                    foreach ( $custom_attributes as $key => $val ) {
2214
+                        $attributes .= "'$key': '$val',";
2215
+                    }
2216
+                }
2217
+            }
2218
+
2219
+            return $attributes;
2220
+        }
2221
+
2222
+        /**
2223
+         * A self looping function to create the output for JS block elements.
2224
+         *
2225
+         * This is what is output in the WP Editor visual view.
2226
+         *
2227
+         * @param $args
2228
+         */
2229
+        public function block_element( $args ) {
2230
+
2231
+
2232
+            if ( ! empty( $args ) ) {
2233
+                foreach ( $args as $element => $new_args ) {
2234
+
2235
+                    if ( is_array( $new_args ) ) { // its an element
2236
+
2237
+
2238
+                        if ( isset( $new_args['element'] ) ) {
2239
+
2240
+                            if ( isset( $new_args['element_require'] ) ) {
2241
+                                echo str_replace( array(
2242
+                                        "'+",
2243
+                                        "+'"
2244
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
2245
+                                unset( $new_args['element_require'] );
2246
+                            }
2247
+
2248
+                            echo "\n el( '" . $new_args['element'] . "', {";
2249
+
2250
+                            // get the attributes
2251
+                            foreach ( $new_args as $new_key => $new_value ) {
2252
+
2253
+
2254
+                                if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
2255
+                                    // do nothing
2256
+                                } else {
2257
+                                    echo $this->block_element( array( $new_key => $new_value ) );
2258
+                                }
2259
+                            }
2260
+
2261
+                            echo "},";// end attributes
2262
+
2263
+                            // get the content
2264
+                            $first_item = 0;
2265
+                            foreach ( $new_args as $new_key => $new_value ) {
2266
+                                if ( $new_key === 'content' || is_array( $new_value ) ) {
2267
+
2268
+                                    if ( $new_key === 'content' ) {
2269
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
2270
+                                    }
2271
+
2272
+                                    if ( is_array( $new_value ) ) {
2273
+
2274
+                                        if ( isset( $new_value['element_require'] ) ) {
2275
+                                            echo str_replace( array(
2276
+                                                    "'+",
2277
+                                                    "+'"
2278
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
2279
+                                            unset( $new_value['element_require'] );
2280
+                                        }
2281
+
2282
+                                        if ( isset( $new_value['element_repeat'] ) ) {
2283
+                                            $x = 1;
2284
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
2285
+                                                $this->block_element( array( '' => $new_value ) );
2286
+                                                $x ++;
2287
+                                            }
2288
+                                        } else {
2289
+                                            $this->block_element( array( '' => $new_value ) );
2290
+                                        }
2291
+                                    }
2292
+                                    $first_item ++;
2293
+                                }
2294
+                            }
2295
+
2296
+                            echo ")";// end content
2297
+
2298
+                            echo ", \n";
2299
+
2300
+                        }
2301
+                    } else {
2302
+
2303
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
2304
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
2305
+                        } elseif ( $element == 'style' ) {
2306
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
2307
+                        } else {
2308
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
2309
+                        }
2310
+
2311
+                    }
2312
+                }
2313
+            }
2314
+        }
2315
+
2316
+        /**
2317
+         * Replace block attributes placeholders with the proper naming.
2318
+         *
2319
+         * @param $string
2320
+         *
2321
+         * @return mixed
2322
+         */
2323
+        public function block_props_replace( $string, $no_wrap = false ) {
2324
+
2325
+            if ( $no_wrap ) {
2326
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
2327
+            } else {
2328
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
2329
+            }
2330
+
2331
+            return $string;
2332
+        }
2333
+
2334
+        /**
2335
+         * Outputs the content of the widget
2336
+         *
2337
+         * @param array $args
2338
+         * @param array $instance
2339
+         */
2340
+        public function widget( $args, $instance ) {
2341
+
2342
+            // get the filtered values
2343
+            $argument_values = $this->argument_values( $instance );
2344
+            $argument_values = $this->string_to_bool( $argument_values );
2345
+            $output          = $this->output( $argument_values, $args );
2346
+
2347
+            $no_wrap = false;
2348
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
2349
+                $no_wrap = true;
2350
+            }
2351
+
2352
+            ob_start();
2353
+            if ( $output && ! $no_wrap ) {
2354
+
2355
+                $class_original = $this->options['widget_ops']['classname'];
2356
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
2357
+
2358
+                // Before widget
2359
+                $before_widget = $args['before_widget'];
2360
+                $before_widget = str_replace($class_original,$class,$before_widget);
2361
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
2362
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
2363
+
2364
+                // After widget
2365
+                $after_widget = $args['after_widget'];
2366
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
2367
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
2368
+
2369
+                echo $before_widget;
2370
+                // elementor strips the widget wrapping div so we check for and add it back if needed
2371
+                if ( $this->is_elementor_widget_output() ) {
2372
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $class  ) . "'>" : '';
2373
+                }
2374
+                echo $this->output_title( $args, $instance );
2375
+                echo $output;
2376
+                if ( $this->is_elementor_widget_output() ) {
2377
+                    echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
2378
+                }
2379
+                echo $after_widget;
2380
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
2381
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
2382
+                echo $output;
2383
+            } elseif ( $output && $no_wrap ) {
2384
+                echo $output;
2385
+            }
2386
+            $output = ob_get_clean();
2387
+
2388
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
2389
+
2390
+            echo $output;
2391
+        }
2392
+
2393
+        /**
2394
+         * Tests if the current output is inside a elementor container.
2395
+         *
2396
+         * @since 1.0.4
2397
+         * @return bool
2398
+         */
2399
+        public function is_elementor_widget_output() {
2400
+            $result = false;
2401
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
2402
+                $result = true;
2403
+            }
2404
+
2405
+            return $result;
2406
+        }
2407
+
2408
+        /**
2409
+         * Tests if the current output is inside a elementor preview.
2410
+         *
2411
+         * @since 1.0.4
2412
+         * @return bool
2413
+         */
2414
+        public function is_elementor_preview() {
2415
+            $result = false;
2416
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
2417
+                $result = true;
2418
+            }
2419
+
2420
+            return $result;
2421
+        }
2422
+
2423
+        /**
2424
+         * Tests if the current output is inside a Divi preview.
2425
+         *
2426
+         * @since 1.0.6
2427
+         * @return bool
2428
+         */
2429
+        public function is_divi_preview() {
2430
+            $result = false;
2431
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
2432
+                $result = true;
2433
+            }
2434
+
2435
+            return $result;
2436
+        }
2437
+
2438
+        /**
2439
+         * Tests if the current output is inside a Beaver builder preview.
2440
+         *
2441
+         * @since 1.0.6
2442
+         * @return bool
2443
+         */
2444
+        public function is_beaver_preview() {
2445
+            $result = false;
2446
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
2447
+                $result = true;
2448
+            }
2449
+
2450
+            return $result;
2451
+        }
2452
+
2453
+        /**
2454
+         * Tests if the current output is inside a siteorigin builder preview.
2455
+         *
2456
+         * @since 1.0.6
2457
+         * @return bool
2458
+         */
2459
+        public function is_siteorigin_preview() {
2460
+            $result = false;
2461
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
2462
+                $result = true;
2463
+            }
2464
+
2465
+            return $result;
2466
+        }
2467
+
2468
+        /**
2469
+         * Tests if the current output is inside a cornerstone builder preview.
2470
+         *
2471
+         * @since 1.0.8
2472
+         * @return bool
2473
+         */
2474
+        public function is_cornerstone_preview() {
2475
+            $result = false;
2476
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
2477
+                $result = true;
2478
+            }
2479
+
2480
+            return $result;
2481
+        }
2482
+
2483
+        /**
2484
+         * Tests if the current output is inside a fusion builder preview.
2485
+         *
2486
+         * @since 1.1.0
2487
+         * @return bool
2488
+         */
2489
+        public function is_fusion_preview() {
2490
+            $result = false;
2491
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
2492
+                $result = true;
2493
+            }
2494
+
2495
+            return $result;
2496
+        }
2497
+
2498
+        /**
2499
+         * Tests if the current output is inside a Oxygen builder preview.
2500
+         *
2501
+         * @since 1.0.18
2502
+         * @return bool
2503
+         */
2504
+        public function is_oxygen_preview() {
2505
+            $result = false;
2506
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
2507
+                $result = true;
2508
+            }
2509
+
2510
+            return $result;
2511
+        }
2512
+
2513
+        /**
2514
+         * General function to check if we are in a preview situation.
2515
+         *
2516
+         * @since 1.0.6
2517
+         * @return bool
2518
+         */
2519
+        public function is_preview() {
2520
+            $preview = false;
2521
+            if ( $this->is_divi_preview() ) {
2522
+                $preview = true;
2523
+            } elseif ( $this->is_elementor_preview() ) {
2524
+                $preview = true;
2525
+            } elseif ( $this->is_beaver_preview() ) {
2526
+                $preview = true;
2527
+            } elseif ( $this->is_siteorigin_preview() ) {
2528
+                $preview = true;
2529
+            } elseif ( $this->is_cornerstone_preview() ) {
2530
+                $preview = true;
2531
+            } elseif ( $this->is_fusion_preview() ) {
2532
+                $preview = true;
2533
+            } elseif ( $this->is_oxygen_preview() ) {
2534
+                $preview = true;
2535
+            } elseif( $this->is_block_content_call() ) {
2536
+                $preview = true;
2537
+            }
2538
+
2539
+            return $preview;
2540
+        }
2541
+
2542
+        /**
2543
+         * Output the super title.
2544
+         *
2545
+         * @param $args
2546
+         * @param array $instance
2547
+         *
2548
+         * @return string
2549
+         */
2550
+        public function output_title( $args, $instance = array() ) {
2551
+            $output = '';
2552
+            if ( ! empty( $instance['title'] ) ) {
2553
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2554
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2555
+                $output = $args['before_title'] . $title . $args['after_title'];
2556
+            }
2557
+
2558
+            return $output;
2559
+        }
2560
+
2561
+        /**
2562
+         * Outputs the options form inputs for the widget.
2563
+         *
2564
+         * @param array $instance The widget options.
2565
+         */
2566
+        public function form( $instance ) {
2567
+
2568
+            // set widget instance
2569
+            $this->instance = $instance;
2570
+
2571
+            // set it as a SD widget
2572
+            echo $this->widget_advanced_toggle();
2573
+
2574
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2575
+            $arguments_raw = $this->get_arguments();
2576
+
2577
+            if ( is_array( $arguments_raw ) ) {
2578
+
2579
+                $arguments = $this->group_arguments( $arguments_raw );
2580
+
2581
+                // Do we have sections?
2582
+                $has_sections = $arguments == $arguments_raw ? false : true;
2583
+
2584
+
2585
+                if ( $has_sections ) {
2586
+                    $panel_count = 0;
2587
+                    foreach ( $arguments as $key => $args ) {
2588
+
2589
+                        ?>
2590 2590
 						<script>
2591 2591
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
2592 2592
 						</script>
2593 2593
 						<?php
2594 2594
 
2595
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
2596
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
2597
-						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>";
2598
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
2599
-
2600
-						foreach ( $args as $k => $a ) {
2601
-							$this->widget_inputs( $a, $instance );
2602
-						}
2603
-
2604
-						echo "</div>";
2605
-
2606
-						$panel_count ++;
2607
-
2608
-					}
2609
-				} else {
2610
-					foreach ( $arguments as $key => $args ) {
2611
-						$this->widget_inputs( $args, $instance );
2612
-					}
2613
-				}
2614
-
2615
-			}
2616
-		}
2617
-
2618
-		/**
2619
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
2620
-		 *
2621
-		 * @return string
2622
-		 */
2623
-		public function widget_advanced_toggle() {
2624
-
2625
-			$output = '';
2626
-			if ( $this->block_show_advanced() ) {
2627
-				$val = 1;
2628
-			} else {
2629
-				$val = 0;
2630
-			}
2631
-
2632
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2633
-
2634
-			return $output;
2635
-		}
2636
-
2637
-		/**
2638
-		 * Convert require element.
2639
-		 *
2640
-		 * @since 1.0.0
2641
-		 *
2642
-		 * @param string $input Input element.
2643
-		 *
2644
-		 * @return string $output
2645
-		 */
2646
-		public function convert_element_require( $input ) {
2647
-
2648
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2649
-
2650
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2651
-				"jQuery(form).find('[data-argument=\"",
2652
-				"\"]').find('input,select,textarea').val()"
2653
-			), $input ) );
2654
-
2655
-			return $output;
2656
-		}
2657
-
2658
-		/**
2659
-		 * Builds the inputs for the widget options.
2660
-		 *
2661
-		 * @param $args
2662
-		 * @param $instance
2663
-		 */
2664
-		public function widget_inputs( $args, $instance ) {
2665
-
2666
-			$class             = "";
2667
-			$element_require   = "";
2668
-			$custom_attributes = "";
2669
-
2670
-			// get value
2671
-			if ( isset( $instance[ $args['name'] ] ) ) {
2672
-				$value = $instance[ $args['name'] ];
2673
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2674
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2675
-			} else {
2676
-				$value = '';
2677
-			}
2678
-
2679
-			// get placeholder
2680
-			if ( ! empty( $args['placeholder'] ) ) {
2681
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2682
-			} else {
2683
-				$placeholder = '';
2684
-			}
2685
-
2686
-			// get if advanced
2687
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2688
-				$class .= " sd-advanced-setting ";
2689
-			}
2690
-
2691
-			// element_require
2692
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2693
-				$element_require = $args['element_require'];
2694
-			}
2695
-
2696
-			// custom_attributes
2697
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2698
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2699
-			}
2700
-
2701
-			// before wrapper
2702
-			?>
2595
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
2596
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
2597
+                        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>";
2598
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
2599
+
2600
+                        foreach ( $args as $k => $a ) {
2601
+                            $this->widget_inputs( $a, $instance );
2602
+                        }
2603
+
2604
+                        echo "</div>";
2605
+
2606
+                        $panel_count ++;
2607
+
2608
+                    }
2609
+                } else {
2610
+                    foreach ( $arguments as $key => $args ) {
2611
+                        $this->widget_inputs( $args, $instance );
2612
+                    }
2613
+                }
2614
+
2615
+            }
2616
+        }
2617
+
2618
+        /**
2619
+         * Get the hidden input that when added makes the advanced button show on widget settings.
2620
+         *
2621
+         * @return string
2622
+         */
2623
+        public function widget_advanced_toggle() {
2624
+
2625
+            $output = '';
2626
+            if ( $this->block_show_advanced() ) {
2627
+                $val = 1;
2628
+            } else {
2629
+                $val = 0;
2630
+            }
2631
+
2632
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
2633
+
2634
+            return $output;
2635
+        }
2636
+
2637
+        /**
2638
+         * Convert require element.
2639
+         *
2640
+         * @since 1.0.0
2641
+         *
2642
+         * @param string $input Input element.
2643
+         *
2644
+         * @return string $output
2645
+         */
2646
+        public function convert_element_require( $input ) {
2647
+
2648
+            $input = str_replace( "'", '"', $input );// we only want double quotes
2649
+
2650
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
2651
+                "jQuery(form).find('[data-argument=\"",
2652
+                "\"]').find('input,select,textarea').val()"
2653
+            ), $input ) );
2654
+
2655
+            return $output;
2656
+        }
2657
+
2658
+        /**
2659
+         * Builds the inputs for the widget options.
2660
+         *
2661
+         * @param $args
2662
+         * @param $instance
2663
+         */
2664
+        public function widget_inputs( $args, $instance ) {
2665
+
2666
+            $class             = "";
2667
+            $element_require   = "";
2668
+            $custom_attributes = "";
2669
+
2670
+            // get value
2671
+            if ( isset( $instance[ $args['name'] ] ) ) {
2672
+                $value = $instance[ $args['name'] ];
2673
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2674
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2675
+            } else {
2676
+                $value = '';
2677
+            }
2678
+
2679
+            // get placeholder
2680
+            if ( ! empty( $args['placeholder'] ) ) {
2681
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2682
+            } else {
2683
+                $placeholder = '';
2684
+            }
2685
+
2686
+            // get if advanced
2687
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2688
+                $class .= " sd-advanced-setting ";
2689
+            }
2690
+
2691
+            // element_require
2692
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2693
+                $element_require = $args['element_require'];
2694
+            }
2695
+
2696
+            // custom_attributes
2697
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2698
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2699
+            }
2700
+
2701
+            // before wrapper
2702
+            ?>
2703 2703
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2704 2704
 			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2705 2705
 			   data-element_require='<?php if ( $element_require ) {
2706
-				   echo $this->convert_element_require( $element_require );
2707
-			   } ?>'
2706
+                    echo $this->convert_element_require( $element_require );
2707
+                } ?>'
2708 2708
 			>
2709 2709
 				<?php
2710 2710
 
2711
-				switch ( $args['type'] ) {
2712
-					//array('text','password','number','email','tel','url','color')
2713
-					case "text":
2714
-					case "password":
2715
-					case "number":
2716
-					case "email":
2717
-					case "tel":
2718
-					case "url":
2719
-					case "color":
2720
-						?>
2711
+                switch ( $args['type'] ) {
2712
+                    //array('text','password','number','email','tel','url','color')
2713
+                    case "text":
2714
+                    case "password":
2715
+                    case "number":
2716
+                    case "email":
2717
+                    case "tel":
2718
+                    case "url":
2719
+                    case "color":
2720
+                        ?>
2721 2721
 						<label
2722 2722
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2723 2723
 						<input <?php echo $placeholder; ?> class="widefat"
@@ -2728,47 +2728,47 @@  discard block
 block discarded – undo
2728 2728
 							                               value="<?php echo esc_attr( $value ); ?>">
2729 2729
 						<?php
2730 2730
 
2731
-						break;
2732
-					case "select":
2733
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2734
-						if ( $multiple ) {
2735
-							if ( empty( $value ) ) {
2736
-								$value = array();
2737
-							}
2738
-						}
2739
-						?>
2731
+                        break;
2732
+                    case "select":
2733
+                        $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2734
+                        if ( $multiple ) {
2735
+                            if ( empty( $value ) ) {
2736
+                                $value = array();
2737
+                            }
2738
+                        }
2739
+                        ?>
2740 2740
 						<label
2741 2741
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2742 2742
 						<select <?php echo $placeholder; ?> class="widefat"
2743 2743
 							<?php echo $custom_attributes; ?>
2744 2744
 							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2745 2745
 							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2746
-							                                if ( $multiple ) {
2747
-								                                echo "[]";
2748
-							                                } ?>"
2746
+                                                            if ( $multiple ) {
2747
+                                                                echo "[]";
2748
+                                                            } ?>"
2749 2749
 							<?php if ( $multiple ) {
2750
-								echo "multiple";
2751
-							} //@todo not implemented yet due to gutenberg not supporting it
2752
-							?>
2750
+                                echo "multiple";
2751
+                            } //@todo not implemented yet due to gutenberg not supporting it
2752
+                            ?>
2753 2753
 						>
2754 2754
 							<?php
2755 2755
 
2756
-							if ( ! empty( $args['options'] ) ) {
2757
-								foreach ( $args['options'] as $val => $label ) {
2758
-									if ( $multiple ) {
2759
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2760
-									} else {
2761
-										$selected = selected( $value, $val, false );
2762
-									}
2763
-									echo "<option value='$val' " . $selected . ">$label</option>";
2764
-								}
2765
-							}
2766
-							?>
2756
+                            if ( ! empty( $args['options'] ) ) {
2757
+                                foreach ( $args['options'] as $val => $label ) {
2758
+                                    if ( $multiple ) {
2759
+                                        $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2760
+                                    } else {
2761
+                                        $selected = selected( $value, $val, false );
2762
+                                    }
2763
+                                    echo "<option value='$val' " . $selected . ">$label</option>";
2764
+                                }
2765
+                            }
2766
+                            ?>
2767 2767
 						</select>
2768 2768
 						<?php
2769
-						break;
2770
-					case "checkbox":
2771
-						?>
2769
+                        break;
2770
+                    case "checkbox":
2771
+                        ?>
2772 2772
 						<input <?php echo $placeholder; ?>
2773 2773
 							<?php checked( 1, $value, true ) ?>
2774 2774
 							<?php echo $custom_attributes; ?>
@@ -2778,9 +2778,9 @@  discard block
 block discarded – undo
2778 2778
 						<label
2779 2779
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2780 2780
 						<?php
2781
-						break;
2782
-					case "textarea":
2783
-						?>
2781
+                        break;
2782
+                    case "textarea":
2783
+                        ?>
2784 2784
 						<label
2785 2785
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2786 2786
 						<textarea <?php echo $placeholder; ?> class="widefat"
@@ -2790,173 +2790,173 @@  discard block
 block discarded – undo
2790 2790
 						><?php echo esc_attr( $value ); ?></textarea>
2791 2791
 						<?php
2792 2792
 
2793
-						break;
2794
-					case "hidden":
2795
-						?>
2793
+                        break;
2794
+                    case "hidden":
2795
+                        ?>
2796 2796
 						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2797 2797
 						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2798 2798
 						       value="<?php echo esc_attr( $value ); ?>">
2799 2799
 						<?php
2800
-						break;
2801
-					default:
2802
-						echo "No input type found!"; // @todo we need to add more input types.
2803
-				}
2800
+                        break;
2801
+                    default:
2802
+                        echo "No input type found!"; // @todo we need to add more input types.
2803
+                }
2804 2804
 
2805
-				// after wrapper
2806
-				?>
2805
+                // after wrapper
2806
+                ?>
2807 2807
 			</p>
2808 2808
 			<?php
2809 2809
 
2810
-		}
2811
-
2812
-		/**
2813
-		 * Get the widget input description html.
2814
-		 *
2815
-		 * @param $args
2816
-		 *
2817
-		 * @return string
2818
-		 * @todo, need to make its own tooltip script
2819
-		 */
2820
-		public function widget_field_desc( $args ) {
2821
-
2822
-			$description = '';
2823
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2824
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2825
-					$description = $this->desc_tip( $args['desc'] );
2826
-				} else {
2827
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2828
-				}
2829
-			}
2830
-
2831
-			return $description;
2832
-		}
2833
-
2834
-		/**
2835
-		 * Get the tool tip html.
2836
-		 *
2837
-		 * @param $tip
2838
-		 * @param bool $allow_html
2839
-		 *
2840
-		 * @return string
2841
-		 */
2842
-		function desc_tip( $tip, $allow_html = false ) {
2843
-			if ( $allow_html ) {
2844
-				$tip = $this->sanitize_tooltip( $tip );
2845
-			} else {
2846
-				$tip = esc_attr( $tip );
2847
-			}
2848
-
2849
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2850
-		}
2851
-
2852
-		/**
2853
-		 * Sanitize a string destined to be a tooltip.
2854
-		 *
2855
-		 * @param string $var
2856
-		 *
2857
-		 * @return string
2858
-		 */
2859
-		public function sanitize_tooltip( $var ) {
2860
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2861
-				'br'     => array(),
2862
-				'em'     => array(),
2863
-				'strong' => array(),
2864
-				'small'  => array(),
2865
-				'span'   => array(),
2866
-				'ul'     => array(),
2867
-				'li'     => array(),
2868
-				'ol'     => array(),
2869
-				'p'      => array(),
2870
-			) ) );
2871
-		}
2872
-
2873
-		/**
2874
-		 * Processing widget options on save
2875
-		 *
2876
-		 * @param array $new_instance The new options
2877
-		 * @param array $old_instance The previous options
2878
-		 *
2879
-		 * @return array
2880
-		 * @todo we should add some sanitation here.
2881
-		 */
2882
-		public function update( $new_instance, $old_instance ) {
2883
-
2884
-			//save the widget
2885
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2886
-
2887
-			// set widget instance
2888
-			$this->instance = $instance;
2889
-
2890
-			if ( empty( $this->arguments ) ) {
2891
-				$this->get_arguments();
2892
-			}
2893
-
2894
-			// check for checkboxes
2895
-			if ( ! empty( $this->arguments ) ) {
2896
-				foreach ( $this->arguments as $argument ) {
2897
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2898
-						$instance[ $argument['name'] ] = '0';
2899
-					}
2900
-				}
2901
-			}
2902
-
2903
-			return $instance;
2904
-		}
2905
-
2906
-		/**
2907
-		 * Checks if the current call is a ajax call to get the block content.
2908
-		 *
2909
-		 * This can be used in your widget to return different content as the block content.
2910
-		 *
2911
-		 * @since 1.0.3
2912
-		 * @return bool
2913
-		 */
2914
-		public function is_block_content_call() {
2915
-			$result = false;
2916
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2917
-				$result = true;
2918
-			}
2919
-
2920
-			return $result;
2921
-		}
2922
-
2923
-		/**
2924
-		 * Get an instance hash that will be unique to the type and settings.
2925
-		 *
2926
-		 * @since 1.0.20
2927
-		 * @return string
2928
-		 */
2929
-		public function get_instance_hash(){
2930
-			$instance_string = $this->base_id.serialize($this->instance);
2931
-			return hash('crc32b',$instance_string);
2932
-		}
2933
-
2934
-		/**
2935
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
2936
-		 *
2937
-		 * @param array $rules
2938
-		 *
2939
-		 * @since 1.0.20
2940
-		 * @return string
2941
-		 */
2942
-		public function get_instance_style($rules = array()){
2943
-			$css = '';
2944
-
2945
-			if(!empty($rules)){
2946
-				$rules = array_unique($rules);
2947
-				$instance_hash = $this->get_instance_hash();
2948
-				$css .= "<style>";
2949
-				foreach($rules as $rule){
2950
-					$css .= ".sdel-$instance_hash $rule";
2951
-				}
2952
-				$css .= "</style>";
2953
-			}
2954
-
2955
-
2956
-			return $css;
2957
-
2958
-		}
2959
-
2960
-	}
2810
+        }
2811
+
2812
+        /**
2813
+         * Get the widget input description html.
2814
+         *
2815
+         * @param $args
2816
+         *
2817
+         * @return string
2818
+         * @todo, need to make its own tooltip script
2819
+         */
2820
+        public function widget_field_desc( $args ) {
2821
+
2822
+            $description = '';
2823
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
2824
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2825
+                    $description = $this->desc_tip( $args['desc'] );
2826
+                } else {
2827
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2828
+                }
2829
+            }
2830
+
2831
+            return $description;
2832
+        }
2833
+
2834
+        /**
2835
+         * Get the tool tip html.
2836
+         *
2837
+         * @param $tip
2838
+         * @param bool $allow_html
2839
+         *
2840
+         * @return string
2841
+         */
2842
+        function desc_tip( $tip, $allow_html = false ) {
2843
+            if ( $allow_html ) {
2844
+                $tip = $this->sanitize_tooltip( $tip );
2845
+            } else {
2846
+                $tip = esc_attr( $tip );
2847
+            }
2848
+
2849
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
2850
+        }
2851
+
2852
+        /**
2853
+         * Sanitize a string destined to be a tooltip.
2854
+         *
2855
+         * @param string $var
2856
+         *
2857
+         * @return string
2858
+         */
2859
+        public function sanitize_tooltip( $var ) {
2860
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2861
+                'br'     => array(),
2862
+                'em'     => array(),
2863
+                'strong' => array(),
2864
+                'small'  => array(),
2865
+                'span'   => array(),
2866
+                'ul'     => array(),
2867
+                'li'     => array(),
2868
+                'ol'     => array(),
2869
+                'p'      => array(),
2870
+            ) ) );
2871
+        }
2872
+
2873
+        /**
2874
+         * Processing widget options on save
2875
+         *
2876
+         * @param array $new_instance The new options
2877
+         * @param array $old_instance The previous options
2878
+         *
2879
+         * @return array
2880
+         * @todo we should add some sanitation here.
2881
+         */
2882
+        public function update( $new_instance, $old_instance ) {
2883
+
2884
+            //save the widget
2885
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
2886
+
2887
+            // set widget instance
2888
+            $this->instance = $instance;
2889
+
2890
+            if ( empty( $this->arguments ) ) {
2891
+                $this->get_arguments();
2892
+            }
2893
+
2894
+            // check for checkboxes
2895
+            if ( ! empty( $this->arguments ) ) {
2896
+                foreach ( $this->arguments as $argument ) {
2897
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2898
+                        $instance[ $argument['name'] ] = '0';
2899
+                    }
2900
+                }
2901
+            }
2902
+
2903
+            return $instance;
2904
+        }
2905
+
2906
+        /**
2907
+         * Checks if the current call is a ajax call to get the block content.
2908
+         *
2909
+         * This can be used in your widget to return different content as the block content.
2910
+         *
2911
+         * @since 1.0.3
2912
+         * @return bool
2913
+         */
2914
+        public function is_block_content_call() {
2915
+            $result = false;
2916
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2917
+                $result = true;
2918
+            }
2919
+
2920
+            return $result;
2921
+        }
2922
+
2923
+        /**
2924
+         * Get an instance hash that will be unique to the type and settings.
2925
+         *
2926
+         * @since 1.0.20
2927
+         * @return string
2928
+         */
2929
+        public function get_instance_hash(){
2930
+            $instance_string = $this->base_id.serialize($this->instance);
2931
+            return hash('crc32b',$instance_string);
2932
+        }
2933
+
2934
+        /**
2935
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
2936
+         *
2937
+         * @param array $rules
2938
+         *
2939
+         * @since 1.0.20
2940
+         * @return string
2941
+         */
2942
+        public function get_instance_style($rules = array()){
2943
+            $css = '';
2944
+
2945
+            if(!empty($rules)){
2946
+                $rules = array_unique($rules);
2947
+                $instance_hash = $this->get_instance_hash();
2948
+                $css .= "<style>";
2949
+                foreach($rules as $rule){
2950
+                    $css .= ".sdel-$instance_hash $rule";
2951
+                }
2952
+                $css .= "</style>";
2953
+            }
2954
+
2955
+
2956
+            return $css;
2957
+
2958
+        }
2959
+
2960
+    }
2961 2961
 
2962 2962
 }
Please login to merge, or discard this patch.
Spacing   +477 added lines, -477 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8 8
 
9 9
 	/**
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 		/**
38 38
 		 * Take the array options and use them to build.
39 39
 		 */
40
-		public function __construct( $options ) {
40
+		public function __construct($options) {
41 41
 			global $sd_widgets;
42 42
 
43
-			$sd_widgets[ $options['base_id'] ] = array(
43
+			$sd_widgets[$options['base_id']] = array(
44 44
 				'name'       => $options['name'],
45 45
 				'class_name' => $options['class_name']
46 46
 			);
47
-			$this->base_id                     = $options['base_id'];
47
+			$this->base_id = $options['base_id'];
48 48
 			// lets filter the options before we do anything
49
-			$options       = apply_filters( "wp_super_duper_options", $options );
50
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
51
-			$options       = $this->add_name_from_key( $options );
49
+			$options       = apply_filters("wp_super_duper_options", $options);
50
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
51
+			$options       = $this->add_name_from_key($options);
52 52
 			$this->options = $options;
53 53
 
54 54
 			$this->base_id   = $options['base_id'];
55
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
55
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
56 56
 
57 57
 			// init parent
58
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
58
+			parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
59 59
 
60
-			if ( isset( $options['class_name'] ) ) {
60
+			if (isset($options['class_name'])) {
61 61
 				// register widget
62 62
 				$this->class_name = $options['class_name'];
63 63
 
@@ -65,66 +65,66 @@  discard block
 block discarded – undo
65 65
 				$this->register_shortcode();
66 66
 
67 67
 				// Fusion Builder (avada) support
68
-				if ( function_exists( 'fusion_builder_map' ) ) {
69
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
68
+				if (function_exists('fusion_builder_map')) {
69
+					add_action('init', array($this, 'register_fusion_element'));
70 70
 				}
71 71
 
72 72
 				// register block
73
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
73
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
74 74
 			}
75 75
 
76 76
 			// add the CSS and JS we need ONCE
77 77
 			global $sd_widget_scripts;
78 78
 
79
-			if ( ! $sd_widget_scripts ) {
80
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
81
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
82
-				wp_add_inline_style( 'widgets', $this->widget_css() );
79
+			if (!$sd_widget_scripts) {
80
+				wp_add_inline_script('admin-widgets', $this->widget_js());
81
+				wp_add_inline_script('customize-controls', $this->widget_js());
82
+				wp_add_inline_style('widgets', $this->widget_css());
83 83
 
84 84
 				// maybe add elementor editor styles
85
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
85
+				add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles'));
86 86
 
87 87
 				$sd_widget_scripts = true;
88 88
 
89 89
 				// add shortcode insert button once
90
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
90
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
91 91
 				// generatepress theme sections compatibility
92
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
93
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
92
+				if (function_exists('generate_sections_sections_metabox')) {
93
+					add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script'));
94 94
 				}
95
-				if ( $this->is_preview() ) {
96
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
95
+				if ($this->is_preview()) {
96
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
97 97
 					// this makes the insert button work for elementor
98
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
98
+					add_action('elementor/editor/after_enqueue_scripts', array(
99 99
 						$this,
100 100
 						'shortcode_insert_button_script'
101
-					) ); // for elementor
101
+					)); // for elementor
102 102
 				}
103 103
 				// this makes the insert button work for cornerstone
104
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
104
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
105 105
 
106
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
107
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
106
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
107
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
108 108
 
109 109
 				// add generator text to admin head
110
-				add_action( 'admin_head', array( $this, 'generator' ) );
110
+				add_action('admin_head', array($this, 'generator'));
111 111
 			}
112 112
 
113
-			do_action( 'wp_super_duper_widget_init', $options, $this );
113
+			do_action('wp_super_duper_widget_init', $options, $this);
114 114
 		}
115 115
 
116 116
 		/**
117 117
 		 * Add our widget CSS to elementor editor.
118 118
 		 */
119 119
 		public function elementor_editor_styles() {
120
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
120
+			wp_add_inline_style('elementor-editor', $this->widget_css(false));
121 121
 		}
122 122
 
123 123
 		public function register_fusion_element() {
124 124
 
125 125
 			$options = $this->options;
126 126
 
127
-			if ( $this->base_id ) {
127
+			if ($this->base_id) {
128 128
 
129 129
 				$params = $this->get_fusion_params();
130 130
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 					'allow_generator' => true,
136 136
 				);
137 137
 
138
-				if ( ! empty( $params ) ) {
138
+				if (!empty($params)) {
139 139
 					$args['params'] = $params;
140 140
 				}
141 141
 
142
-				fusion_builder_map( $args );
142
+				fusion_builder_map($args);
143 143
 			}
144 144
 
145 145
 		}
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 			$params    = array();
149 149
 			$arguments = $this->get_arguments();
150 150
 
151
-			if ( ! empty( $arguments ) ) {
152
-				foreach ( $arguments as $key => $val ) {
151
+			if (!empty($arguments)) {
152
+				foreach ($arguments as $key => $val) {
153 153
 					$param = array();
154 154
 					// type
155 155
 					$param['type'] = str_replace(
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 						$val['type'] );
172 172
 
173 173
 					// multiselect
174
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
174
+					if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) {
175 175
 						$param['type']     = 'multiple_select';
176 176
 						$param['multiple'] = true;
177 177
 					}
@@ -180,29 +180,29 @@  discard block
 block discarded – undo
180 180
 					$param['heading'] = $val['title'];
181 181
 
182 182
 					// description
183
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
183
+					$param['description'] = isset($val['desc']) ? $val['desc'] : '';
184 184
 
185 185
 					// param_name
186 186
 					$param['param_name'] = $key;
187 187
 
188 188
 					// Default
189
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
189
+					$param['default'] = isset($val['default']) ? $val['default'] : '';
190 190
 
191 191
 					// Group
192
-					if ( isset( $val['group'] ) ) {
192
+					if (isset($val['group'])) {
193 193
 						$param['group'] = $val['group'];
194 194
 					}
195 195
 
196 196
 					// value
197
-					if ( $val['type'] == 'checkbox' ) {
198
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
199
-							unset( $param['default'] );
197
+					if ($val['type'] == 'checkbox') {
198
+						if (isset($val['default']) && $val['default'] == '0') {
199
+							unset($param['default']);
200 200
 						}
201
-						$param['value'] = array( '' => __( "No" ), '1' => __( "Yes" ) );
202
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
203
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
201
+						$param['value'] = array('' => __("No"), '1' => __("Yes"));
202
+					} elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') {
203
+						$param['value'] = isset($val['options']) ? $val['options'] : array();
204 204
 					} else {
205
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
205
+						$param['value'] = isset($val['default']) ? $val['default'] : '';
206 206
 					}
207 207
 
208 208
 					// setup the param
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
220 220
 		 */
221 221
 		public static function maybe_cornerstone_builder() {
222
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
222
+			if (did_action('cornerstone_before_boot_app')) {
223 223
 				self::shortcode_insert_button_script();
224 224
 			}
225 225
 		}
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 		 *
232 232
 		 * @return string
233 233
 		 */
234
-		public static function get_picker( $editor_id = '' ) {
234
+		public static function get_picker($editor_id = '') {
235 235
 
236 236
 			ob_start();
237
-			if ( isset( $_POST['editor_id'] ) ) {
238
-				$editor_id = esc_attr( $_POST['editor_id'] );
239
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
237
+			if (isset($_POST['editor_id'])) {
238
+				$editor_id = esc_attr($_POST['editor_id']);
239
+			} elseif (isset($_REQUEST['et_fb'])) {
240 240
 				$editor_id = 'main_content_content_vb_tiny_mce';
241 241
 			}
242 242
 
@@ -245,13 +245,13 @@  discard block
 block discarded – undo
245 245
 
246 246
 			<div class="sd-shortcode-left-wrap">
247 247
 				<?php
248
-				ksort( $sd_widgets );
248
+				ksort($sd_widgets);
249 249
 				//				print_r($sd_widgets);exit;
250
-				if ( ! empty( $sd_widgets ) ) {
250
+				if (!empty($sd_widgets)) {
251 251
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
252
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
253
-					foreach ( $sd_widgets as $shortcode => $class ) {
254
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
252
+					echo "<option>" . __('Select shortcode') . "</option>";
253
+					foreach ($sd_widgets as $shortcode => $class) {
254
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
255 255
 					}
256 256
 					echo "</select>";
257 257
 
@@ -264,37 +264,37 @@  discard block
 block discarded – undo
264 264
 			<div class="sd-shortcode-right-wrap">
265 265
 				<textarea id='sd-shortcode-output' disabled></textarea>
266 266
 				<div id='sd-shortcode-output-actions'>
267
-					<?php if ( $editor_id != '' ) { ?>
267
+					<?php if ($editor_id != '') { ?>
268 268
 						<button class="button sd-insert-shortcode-button"
269
-						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
269
+						        onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
270 270
 							        echo "'" . $editor_id . "'";
271
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
271
+						        } ?>)"><?php _e('Insert shortcode'); ?></button>
272 272
 					<?php } ?>
273 273
 					<button class="button"
274
-					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
274
+					        onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
275 275
 				</div>
276 276
 			</div>
277 277
 			<?php
278 278
 
279 279
 			$html = ob_get_clean();
280 280
 
281
-			if ( wp_doing_ajax() ) {
281
+			if (wp_doing_ajax()) {
282 282
 				echo $html;
283 283
 				$should_die = true;
284 284
 
285 285
 				// some builder get the editor via ajax so we should not die on those ocasions
286 286
 				$dont_die = array(
287
-					'parent_tag',// WP Bakery
287
+					'parent_tag', // WP Bakery
288 288
 					'avia_request' // enfold
289 289
 				);
290 290
 
291
-				foreach ( $dont_die as $request ) {
292
-					if ( isset( $_REQUEST[ $request ] ) ) {
291
+				foreach ($dont_die as $request) {
292
+					if (isset($_REQUEST[$request])) {
293 293
 						$should_die = false;
294 294
 					}
295 295
 				}
296 296
 
297
-				if ( $should_die ) {
297
+				if ($should_die) {
298 298
 					wp_die();
299 299
 				}
300 300
 
@@ -321,16 +321,16 @@  discard block
 block discarded – undo
321 321
 		public static function get_widget_settings() {
322 322
 			global $sd_widgets;
323 323
 
324
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
325
-			if ( ! $shortcode ) {
324
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
325
+			if (!$shortcode) {
326 326
 				wp_die();
327 327
 			}
328
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
329
-			if ( ! $widget_args ) {
328
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
329
+			if (!$widget_args) {
330 330
 				wp_die();
331 331
 			}
332
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
333
-			if ( ! $class_name ) {
332
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
333
+			if (!$class_name) {
334 334
 				wp_die();
335 335
 			}
336 336
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			$widget = new $class_name;
339 339
 
340 340
 			ob_start();
341
-			$widget->form( array() );
341
+			$widget->form(array());
342 342
 			$form = ob_get_clean();
343 343
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
344 344
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
357 357
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
358 358
 		 */
359
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
359
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
360 360
 			global $sd_widgets, $shortcode_insert_button_once;
361
-			if ( $shortcode_insert_button_once ) {
361
+			if ($shortcode_insert_button_once) {
362 362
 				return;
363 363
 			}
364 364
 			add_thickbox();
@@ -368,21 +368,21 @@  discard block
 block discarded – undo
368 368
 			 * Cornerstone makes us play dirty tricks :/
369 369
 			 * 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.
370 370
 			 */
371
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
371
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
372 372
 				echo '<span id="insert-media-button">';
373 373
 			}
374 374
 
375
-			echo self::shortcode_button( 'this', 'true' );
375
+			echo self::shortcode_button('this', 'true');
376 376
 
377 377
 			// see opening note
378
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
378
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
379 379
 				echo '</span>'; // end #insert-media-button
380 380
 			}
381 381
 
382 382
 			// Add separate script for generatepress theme sections
383
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
383
+			if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) {
384 384
 			} else {
385
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
385
+				self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
386 386
 			}
387 387
 
388 388
 			$shortcode_insert_button_once = true;
@@ -396,12 +396,12 @@  discard block
 block discarded – undo
396 396
 		 *
397 397
 		 * @return mixed
398 398
 		 */
399
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
399
+		public static function shortcode_button($id = '', $search_for_id = '') {
400 400
 			ob_start();
401 401
 			?>
402 402
 			<span class="sd-lable-shortcode-inserter">
403 403
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
404
-				if ( $search_for_id ) {
404
+				if ($search_for_id) {
405 405
 					echo "," . $search_for_id;
406 406
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
407 407
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 			$html = ob_get_clean();
418 418
 
419 419
 			// remove line breaks so we can use it in js
420
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
420
+			return preg_replace("/\r|\n/", "", trim($html));
421 421
 		}
422 422
 
423 423
 		/**
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 						jQuery($this).data('sd-widget-enabled', true);
476 476
 					}
477 477
 
478
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
478
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
479 479
 					var form = jQuery($this).parents('' + $selector + '');
480 480
 
481 481
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -512,10 +512,10 @@  discard block
 block discarded – undo
512 512
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
513 513
 			 */
514 514
 
515
-			return str_replace( array(
515
+			return str_replace(array(
516 516
 				'<script>',
517 517
 				'</script>'
518
-			), '', $output );
518
+			), '', $output);
519 519
 		}
520 520
 
521 521
 		/**
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		 * @param string $editor_id
527 527
 		 * @param string $insert_shortcode_function
528 528
 		 */
529
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
529
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
530 530
 			?>
531 531
 			<style>
532 532
 				.sd-shortcode-left-wrap {
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 					width: 100%;
646 646
 				}
647 647
 
648
-				<?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?>
648
+				<?php if (function_exists('generate_sections_sections_metabox')) { ?>
649 649
 				.generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter {
650 650
 					display: inline;
651 651
 				}
@@ -653,15 +653,15 @@  discard block
 block discarded – undo
653 653
 				<?php } ?>
654 654
 			</style>
655 655
 			<?php
656
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
656
+			if (class_exists('SiteOrigin_Panels')) {
657 657
 				echo "<script>" . self::siteorigin_js() . "</script>";
658 658
 			}
659 659
 			?>
660 660
 			<script>
661 661
 				<?php
662
-				if(! empty( $insert_shortcode_function )){
662
+				if (!empty($insert_shortcode_function)) {
663 663
 					echo $insert_shortcode_function;
664
-				}else{
664
+				} else {
665 665
 
666 666
 				/**
667 667
 				 * Function for super duper insert shortcode.
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 					if ($shortcode) {
675 675
 						if (!$editor_id) {
676 676
 							<?php
677
-							if ( isset( $_REQUEST['et_fb'] ) ) {
677
+							if (isset($_REQUEST['et_fb'])) {
678 678
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
679
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
679
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
680 680
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
681 681
 							} else {
682 682
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
 							'shortcode': $short_code,
762 762
 							'attributes': 123,
763 763
 							'post_id': 321,
764
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
764
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
765 765
 						};
766 766
 
767 767
 						if (typeof ajaxurl === 'undefined') {
768
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
768
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
769 769
 						}
770 770
 
771 771
 						jQuery.post(ajaxurl, data, function (response) {
@@ -974,11 +974,11 @@  discard block
 block discarded – undo
974 974
 					var data = {
975 975
 						'action': 'super_duper_get_picker',
976 976
 						'editor_id': $id,
977
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
977
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
978 978
 					};
979 979
 
980 980
 					if (!ajaxurl) {
981
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
981
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
982 982
 					}
983 983
 
984 984
 					jQuery.post(ajaxurl, data, function (response) {
@@ -999,9 +999,9 @@  discard block
 block discarded – undo
999 999
 				 */
1000 1000
 				function sd_shortcode_button($id) {
1001 1001
 					if ($id) {
1002
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
1002
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
1003 1003
 					} else {
1004
-						return '<?php echo self::shortcode_button();?>';
1004
+						return '<?php echo self::shortcode_button(); ?>';
1005 1005
 					}
1006 1006
 				}
1007 1007
 
@@ -1016,11 +1016,11 @@  discard block
 block discarded – undo
1016 1016
 		 *
1017 1017
 		 * @return mixed
1018 1018
 		 */
1019
-		public function widget_css( $advanced = true ) {
1019
+		public function widget_css($advanced = true) {
1020 1020
 			ob_start();
1021 1021
 			?>
1022 1022
 			<style>
1023
-				<?php if( $advanced ){ ?>
1023
+				<?php if ($advanced) { ?>
1024 1024
 				.sd-advanced-setting {
1025 1025
 					display: none;
1026 1026
 				}
@@ -1062,10 +1062,10 @@  discard block
 block discarded – undo
1062 1062
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1063 1063
 			 */
1064 1064
 
1065
-			return str_replace( array(
1065
+			return str_replace(array(
1066 1066
 				'<style>',
1067 1067
 				'</style>'
1068
-			), '', $output );
1068
+			), '', $output);
1069 1069
 		}
1070 1070
 
1071 1071
 		/**
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
 						jQuery($this).data('sd-widget-enabled', true);
1136 1136
 					}
1137 1137
 
1138
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1138
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1139 1139
 					var form = jQuery($this).parents('' + $selector + '');
1140 1140
 
1141 1141
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 					});
1228 1228
 
1229 1229
 				}
1230
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1230
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1231 1231
 			</script>
1232 1232
 			<?php
1233 1233
 			$output = ob_get_clean();
@@ -1236,10 +1236,10 @@  discard block
 block discarded – undo
1236 1236
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1237 1237
 			 */
1238 1238
 
1239
-			return str_replace( array(
1239
+			return str_replace(array(
1240 1240
 				'<script>',
1241 1241
 				'</script>'
1242
-			), '', $output );
1242
+			), '', $output);
1243 1243
 		}
1244 1244
 
1245 1245
 
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
 		 *
1251 1251
 		 * @return mixed
1252 1252
 		 */
1253
-		private function add_name_from_key( $options, $arguments = false ) {
1254
-			if ( ! empty( $options['arguments'] ) ) {
1255
-				foreach ( $options['arguments'] as $key => $val ) {
1256
-					$options['arguments'][ $key ]['name'] = $key;
1253
+		private function add_name_from_key($options, $arguments = false) {
1254
+			if (!empty($options['arguments'])) {
1255
+				foreach ($options['arguments'] as $key => $val) {
1256
+					$options['arguments'][$key]['name'] = $key;
1257 1257
 				}
1258
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1259
-				foreach ( $options as $key => $val ) {
1260
-					$options[ $key ]['name'] = $key;
1258
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1259
+				foreach ($options as $key => $val) {
1260
+					$options[$key]['name'] = $key;
1261 1261
 				}
1262 1262
 			}
1263 1263
 
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 		 * @since 1.0.0
1271 1271
 		 */
1272 1272
 		public function register_shortcode() {
1273
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1274
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1273
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1274
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
1275 1275
 		}
1276 1276
 
1277 1277
 		/**
@@ -1281,33 +1281,33 @@  discard block
 block discarded – undo
1281 1281
 		 */
1282 1282
 		public static function render_shortcode() {
1283 1283
 
1284
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1285
-			if ( ! current_user_can( 'manage_options' ) ) {
1284
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1285
+			if (!current_user_can('manage_options')) {
1286 1286
 				wp_die();
1287 1287
 			}
1288 1288
 
1289 1289
 			// we might need the $post value here so lets set it.
1290
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1291
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1292
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1290
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1291
+				$post_obj = get_post(absint($_POST['post_id']));
1292
+				if (!empty($post_obj) && empty($post)) {
1293 1293
 					global $post;
1294 1294
 					$post = $post_obj;
1295 1295
 				}
1296 1296
 			}
1297 1297
 
1298
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1299
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1300
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1298
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1299
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1300
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1301 1301
 				$attributes       = '';
1302
-				if ( ! empty( $attributes_array ) ) {
1303
-					foreach ( $attributes_array as $key => $value ) {
1304
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1302
+				if (!empty($attributes_array)) {
1303
+					foreach ($attributes_array as $key => $value) {
1304
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
1305 1305
 					}
1306 1306
 				}
1307 1307
 
1308 1308
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1309 1309
 
1310
-				echo do_shortcode( $shortcode );
1310
+				echo do_shortcode($shortcode);
1311 1311
 
1312 1312
 			}
1313 1313
 			wp_die();
@@ -1321,45 +1321,45 @@  discard block
 block discarded – undo
1321 1321
 		 *
1322 1322
 		 * @return string
1323 1323
 		 */
1324
-		public function shortcode_output( $args = array(), $content = '' ) {
1325
-			$args = $this->argument_values( $args );
1324
+		public function shortcode_output($args = array(), $content = '') {
1325
+			$args = $this->argument_values($args);
1326 1326
 
1327 1327
 			// add extra argument so we know its a output to gutenberg
1328 1328
 			//$args
1329
-			$args = $this->string_to_bool( $args );
1329
+			$args = $this->string_to_bool($args);
1330 1330
 
1331 1331
 			// if we have a enclosed shortcode we add it to the special `html` argument
1332
-			if ( ! empty( $content ) ) {
1332
+			if (!empty($content)) {
1333 1333
 				$args['html'] = $content;
1334 1334
 			}
1335 1335
 
1336
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1337
-			$class .= " sdel-".$this->get_instance_hash();
1336
+			$class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1337
+			$class .= " sdel-" . $this->get_instance_hash();
1338 1338
 
1339
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1340
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1339
+			$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
1340
+			$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
1341 1341
 
1342
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1343
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); //@todo this does not seem right @kiran?
1342
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1343
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this); //@todo this does not seem right @kiran?
1344 1344
 
1345 1345
 			$shortcode_args = array();
1346 1346
 			$output         = '';
1347
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1348
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1347
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1348
+			if (isset($args['no_wrap']) && $args['no_wrap']) {
1349 1349
 				$no_wrap = true;
1350 1350
 			}
1351
-			$main_content = $this->output( $args, $shortcode_args, $content );
1352
-			if ( $main_content && ! $no_wrap ) {
1351
+			$main_content = $this->output($args, $shortcode_args, $content);
1352
+			if ($main_content && !$no_wrap) {
1353 1353
 				// wrap the shortcode in a div with the same class as the widget
1354 1354
 				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1355
-				if ( ! empty( $args['title'] ) ) {
1355
+				if (!empty($args['title'])) {
1356 1356
 					// if its a shortcode and there is a title try to grab the title wrappers
1357
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1358
-					if ( empty( $instance ) ) {
1357
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1358
+					if (empty($instance)) {
1359 1359
 						global $wp_registered_sidebars;
1360
-						if ( ! empty( $wp_registered_sidebars ) ) {
1361
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1362
-								if ( ! empty( $sidebar['before_title'] ) ) {
1360
+						if (!empty($wp_registered_sidebars)) {
1361
+							foreach ($wp_registered_sidebars as $sidebar) {
1362
+								if (!empty($sidebar['before_title'])) {
1363 1363
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1364 1364
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1365 1365
 									break;
@@ -1367,20 +1367,20 @@  discard block
 block discarded – undo
1367 1367
 							}
1368 1368
 						}
1369 1369
 					}
1370
-					$output .= $this->output_title( $shortcode_args, $args );
1370
+					$output .= $this->output_title($shortcode_args, $args);
1371 1371
 				}
1372 1372
 				$output .= $main_content;
1373 1373
 				$output .= '</div>';
1374
-			} elseif ( $main_content && $no_wrap ) {
1374
+			} elseif ($main_content && $no_wrap) {
1375 1375
 				$output .= $main_content;
1376 1376
 			}
1377 1377
 
1378 1378
 			// if preview show a placeholder if empty
1379
-			if ( $this->is_preview() && $output == '' ) {
1380
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1379
+			if ($this->is_preview() && $output == '') {
1380
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1381 1381
 			}
1382 1382
 
1383
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1383
+			return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this);
1384 1384
 		}
1385 1385
 
1386 1386
 		/**
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 		 *
1391 1391
 		 * @return string
1392 1392
 		 */
1393
-		public function preview_placeholder_text( $name = '' ) {
1394
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1393
+		public function preview_placeholder_text($name = '') {
1394
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>";
1395 1395
 		}
1396 1396
 
1397 1397
 		/**
@@ -1401,13 +1401,13 @@  discard block
 block discarded – undo
1401 1401
 		 *
1402 1402
 		 * @return mixed
1403 1403
 		 */
1404
-		public function string_to_bool( $options ) {
1404
+		public function string_to_bool($options) {
1405 1405
 			// convert bool strings to booleans
1406
-			foreach ( $options as $key => $val ) {
1407
-				if ( $val == 'false' ) {
1408
-					$options[ $key ] = false;
1409
-				} elseif ( $val == 'true' ) {
1410
-					$options[ $key ] = true;
1406
+			foreach ($options as $key => $val) {
1407
+				if ($val == 'false') {
1408
+					$options[$key] = false;
1409
+				} elseif ($val == 'true') {
1410
+					$options[$key] = true;
1411 1411
 				}
1412 1412
 			}
1413 1413
 
@@ -1423,26 +1423,26 @@  discard block
 block discarded – undo
1423 1423
 		 *
1424 1424
 		 * @return array
1425 1425
 		 */
1426
-		public function argument_values( $instance ) {
1426
+		public function argument_values($instance) {
1427 1427
 			$argument_values = array();
1428 1428
 
1429 1429
 			// set widget instance
1430 1430
 			$this->instance = $instance;
1431 1431
 
1432
-			if ( empty( $this->arguments ) ) {
1432
+			if (empty($this->arguments)) {
1433 1433
 				$this->arguments = $this->get_arguments();
1434 1434
 			}
1435 1435
 
1436
-			if ( ! empty( $this->arguments ) ) {
1437
-				foreach ( $this->arguments as $key => $args ) {
1436
+			if (!empty($this->arguments)) {
1437
+				foreach ($this->arguments as $key => $args) {
1438 1438
 					// set the input name from the key
1439 1439
 					$args['name'] = $key;
1440 1440
 					//
1441
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1442
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1441
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1442
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1443 1443
 						// don't set default for an empty checkbox
1444
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1445
-						$argument_values[ $key ] = $args['default'];
1444
+					} elseif ($argument_values[$key] == '' && isset($args['default'])) {
1445
+						$argument_values[$key] = $args['default'];
1446 1446
 					}
1447 1447
 				}
1448 1448
 			}
@@ -1469,12 +1469,12 @@  discard block
 block discarded – undo
1469 1469
 		 * @return array Get arguments.
1470 1470
 		 */
1471 1471
 		public function get_arguments() {
1472
-			if ( empty( $this->arguments ) ) {
1472
+			if (empty($this->arguments)) {
1473 1473
 				$this->arguments = $this->set_arguments();
1474 1474
 			}
1475 1475
 
1476
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1477
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1476
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1477
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1478 1478
 
1479 1479
 			return $this->arguments;
1480 1480
 		}
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 		 * @param array $widget_args
1487 1487
 		 * @param string $content
1488 1488
 		 */
1489
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1489
+		public function output($args = array(), $widget_args = array(), $content = '') {
1490 1490
 
1491 1491
 		}
1492 1492
 
@@ -1494,9 +1494,9 @@  discard block
 block discarded – undo
1494 1494
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1495 1495
 		 */
1496 1496
 		public function register_block() {
1497
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1498
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1499
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1497
+			wp_add_inline_script('wp-blocks', $this->block());
1498
+			if (class_exists('SiteOrigin_Panels')) {
1499
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1500 1500
 			}
1501 1501
 		}
1502 1502
 
@@ -1510,13 +1510,13 @@  discard block
 block discarded – undo
1510 1510
 			$show      = false;
1511 1511
 			$arguments = $this->arguments;
1512 1512
 
1513
-			if ( empty( $arguments ) ) {
1513
+			if (empty($arguments)) {
1514 1514
 				$arguments = $this->get_arguments();
1515 1515
 			}
1516 1516
 
1517
-			if ( ! empty( $arguments ) ) {
1518
-				foreach ( $arguments as $argument ) {
1519
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1517
+			if (!empty($arguments)) {
1518
+				foreach ($arguments as $argument) {
1519
+					if (isset($argument['advanced']) && $argument['advanced']) {
1520 1520
 						$show = true;
1521 1521
 						break; // no need to continue if we know we have it
1522 1522
 					}
@@ -1535,15 +1535,15 @@  discard block
 block discarded – undo
1535 1535
 
1536 1536
 			$url = $this->url;
1537 1537
 
1538
-			if ( ! $url ) {
1538
+			if (!$url) {
1539 1539
 				// check if we are inside a plugin
1540
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1540
+				$file_dir = str_replace("/includes", "", dirname(__FILE__));
1541 1541
 
1542
-				$dir_parts = explode( "/wp-content/", $file_dir );
1543
-				$url_parts = explode( "/wp-content/", plugins_url() );
1542
+				$dir_parts = explode("/wp-content/", $file_dir);
1543
+				$url_parts = explode("/wp-content/", plugins_url());
1544 1544
 
1545
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1546
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1545
+				if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1546
+					$url       = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]);
1547 1547
 					$this->url = $url;
1548 1548
 				}
1549 1549
 			}
@@ -1564,46 +1564,46 @@  discard block
 block discarded – undo
1564 1564
 		 * @since 1.1.0
1565 1565
 		 * @return string
1566 1566
 		 */
1567
-		public function get_block_icon( $icon ) {
1567
+		public function get_block_icon($icon) {
1568 1568
 
1569 1569
 			// check if we have a Font Awesome icon
1570 1570
 			$fa_type = '';
1571
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1571
+			if (substr($icon, 0, 7) === "fas fa-") {
1572 1572
 				$fa_type = 'solid';
1573
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1573
+			} elseif (substr($icon, 0, 7) === "far fa-") {
1574 1574
 				$fa_type = 'regular';
1575
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1575
+			} elseif (substr($icon, 0, 7) === "fab fa-") {
1576 1576
 				$fa_type = 'brands';
1577 1577
 			} else {
1578 1578
 				$icon = "'" . $icon . "'";
1579 1579
 			}
1580 1580
 
1581 1581
 			// set the icon if we found one
1582
-			if ( $fa_type ) {
1583
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1582
+			if ($fa_type) {
1583
+				$fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon);
1584 1584
 				$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 . "'}))";
1585 1585
 			}
1586 1586
 
1587 1587
 			return $icon;
1588 1588
 		}
1589 1589
 
1590
-		public function group_arguments( $arguments ) {
1590
+		public function group_arguments($arguments) {
1591 1591
 //			echo '###';print_r($arguments);
1592
-			if ( ! empty( $arguments ) ) {
1592
+			if (!empty($arguments)) {
1593 1593
 				$temp_arguments = array();
1594
-				$general        = __( "General" );
1594
+				$general        = __("General");
1595 1595
 				$add_sections   = false;
1596
-				foreach ( $arguments as $key => $args ) {
1597
-					if ( isset( $args['group'] ) ) {
1598
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1596
+				foreach ($arguments as $key => $args) {
1597
+					if (isset($args['group'])) {
1598
+						$temp_arguments[$args['group']][$key] = $args;
1599 1599
 						$add_sections                             = true;
1600 1600
 					} else {
1601
-						$temp_arguments[ $general ][ $key ] = $args;
1601
+						$temp_arguments[$general][$key] = $args;
1602 1602
 					}
1603 1603
 				}
1604 1604
 
1605 1605
 				// only add sections if more than one
1606
-				if ( $add_sections ) {
1606
+				if ($add_sections) {
1607 1607
 					$arguments = $temp_arguments;
1608 1608
 				}
1609 1609
 			}
@@ -1645,8 +1645,8 @@  discard block
 block discarded – undo
1645 1645
 					var prev_attributes = [];
1646 1646
 
1647 1647
 					var term_query_type = '';
1648
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
1649
-					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
1648
+					var post_type_rest_slugs = <?php if (!empty($this->arguments) && isset($this->arguments['post_type']['onchange_rest']['values'])) {echo "[" . json_encode($this->arguments['post_type']['onchange_rest']['values']) . "]"; } else {echo "[]"; } ?>;
1649
+					const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
1650 1650
 
1651 1651
 					/**
1652 1652
 					 * Register Basic Block.
@@ -1660,30 +1660,30 @@  discard block
 block discarded – undo
1660 1660
 					 * @return {?WPBlock}          The block, if it has been successfully
1661 1661
 					 *                             registered; otherwise `undefined`.
1662 1662
 					 */
1663
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1664
-						title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title.
1665
-						description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title.
1666
-						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/.
1663
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1664
+						title: '<?php echo addslashes($this->options['name']); ?>', // Block title.
1665
+						description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title.
1666
+						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/.
1667 1667
 						supports: {
1668 1668
 							<?php
1669
-							if ( isset( $this->options['block-supports'] ) ) {
1670
-								echo $this->array_to_attributes( $this->options['block-supports'] );
1669
+							if (isset($this->options['block-supports'])) {
1670
+								echo $this->array_to_attributes($this->options['block-supports']);
1671 1671
 							}
1672 1672
 							?>
1673 1673
 						},
1674
-						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.
1675
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
1674
+						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.
1675
+						<?php if (isset($this->options['block-keywords'])) {
1676 1676
 						echo "keywords : " . $this->options['block-keywords'] . ",";
1677 1677
 					}?>
1678 1678
 
1679 1679
 						<?php
1680 1680
 
1681 1681
 						// maybe set no_wrap
1682
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1683
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
1682
+						$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1683
+						if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) {
1684 1684
 							$no_wrap = true;
1685 1685
 						}
1686
-						if ( $no_wrap ) {
1686
+						if ($no_wrap) {
1687 1687
 							$this->options['block-wrap'] = '';
1688 1688
 						}
1689 1689
 
@@ -1696,10 +1696,10 @@  discard block
 block discarded – undo
1696 1696
 						echo "  html: false";
1697 1697
 						echo "},";*/
1698 1698
 
1699
-						if ( ! empty( $this->arguments ) ) {
1699
+						if (!empty($this->arguments)) {
1700 1700
 							echo "attributes : {";
1701 1701
 
1702
-							if ( $show_advanced ) {
1702
+							if ($show_advanced) {
1703 1703
 								echo "show_advanced: {";
1704 1704
 								echo "	type: 'boolean',";
1705 1705
 								echo "  default: false,";
@@ -1707,41 +1707,41 @@  discard block
 block discarded – undo
1707 1707
 							}
1708 1708
 
1709 1709
 							// block wrap element
1710
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1710
+							if (!empty($this->options['block-wrap'])) { //@todo we should validate this?
1711 1711
 								echo "block_wrap: {";
1712 1712
 								echo "	type: 'string',";
1713
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1713
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
1714 1714
 								echo "},";
1715 1715
 							}
1716 1716
 
1717
-							foreach ( $this->arguments as $key => $args ) {
1717
+							foreach ($this->arguments as $key => $args) {
1718 1718
 
1719 1719
 								// set if we should show alignment
1720
-								if ( $key == 'alignment' ) {
1720
+								if ($key == 'alignment') {
1721 1721
 									$show_alignment = true;
1722 1722
 								}
1723 1723
 
1724 1724
 								$extra = '';
1725 1725
 
1726
-								if ( $args['type'] == 'checkbox' ) {
1726
+								if ($args['type'] == 'checkbox') {
1727 1727
 									$type    = 'boolean';
1728
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1729
-								} elseif ( $args['type'] == 'number' ) {
1728
+									$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
1729
+								} elseif ($args['type'] == 'number') {
1730 1730
 									$type    = 'number';
1731
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1732
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1731
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1732
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
1733 1733
 									$type = 'array';
1734
-									if ( is_array( $args['default'] ) ) {
1735
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1734
+									if (is_array($args['default'])) {
1735
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
1736 1736
 									} else {
1737
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1737
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1738 1738
 									}
1739
-								} elseif ( $args['type'] == 'multiselect' ) {
1739
+								} elseif ($args['type'] == 'multiselect') {
1740 1740
 									$type    = 'array';
1741
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1741
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1742 1742
 								} else {
1743 1743
 									$type    = 'string';
1744
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1744
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1745 1745
 								}
1746 1746
 								echo $key . " : {";
1747 1747
 								echo "type : '$type',";
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 
1766 1766
 							<?php
1767 1767
 							// if we have a post_type and a category then link them
1768
-							if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked']) ){
1768
+							if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && isset($this->arguments['category']['post_type_linked'])) {
1769 1769
 							?>
1770 1770
 							if(typeof(prev_attributes[props.id]) != 'undefined' ){
1771 1771
 								$pt = props.attributes.post_type;
@@ -1774,13 +1774,13 @@  discard block
 block discarded – undo
1774 1774
 								}
1775 1775
 								if('post_type' in prev_attributes[props.id] && 'category' in prev_attributes[props.id] && $pt != term_query_type ){
1776 1776
 									term_query_type = $pt;
1777
-									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories';} ?>"}).then(terms => {
1778
-										while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
1779
-										taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
1777
+									wp.apiFetch({path: "<?php if (isset($this->arguments['post_type']['onchange_rest']['path'])) {echo $this->arguments['post_type']['onchange_rest']['path']; } else {'/wp/v2/"+$value+"/categories'; } ?>"}).then(terms => {
1778
+										while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
1779
+										taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
1780 1780
 									}
1781
-									taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
1781
+									taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
1782 1782
 									jQuery.each( terms, function( key, val ) {
1783
-										taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
1783
+										taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
1784 1784
 									});
1785 1785
 
1786 1786
 									// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 									props.setAttributes({category: [0] });
1789 1789
 									props.setAttributes({category: $old_cat_value });
1790 1790
 
1791
-									return taxonomies_<?php echo str_replace("-","_", $this->id);?>;
1791
+									return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>;
1792 1792
 								});
1793 1793
 								}
1794 1794
 							}
@@ -1814,12 +1814,12 @@  discard block
 block discarded – undo
1814 1814
 									is_fetching = true;
1815 1815
 									var data = {
1816 1816
 										'action': 'super_duper_output_shortcode',
1817
-										'shortcode': '<?php echo $this->options['base_id'];?>',
1817
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
1818 1818
 										'attributes': props.attributes,
1819
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1819
+										'post_id': <?php global $post; if (isset($post->ID)) {
1820 1820
 										echo $post->ID;
1821 1821
 									}?>,
1822
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1822
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
1823 1823
 									};
1824 1824
 
1825 1825
 									jQuery.post(ajaxurl, data, function (response) {
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 
1829 1829
 										// if the content is empty then we place some placeholder text
1830 1830
 										if (env == '') {
1831
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>";
1831
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>";
1832 1832
 										}
1833 1833
 
1834 1834
 										props.setAttributes({content: env});
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
 
1853 1853
 								el(wp.blockEditor.BlockControls, {key: 'controls'},
1854 1854
 
1855
-									<?php if($show_alignment){?>
1855
+									<?php if ($show_alignment) {?>
1856 1856
 									el(
1857 1857
 										wp.blockEditor.AlignmentToolbar,
1858 1858
 										{
@@ -1870,9 +1870,9 @@  discard block
 block discarded – undo
1870 1870
 
1871 1871
 									<?php
1872 1872
 
1873
-									if(! empty( $this->arguments )){
1873
+									if (!empty($this->arguments)) {
1874 1874
 
1875
-									if ( $show_advanced ) {
1875
+									if ($show_advanced) {
1876 1876
 									?>
1877 1877
 									el('div', {
1878 1878
 											style: {'padding-left': '16px','padding-right': '16px'}
@@ -1893,19 +1893,19 @@  discard block
 block discarded – undo
1893 1893
 
1894 1894
 									}
1895 1895
 
1896
-									$arguments = $this->group_arguments( $this->arguments );
1896
+									$arguments = $this->group_arguments($this->arguments);
1897 1897
 
1898 1898
 									// Do we have sections?
1899 1899
 									$has_sections = $arguments == $this->arguments ? false : true;
1900 1900
 
1901 1901
 
1902
-									if($has_sections){
1902
+									if ($has_sections) {
1903 1903
 									$panel_count = 0;
1904
-									foreach($arguments as $key => $args){
1904
+									foreach ($arguments as $key => $args) {
1905 1905
 									?>
1906 1906
 									el(wp.components.PanelBody, {
1907
-											title: '<?php esc_attr_e( $key ); ?>',
1908
-											initialOpen: <?php if ( $panel_count ) {
1907
+											title: '<?php esc_attr_e($key); ?>',
1908
+											initialOpen: <?php if ($panel_count) {
1909 1909
 											echo "false";
1910 1910
 										} else {
1911 1911
 											echo "true";
@@ -1913,24 +1913,24 @@  discard block
 block discarded – undo
1913 1913
 										},
1914 1914
 										<?php
1915 1915
 
1916
-										foreach ( $args as $k => $a ) {
1917
-											$this->build_block_arguments( $k, $a );
1916
+										foreach ($args as $k => $a) {
1917
+											$this->build_block_arguments($k, $a);
1918 1918
 										}
1919 1919
 										?>
1920 1920
 									),
1921 1921
 									<?php
1922
-									$panel_count ++;
1922
+									$panel_count++;
1923 1923
 
1924 1924
 									}
1925
-									}else {
1925
+									} else {
1926 1926
 									?>
1927 1927
 									el(wp.components.PanelBody, {
1928
-											title: '<?php esc_attr_e( "Settings" ); ?>',
1928
+											title: '<?php esc_attr_e("Settings"); ?>',
1929 1929
 											initialOpen: true
1930 1930
 										},
1931 1931
 										<?php
1932
-										foreach ( $this->arguments as $key => $args ) {
1933
-											$this->build_block_arguments( $key, $args );
1932
+										foreach ($this->arguments as $key => $args) {
1933
+											$this->build_block_arguments($key, $args);
1934 1934
 										}
1935 1935
 										?>
1936 1936
 									),
@@ -1944,9 +1944,9 @@  discard block
 block discarded – undo
1944 1944
 
1945 1945
 								<?php
1946 1946
 								// If the user sets block-output array then build it
1947
-								if ( ! empty( $this->options['block-output'] ) ) {
1948
-								$this->block_element( $this->options['block-output'] );
1949
-							}else{
1947
+								if (!empty($this->options['block-output'])) {
1948
+								$this->block_element($this->options['block-output']);
1949
+							} else {
1950 1950
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1951 1951
 								?>
1952 1952
 								el('div', {
@@ -1970,19 +1970,19 @@  discard block
 block discarded – undo
1970 1970
 							var align = '';
1971 1971
 
1972 1972
 							// build the shortcode.
1973
-							var content = "[<?php echo $this->options['base_id'];?>";
1973
+							var content = "[<?php echo $this->options['base_id']; ?>";
1974 1974
 							$html = '';
1975 1975
 							<?php
1976 1976
 
1977
-							if(! empty( $this->arguments )){
1977
+							if (!empty($this->arguments)) {
1978 1978
 
1979
-							foreach($this->arguments as $key => $args){
1979
+							foreach ($this->arguments as $key => $args) {
1980 1980
 							?>
1981
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1982
-								if ('<?php echo esc_attr( $key );?>' == 'html') {
1983
-									$html = attr.<?php echo esc_attr( $key );?>;
1981
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1982
+								if ('<?php echo esc_attr($key); ?>' == 'html') {
1983
+									$html = attr.<?php echo esc_attr($key); ?>;
1984 1984
 								} else {
1985
-									content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1985
+									content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1986 1986
 								}
1987 1987
 							}
1988 1988
 							<?php
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
 							// if has html element
1996 1996
 							if ($html) {
1997
-								content += $html + "[/<?php echo $this->options['base_id'];?>]";
1997
+								content += $html + "[/<?php echo $this->options['base_id']; ?>]";
1998 1998
 							}
1999 1999
 
2000 2000
 
@@ -2012,11 +2012,11 @@  discard block
 block discarded – undo
2012 2012
 							}
2013 2013
 
2014 2014
 							<?php
2015
-							if(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
2015
+							if (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') {
2016 2016
 							?>
2017 2017
 							return content;
2018 2018
 							<?php
2019
-							}else{
2019
+							} else {
2020 2020
 							?>
2021 2021
 							var block_wrap = 'div';
2022 2022
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -2039,38 +2039,38 @@  discard block
 block discarded – undo
2039 2039
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
2040 2040
 			 */
2041 2041
 
2042
-			return str_replace( array(
2042
+			return str_replace(array(
2043 2043
 				'<script>',
2044 2044
 				'</script>'
2045
-			), '', $output );
2045
+			), '', $output);
2046 2046
 		}
2047 2047
 
2048
-		public function build_block_arguments( $key, $args ) {
2049
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
2048
+		public function build_block_arguments($key, $args) {
2049
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
2050 2050
 			$options           = '';
2051 2051
 			$extra             = '';
2052 2052
 			$require           = '';
2053 2053
 
2054 2054
 			// `content` is a protected and special argument
2055
-			if ( $key == 'content' ) {
2055
+			if ($key == 'content') {
2056 2056
 				return;
2057 2057
 			}
2058 2058
 
2059 2059
 			// require advanced
2060
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
2060
+			$require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : "";
2061 2061
 
2062 2062
 			// element require
2063
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
2063
+			$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
2064 2064
 
2065 2065
 
2066 2066
 			$onchange  = "props.setAttributes({ $key: $key } )";
2067
-			$onchangecomplete  = "";
2067
+			$onchangecomplete = "";
2068 2068
 			$value     = "props.attributes.$key";
2069
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx' );
2070
-			if ( in_array( $args['type'], $text_type ) ) {
2069
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx');
2070
+			if (in_array($args['type'], $text_type)) {
2071 2071
 				$type = 'TextControl';
2072 2072
 				// Save numbers as numbers and not strings
2073
-				if ( $args['type'] == 'number' ) {
2073
+				if ($args['type'] == 'number') {
2074 2074
 					$onchange = "props.setAttributes({ $key: Number($key) } )";
2075 2075
 				}
2076 2076
 			}
@@ -2108,11 +2108,11 @@  discard block
 block discarded – undo
2108 2108
 				return;
2109 2109
 			}
2110 2110
 */
2111
-			elseif ( $args['type'] == 'color' ) {
2111
+			elseif ($args['type'] == 'color') {
2112 2112
 				$type = 'ColorPicker';
2113 2113
 				$onchange = "";
2114 2114
 				$extra = "color: $value,";
2115
-				if(!empty($args['disable_alpha'])){
2115
+				if (!empty($args['disable_alpha'])) {
2116 2116
 					$extra .= "disableAlpha: true,";
2117 2117
 				}
2118 2118
 				$onchangecomplete = "onChangeComplete: function($key) {
@@ -2122,45 +2122,45 @@  discard block
 block discarded – undo
2122 2122
                         });
2123 2123
                     },";
2124 2124
 			}
2125
-			elseif ( $args['type'] == 'checkbox' ) {
2125
+			elseif ($args['type'] == 'checkbox') {
2126 2126
 				$type = 'CheckboxControl';
2127 2127
 				$extra .= "checked: props.attributes.$key,";
2128 2128
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
2129
-			} elseif ( $args['type'] == 'textarea' ) {
2129
+			} elseif ($args['type'] == 'textarea') {
2130 2130
 				$type = 'TextareaControl';
2131
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
2131
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
2132 2132
 				$type = 'SelectControl';
2133 2133
 
2134
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
2135
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
2136
-				}else {
2134
+				if ($args['name'] == 'category' && !empty($args['post_type_linked'])) {
2135
+					$options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ",";
2136
+				} else {
2137 2137
 
2138
-					if ( ! empty( $args['options'] ) ) {
2138
+					if (!empty($args['options'])) {
2139 2139
 						$options .= "options: [";
2140
-						foreach ( $args['options'] as $option_val => $option_label ) {
2141
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . addslashes( $option_label ) . "' },";
2140
+						foreach ($args['options'] as $option_val => $option_label) {
2141
+							$options .= "{ value: '" . esc_attr($option_val) . "', label: '" . addslashes($option_label) . "' },";
2142 2142
 						}
2143 2143
 						$options .= "],";
2144 2144
 					}
2145 2145
 				}
2146
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
2146
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
2147 2147
 					$extra .= ' multiple: true, ';
2148 2148
 				}
2149
-			} elseif ( $args['type'] == 'alignment' ) {
2149
+			} elseif ($args['type'] == 'alignment') {
2150 2150
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
2151 2151
 			} else {
2152
-				return;// if we have not implemented the control then don't break the JS.
2152
+				return; // if we have not implemented the control then don't break the JS.
2153 2153
 			}
2154 2154
 
2155 2155
 
2156 2156
 
2157 2157
 			// color input does not show the labels so we add them
2158
-			if($args['type']=='color'){
2158
+			if ($args['type'] == 'color') {
2159 2159
 				// add show only if advanced
2160 2160
 				echo $require_advanced;
2161 2161
 				// add setting require if defined
2162 2162
 				echo $element_require;
2163
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
2163
+				echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),";
2164 2164
 			}
2165 2165
 
2166 2166
 			// add show only if advanced
@@ -2169,21 +2169,21 @@  discard block
 block discarded – undo
2169 2169
 			echo $element_require;
2170 2170
 			?>
2171 2171
 			el( wp.components.<?php echo $type; ?>, {
2172
-			label: '<?php echo addslashes( $args['title'] ); ?>',
2173
-			help: '<?php if ( isset( $args['desc'] ) ) {
2174
-				echo addslashes( $args['desc'] );
2172
+			label: '<?php echo addslashes($args['title']); ?>',
2173
+			help: '<?php if (isset($args['desc'])) {
2174
+				echo addslashes($args['desc']);
2175 2175
 			} ?>',
2176 2176
 			value: <?php echo $value; ?>,
2177
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
2178
-				echo "type: '" . addslashes( $args['type'] ) . "',";
2177
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
2178
+				echo "type: '" . addslashes($args['type']) . "',";
2179 2179
 			} ?>
2180
-			<?php if ( ! empty( $args['placeholder'] ) ) {
2181
-				echo "placeholder: '" . addslashes( $args['placeholder'] ) . "',";
2180
+			<?php if (!empty($args['placeholder'])) {
2181
+				echo "placeholder: '" . addslashes($args['placeholder']) . "',";
2182 2182
 			} ?>
2183 2183
 			<?php echo $options; ?>
2184 2184
 			<?php echo $extra; ?>
2185 2185
 			<?php echo $custom_attributes; ?>
2186
-			<?php echo $onchangecomplete;?>
2186
+			<?php echo $onchangecomplete; ?>
2187 2187
 			onChange: function ( <?php echo $key; ?> ) {
2188 2188
 			<?php echo $onchange; ?>
2189 2189
 			}
@@ -2201,16 +2201,16 @@  discard block
 block discarded – undo
2201 2201
 		 *
2202 2202
 		 * @return string
2203 2203
 		 */
2204
-		public function array_to_attributes( $custom_attributes, $html = false ) {
2204
+		public function array_to_attributes($custom_attributes, $html = false) {
2205 2205
 			$attributes = '';
2206
-			if ( ! empty( $custom_attributes ) ) {
2206
+			if (!empty($custom_attributes)) {
2207 2207
 
2208
-				if ( $html ) {
2209
-					foreach ( $custom_attributes as $key => $val ) {
2208
+				if ($html) {
2209
+					foreach ($custom_attributes as $key => $val) {
2210 2210
 						$attributes .= " $key='$val' ";
2211 2211
 					}
2212 2212
 				} else {
2213
-					foreach ( $custom_attributes as $key => $val ) {
2213
+					foreach ($custom_attributes as $key => $val) {
2214 2214
 						$attributes .= "'$key': '$val',";
2215 2215
 					}
2216 2216
 				}
@@ -2226,86 +2226,86 @@  discard block
 block discarded – undo
2226 2226
 		 *
2227 2227
 		 * @param $args
2228 2228
 		 */
2229
-		public function block_element( $args ) {
2229
+		public function block_element($args) {
2230 2230
 
2231 2231
 
2232
-			if ( ! empty( $args ) ) {
2233
-				foreach ( $args as $element => $new_args ) {
2232
+			if (!empty($args)) {
2233
+				foreach ($args as $element => $new_args) {
2234 2234
 
2235
-					if ( is_array( $new_args ) ) { // its an element
2235
+					if (is_array($new_args)) { // its an element
2236 2236
 
2237 2237
 
2238
-						if ( isset( $new_args['element'] ) ) {
2238
+						if (isset($new_args['element'])) {
2239 2239
 
2240
-							if ( isset( $new_args['element_require'] ) ) {
2241
-								echo str_replace( array(
2240
+							if (isset($new_args['element_require'])) {
2241
+								echo str_replace(array(
2242 2242
 										"'+",
2243 2243
 										"+'"
2244
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
2245
-								unset( $new_args['element_require'] );
2244
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
2245
+								unset($new_args['element_require']);
2246 2246
 							}
2247 2247
 
2248 2248
 							echo "\n el( '" . $new_args['element'] . "', {";
2249 2249
 
2250 2250
 							// get the attributes
2251
-							foreach ( $new_args as $new_key => $new_value ) {
2251
+							foreach ($new_args as $new_key => $new_value) {
2252 2252
 
2253 2253
 
2254
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
2254
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
2255 2255
 									// do nothing
2256 2256
 								} else {
2257
-									echo $this->block_element( array( $new_key => $new_value ) );
2257
+									echo $this->block_element(array($new_key => $new_value));
2258 2258
 								}
2259 2259
 							}
2260 2260
 
2261
-							echo "},";// end attributes
2261
+							echo "},"; // end attributes
2262 2262
 
2263 2263
 							// get the content
2264 2264
 							$first_item = 0;
2265
-							foreach ( $new_args as $new_key => $new_value ) {
2266
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
2265
+							foreach ($new_args as $new_key => $new_value) {
2266
+								if ($new_key === 'content' || is_array($new_value)) {
2267 2267
 
2268
-									if ( $new_key === 'content' ) {
2269
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
2268
+									if ($new_key === 'content') {
2269
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
2270 2270
 									}
2271 2271
 
2272
-									if ( is_array( $new_value ) ) {
2272
+									if (is_array($new_value)) {
2273 2273
 
2274
-										if ( isset( $new_value['element_require'] ) ) {
2275
-											echo str_replace( array(
2274
+										if (isset($new_value['element_require'])) {
2275
+											echo str_replace(array(
2276 2276
 													"'+",
2277 2277
 													"+'"
2278
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
2279
-											unset( $new_value['element_require'] );
2278
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
2279
+											unset($new_value['element_require']);
2280 2280
 										}
2281 2281
 
2282
-										if ( isset( $new_value['element_repeat'] ) ) {
2282
+										if (isset($new_value['element_repeat'])) {
2283 2283
 											$x = 1;
2284
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
2285
-												$this->block_element( array( '' => $new_value ) );
2286
-												$x ++;
2284
+											while ($x <= absint($new_value['element_repeat'])) {
2285
+												$this->block_element(array('' => $new_value));
2286
+												$x++;
2287 2287
 											}
2288 2288
 										} else {
2289
-											$this->block_element( array( '' => $new_value ) );
2289
+											$this->block_element(array('' => $new_value));
2290 2290
 										}
2291 2291
 									}
2292
-									$first_item ++;
2292
+									$first_item++;
2293 2293
 								}
2294 2294
 							}
2295 2295
 
2296
-							echo ")";// end content
2296
+							echo ")"; // end content
2297 2297
 
2298 2298
 							echo ", \n";
2299 2299
 
2300 2300
 						}
2301 2301
 					} else {
2302 2302
 
2303
-						if ( substr( $element, 0, 3 ) === "if_" ) {
2304
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
2305
-						} elseif ( $element == 'style' ) {
2306
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
2303
+						if (substr($element, 0, 3) === "if_") {
2304
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
2305
+						} elseif ($element == 'style') {
2306
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
2307 2307
 						} else {
2308
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
2308
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
2309 2309
 						}
2310 2310
 
2311 2311
 					}
@@ -2320,12 +2320,12 @@  discard block
 block discarded – undo
2320 2320
 		 *
2321 2321
 		 * @return mixed
2322 2322
 		 */
2323
-		public function block_props_replace( $string, $no_wrap = false ) {
2323
+		public function block_props_replace($string, $no_wrap = false) {
2324 2324
 
2325
-			if ( $no_wrap ) {
2326
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
2325
+			if ($no_wrap) {
2326
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
2327 2327
 			} else {
2328
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
2328
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
2329 2329
 			}
2330 2330
 
2331 2331
 			return $string;
@@ -2337,55 +2337,55 @@  discard block
 block discarded – undo
2337 2337
 		 * @param array $args
2338 2338
 		 * @param array $instance
2339 2339
 		 */
2340
-		public function widget( $args, $instance ) {
2340
+		public function widget($args, $instance) {
2341 2341
 
2342 2342
 			// get the filtered values
2343
-			$argument_values = $this->argument_values( $instance );
2344
-			$argument_values = $this->string_to_bool( $argument_values );
2345
-			$output          = $this->output( $argument_values, $args );
2343
+			$argument_values = $this->argument_values($instance);
2344
+			$argument_values = $this->string_to_bool($argument_values);
2345
+			$output          = $this->output($argument_values, $args);
2346 2346
 
2347 2347
 			$no_wrap = false;
2348
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
2348
+			if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) {
2349 2349
 				$no_wrap = true;
2350 2350
 			}
2351 2351
 
2352 2352
 			ob_start();
2353
-			if ( $output && ! $no_wrap ) {
2353
+			if ($output && !$no_wrap) {
2354 2354
 
2355 2355
 				$class_original = $this->options['widget_ops']['classname'];
2356
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
2356
+				$class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash();
2357 2357
 
2358 2358
 				// Before widget
2359 2359
 				$before_widget = $args['before_widget'];
2360
-				$before_widget = str_replace($class_original,$class,$before_widget);
2361
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
2362
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
2360
+				$before_widget = str_replace($class_original, $class, $before_widget);
2361
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
2362
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
2363 2363
 
2364 2364
 				// After widget
2365 2365
 				$after_widget = $args['after_widget'];
2366
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
2367
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
2366
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
2367
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
2368 2368
 
2369 2369
 				echo $before_widget;
2370 2370
 				// elementor strips the widget wrapping div so we check for and add it back if needed
2371
-				if ( $this->is_elementor_widget_output() ) {
2372
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $class  ) . "'>" : '';
2371
+				if ($this->is_elementor_widget_output()) {
2372
+					echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($class) . "'>" : '';
2373 2373
 				}
2374
-				echo $this->output_title( $args, $instance );
2374
+				echo $this->output_title($args, $instance);
2375 2375
 				echo $output;
2376
-				if ( $this->is_elementor_widget_output() ) {
2377
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
2376
+				if ($this->is_elementor_widget_output()) {
2377
+					echo !empty($this->options['widget_ops']['classname']) ? "</span>" : '';
2378 2378
 				}
2379 2379
 				echo $after_widget;
2380
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
2381
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
2380
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
2381
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
2382 2382
 				echo $output;
2383
-			} elseif ( $output && $no_wrap ) {
2383
+			} elseif ($output && $no_wrap) {
2384 2384
 				echo $output;
2385 2385
 			}
2386 2386
 			$output = ob_get_clean();
2387 2387
 
2388
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
2388
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
2389 2389
 
2390 2390
 			echo $output;
2391 2391
 		}
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 		 */
2399 2399
 		public function is_elementor_widget_output() {
2400 2400
 			$result = false;
2401
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
2401
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
2402 2402
 				$result = true;
2403 2403
 			}
2404 2404
 
@@ -2413,7 +2413,7 @@  discard block
 block discarded – undo
2413 2413
 		 */
2414 2414
 		public function is_elementor_preview() {
2415 2415
 			$result = false;
2416
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
2416
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
2417 2417
 				$result = true;
2418 2418
 			}
2419 2419
 
@@ -2428,7 +2428,7 @@  discard block
 block discarded – undo
2428 2428
 		 */
2429 2429
 		public function is_divi_preview() {
2430 2430
 			$result = false;
2431
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
2431
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
2432 2432
 				$result = true;
2433 2433
 			}
2434 2434
 
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
 		 */
2444 2444
 		public function is_beaver_preview() {
2445 2445
 			$result = false;
2446
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
2446
+			if (isset($_REQUEST['fl_builder'])) {
2447 2447
 				$result = true;
2448 2448
 			}
2449 2449
 
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
 		 */
2459 2459
 		public function is_siteorigin_preview() {
2460 2460
 			$result = false;
2461
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
2461
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
2462 2462
 				$result = true;
2463 2463
 			}
2464 2464
 
@@ -2473,7 +2473,7 @@  discard block
 block discarded – undo
2473 2473
 		 */
2474 2474
 		public function is_cornerstone_preview() {
2475 2475
 			$result = false;
2476
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
2476
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
2477 2477
 				$result = true;
2478 2478
 			}
2479 2479
 
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 		 */
2489 2489
 		public function is_fusion_preview() {
2490 2490
 			$result = false;
2491
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
2491
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
2492 2492
 				$result = true;
2493 2493
 			}
2494 2494
 
@@ -2503,7 +2503,7 @@  discard block
 block discarded – undo
2503 2503
 		 */
2504 2504
 		public function is_oxygen_preview() {
2505 2505
 			$result = false;
2506
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
2506
+			if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) {
2507 2507
 				$result = true;
2508 2508
 			}
2509 2509
 
@@ -2518,21 +2518,21 @@  discard block
 block discarded – undo
2518 2518
 		 */
2519 2519
 		public function is_preview() {
2520 2520
 			$preview = false;
2521
-			if ( $this->is_divi_preview() ) {
2521
+			if ($this->is_divi_preview()) {
2522 2522
 				$preview = true;
2523
-			} elseif ( $this->is_elementor_preview() ) {
2523
+			} elseif ($this->is_elementor_preview()) {
2524 2524
 				$preview = true;
2525
-			} elseif ( $this->is_beaver_preview() ) {
2525
+			} elseif ($this->is_beaver_preview()) {
2526 2526
 				$preview = true;
2527
-			} elseif ( $this->is_siteorigin_preview() ) {
2527
+			} elseif ($this->is_siteorigin_preview()) {
2528 2528
 				$preview = true;
2529
-			} elseif ( $this->is_cornerstone_preview() ) {
2529
+			} elseif ($this->is_cornerstone_preview()) {
2530 2530
 				$preview = true;
2531
-			} elseif ( $this->is_fusion_preview() ) {
2531
+			} elseif ($this->is_fusion_preview()) {
2532 2532
 				$preview = true;
2533
-			} elseif ( $this->is_oxygen_preview() ) {
2533
+			} elseif ($this->is_oxygen_preview()) {
2534 2534
 				$preview = true;
2535
-			} elseif( $this->is_block_content_call() ) {
2535
+			} elseif ($this->is_block_content_call()) {
2536 2536
 				$preview = true;
2537 2537
 			}
2538 2538
 
@@ -2547,11 +2547,11 @@  discard block
 block discarded – undo
2547 2547
 		 *
2548 2548
 		 * @return string
2549 2549
 		 */
2550
-		public function output_title( $args, $instance = array() ) {
2550
+		public function output_title($args, $instance = array()) {
2551 2551
 			$output = '';
2552
-			if ( ! empty( $instance['title'] ) ) {
2552
+			if (!empty($instance['title'])) {
2553 2553
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2554
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2554
+				$title  = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
2555 2555
 				$output = $args['before_title'] . $title . $args['after_title'];
2556 2556
 			}
2557 2557
 
@@ -2563,7 +2563,7 @@  discard block
 block discarded – undo
2563 2563
 		 *
2564 2564
 		 * @param array $instance The widget options.
2565 2565
 		 */
2566
-		public function form( $instance ) {
2566
+		public function form($instance) {
2567 2567
 
2568 2568
 			// set widget instance
2569 2569
 			$this->instance = $instance;
@@ -2571,20 +2571,20 @@  discard block
 block discarded – undo
2571 2571
 			// set it as a SD widget
2572 2572
 			echo $this->widget_advanced_toggle();
2573 2573
 
2574
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2574
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
2575 2575
 			$arguments_raw = $this->get_arguments();
2576 2576
 
2577
-			if ( is_array( $arguments_raw ) ) {
2577
+			if (is_array($arguments_raw)) {
2578 2578
 
2579
-				$arguments = $this->group_arguments( $arguments_raw );
2579
+				$arguments = $this->group_arguments($arguments_raw);
2580 2580
 
2581 2581
 				// Do we have sections?
2582 2582
 				$has_sections = $arguments == $arguments_raw ? false : true;
2583 2583
 
2584 2584
 
2585
-				if ( $has_sections ) {
2585
+				if ($has_sections) {
2586 2586
 					$panel_count = 0;
2587
-					foreach ( $arguments as $key => $args ) {
2587
+					foreach ($arguments as $key => $args) {
2588 2588
 
2589 2589
 						?>
2590 2590
 						<script>
@@ -2594,21 +2594,21 @@  discard block
 block discarded – undo
2594 2594
 
2595 2595
 						$hide       = $panel_count ? ' style="display:none;" ' : '';
2596 2596
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
2597
-						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>";
2598
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
2597
+						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>";
2598
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
2599 2599
 
2600
-						foreach ( $args as $k => $a ) {
2601
-							$this->widget_inputs( $a, $instance );
2600
+						foreach ($args as $k => $a) {
2601
+							$this->widget_inputs($a, $instance);
2602 2602
 						}
2603 2603
 
2604 2604
 						echo "</div>";
2605 2605
 
2606
-						$panel_count ++;
2606
+						$panel_count++;
2607 2607
 
2608 2608
 					}
2609 2609
 				} else {
2610
-					foreach ( $arguments as $key => $args ) {
2611
-						$this->widget_inputs( $args, $instance );
2610
+					foreach ($arguments as $key => $args) {
2611
+						$this->widget_inputs($args, $instance);
2612 2612
 					}
2613 2613
 				}
2614 2614
 
@@ -2623,7 +2623,7 @@  discard block
 block discarded – undo
2623 2623
 		public function widget_advanced_toggle() {
2624 2624
 
2625 2625
 			$output = '';
2626
-			if ( $this->block_show_advanced() ) {
2626
+			if ($this->block_show_advanced()) {
2627 2627
 				$val = 1;
2628 2628
 			} else {
2629 2629
 				$val = 0;
@@ -2643,14 +2643,14 @@  discard block
 block discarded – undo
2643 2643
 		 *
2644 2644
 		 * @return string $output
2645 2645
 		 */
2646
-		public function convert_element_require( $input ) {
2646
+		public function convert_element_require($input) {
2647 2647
 
2648
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2648
+			$input = str_replace("'", '"', $input); // we only want double quotes
2649 2649
 
2650
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2650
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
2651 2651
 				"jQuery(form).find('[data-argument=\"",
2652 2652
 				"\"]').find('input,select,textarea').val()"
2653
-			), $input ) );
2653
+			), $input));
2654 2654
 
2655 2655
 			return $output;
2656 2656
 		}
@@ -2661,54 +2661,54 @@  discard block
 block discarded – undo
2661 2661
 		 * @param $args
2662 2662
 		 * @param $instance
2663 2663
 		 */
2664
-		public function widget_inputs( $args, $instance ) {
2664
+		public function widget_inputs($args, $instance) {
2665 2665
 
2666 2666
 			$class             = "";
2667 2667
 			$element_require   = "";
2668 2668
 			$custom_attributes = "";
2669 2669
 
2670 2670
 			// get value
2671
-			if ( isset( $instance[ $args['name'] ] ) ) {
2672
-				$value = $instance[ $args['name'] ];
2673
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2674
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2671
+			if (isset($instance[$args['name']])) {
2672
+				$value = $instance[$args['name']];
2673
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
2674
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
2675 2675
 			} else {
2676 2676
 				$value = '';
2677 2677
 			}
2678 2678
 
2679 2679
 			// get placeholder
2680
-			if ( ! empty( $args['placeholder'] ) ) {
2681
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2680
+			if (!empty($args['placeholder'])) {
2681
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
2682 2682
 			} else {
2683 2683
 				$placeholder = '';
2684 2684
 			}
2685 2685
 
2686 2686
 			// get if advanced
2687
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2687
+			if (isset($args['advanced']) && $args['advanced']) {
2688 2688
 				$class .= " sd-advanced-setting ";
2689 2689
 			}
2690 2690
 
2691 2691
 			// element_require
2692
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2692
+			if (isset($args['element_require']) && $args['element_require']) {
2693 2693
 				$element_require = $args['element_require'];
2694 2694
 			}
2695 2695
 
2696 2696
 			// custom_attributes
2697
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2698
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2697
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
2698
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
2699 2699
 			}
2700 2700
 
2701 2701
 			// before wrapper
2702 2702
 			?>
2703
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2704
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2705
-			   data-element_require='<?php if ( $element_require ) {
2706
-				   echo $this->convert_element_require( $element_require );
2703
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
2704
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
2705
+			   data-element_require='<?php if ($element_require) {
2706
+				   echo $this->convert_element_require($element_require);
2707 2707
 			   } ?>'
2708 2708
 			>
2709 2709
 				<?php
2710 2710
 
2711
-				switch ( $args['type'] ) {
2711
+				switch ($args['type']) {
2712 2712
 					//array('text','password','number','email','tel','url','color')
2713 2713
 					case "text":
2714 2714
 					case "password":
@@ -2719,46 +2719,46 @@  discard block
 block discarded – undo
2719 2719
 					case "color":
2720 2720
 						?>
2721 2721
 						<label
2722
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2722
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2723 2723
 						<input <?php echo $placeholder; ?> class="widefat"
2724 2724
 							<?php echo $custom_attributes; ?>
2725
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2726
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
2727
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
2728
-							                               value="<?php echo esc_attr( $value ); ?>">
2725
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2726
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
2727
+							                               type="<?php echo esc_attr($args['type']); ?>"
2728
+							                               value="<?php echo esc_attr($value); ?>">
2729 2729
 						<?php
2730 2730
 
2731 2731
 						break;
2732 2732
 					case "select":
2733
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2734
-						if ( $multiple ) {
2735
-							if ( empty( $value ) ) {
2733
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
2734
+						if ($multiple) {
2735
+							if (empty($value)) {
2736 2736
 								$value = array();
2737 2737
 							}
2738 2738
 						}
2739 2739
 						?>
2740 2740
 						<label
2741
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2741
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2742 2742
 						<select <?php echo $placeholder; ?> class="widefat"
2743 2743
 							<?php echo $custom_attributes; ?>
2744
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2745
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2746
-							                                if ( $multiple ) {
2744
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2745
+							                                name="<?php echo esc_attr($this->get_field_name($args['name']));
2746
+							                                if ($multiple) {
2747 2747
 								                                echo "[]";
2748 2748
 							                                } ?>"
2749
-							<?php if ( $multiple ) {
2749
+							<?php if ($multiple) {
2750 2750
 								echo "multiple";
2751 2751
 							} //@todo not implemented yet due to gutenberg not supporting it
2752 2752
 							?>
2753 2753
 						>
2754 2754
 							<?php
2755 2755
 
2756
-							if ( ! empty( $args['options'] ) ) {
2757
-								foreach ( $args['options'] as $val => $label ) {
2758
-									if ( $multiple ) {
2759
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2756
+							if (!empty($args['options'])) {
2757
+								foreach ($args['options'] as $val => $label) {
2758
+									if ($multiple) {
2759
+										$selected = in_array($val, $value) ? 'selected="selected"' : '';
2760 2760
 									} else {
2761
-										$selected = selected( $value, $val, false );
2761
+										$selected = selected($value, $val, false);
2762 2762
 									}
2763 2763
 									echo "<option value='$val' " . $selected . ">$label</option>";
2764 2764
 								}
@@ -2770,32 +2770,32 @@  discard block
 block discarded – undo
2770 2770
 					case "checkbox":
2771 2771
 						?>
2772 2772
 						<input <?php echo $placeholder; ?>
2773
-							<?php checked( 1, $value, true ) ?>
2773
+							<?php checked(1, $value, true) ?>
2774 2774
 							<?php echo $custom_attributes; ?>
2775
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2776
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
2775
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2776
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
2777 2777
 							value="1">
2778 2778
 						<label
2779
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2779
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2780 2780
 						<?php
2781 2781
 						break;
2782 2782
 					case "textarea":
2783 2783
 						?>
2784 2784
 						<label
2785
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2785
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2786 2786
 						<textarea <?php echo $placeholder; ?> class="widefat"
2787 2787
 							<?php echo $custom_attributes; ?>
2788
-							                                  id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2789
-							                                  name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
2790
-						><?php echo esc_attr( $value ); ?></textarea>
2788
+							                                  id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2789
+							                                  name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
2790
+						><?php echo esc_attr($value); ?></textarea>
2791 2791
 						<?php
2792 2792
 
2793 2793
 						break;
2794 2794
 					case "hidden":
2795 2795
 						?>
2796
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2797
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2798
-						       value="<?php echo esc_attr( $value ); ?>">
2796
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2797
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
2798
+						       value="<?php echo esc_attr($value); ?>">
2799 2799
 						<?php
2800 2800
 						break;
2801 2801
 					default:
@@ -2817,14 +2817,14 @@  discard block
 block discarded – undo
2817 2817
 		 * @return string
2818 2818
 		 * @todo, need to make its own tooltip script
2819 2819
 		 */
2820
-		public function widget_field_desc( $args ) {
2820
+		public function widget_field_desc($args) {
2821 2821
 
2822 2822
 			$description = '';
2823
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2824
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2825
-					$description = $this->desc_tip( $args['desc'] );
2823
+			if (isset($args['desc']) && $args['desc']) {
2824
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
2825
+					$description = $this->desc_tip($args['desc']);
2826 2826
 				} else {
2827
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2827
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
2828 2828
 				}
2829 2829
 			}
2830 2830
 
@@ -2839,11 +2839,11 @@  discard block
 block discarded – undo
2839 2839
 		 *
2840 2840
 		 * @return string
2841 2841
 		 */
2842
-		function desc_tip( $tip, $allow_html = false ) {
2843
-			if ( $allow_html ) {
2844
-				$tip = $this->sanitize_tooltip( $tip );
2842
+		function desc_tip($tip, $allow_html = false) {
2843
+			if ($allow_html) {
2844
+				$tip = $this->sanitize_tooltip($tip);
2845 2845
 			} else {
2846
-				$tip = esc_attr( $tip );
2846
+				$tip = esc_attr($tip);
2847 2847
 			}
2848 2848
 
2849 2849
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -2856,8 +2856,8 @@  discard block
 block discarded – undo
2856 2856
 		 *
2857 2857
 		 * @return string
2858 2858
 		 */
2859
-		public function sanitize_tooltip( $var ) {
2860
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2859
+		public function sanitize_tooltip($var) {
2860
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
2861 2861
 				'br'     => array(),
2862 2862
 				'em'     => array(),
2863 2863
 				'strong' => array(),
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
 				'li'     => array(),
2868 2868
 				'ol'     => array(),
2869 2869
 				'p'      => array(),
2870
-			) ) );
2870
+			)));
2871 2871
 		}
2872 2872
 
2873 2873
 		/**
@@ -2879,23 +2879,23 @@  discard block
 block discarded – undo
2879 2879
 		 * @return array
2880 2880
 		 * @todo we should add some sanitation here.
2881 2881
 		 */
2882
-		public function update( $new_instance, $old_instance ) {
2882
+		public function update($new_instance, $old_instance) {
2883 2883
 
2884 2884
 			//save the widget
2885
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2885
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
2886 2886
 
2887 2887
 			// set widget instance
2888 2888
 			$this->instance = $instance;
2889 2889
 
2890
-			if ( empty( $this->arguments ) ) {
2890
+			if (empty($this->arguments)) {
2891 2891
 				$this->get_arguments();
2892 2892
 			}
2893 2893
 
2894 2894
 			// check for checkboxes
2895
-			if ( ! empty( $this->arguments ) ) {
2896
-				foreach ( $this->arguments as $argument ) {
2897
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2898
-						$instance[ $argument['name'] ] = '0';
2895
+			if (!empty($this->arguments)) {
2896
+				foreach ($this->arguments as $argument) {
2897
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
2898
+						$instance[$argument['name']] = '0';
2899 2899
 					}
2900 2900
 				}
2901 2901
 			}
@@ -2913,7 +2913,7 @@  discard block
 block discarded – undo
2913 2913
 		 */
2914 2914
 		public function is_block_content_call() {
2915 2915
 			$result = false;
2916
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2916
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
2917 2917
 				$result = true;
2918 2918
 			}
2919 2919
 
@@ -2926,9 +2926,9 @@  discard block
 block discarded – undo
2926 2926
 		 * @since 1.0.20
2927 2927
 		 * @return string
2928 2928
 		 */
2929
-		public function get_instance_hash(){
2930
-			$instance_string = $this->base_id.serialize($this->instance);
2931
-			return hash('crc32b',$instance_string);
2929
+		public function get_instance_hash() {
2930
+			$instance_string = $this->base_id . serialize($this->instance);
2931
+			return hash('crc32b', $instance_string);
2932 2932
 		}
2933 2933
 
2934 2934
 		/**
@@ -2939,14 +2939,14 @@  discard block
 block discarded – undo
2939 2939
 		 * @since 1.0.20
2940 2940
 		 * @return string
2941 2941
 		 */
2942
-		public function get_instance_style($rules = array()){
2942
+		public function get_instance_style($rules = array()) {
2943 2943
 			$css = '';
2944 2944
 
2945
-			if(!empty($rules)){
2945
+			if (!empty($rules)) {
2946 2946
 				$rules = array_unique($rules);
2947 2947
 				$instance_hash = $this->get_instance_hash();
2948 2948
 				$css .= "<style>";
2949
-				foreach($rules as $rule){
2949
+				foreach ($rules as $rule) {
2950 2950
 					$css .= ".sdel-$instance_hash $rule";
2951 2951
 				}
2952 2952
 				$css .= "</style>";
Please login to merge, or discard this patch.
Braces   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 				<?php
662 662
 				if(! empty( $insert_shortcode_function )){
663 663
 					echo $insert_shortcode_function;
664
-				}else{
664
+				} else{
665 665
 
666 666
 				/**
667 667
 				 * Function for super duper insert shortcode.
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 					var prev_attributes = [];
1646 1646
 
1647 1647
 					var term_query_type = '';
1648
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
1648
+					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>;
1649 1649
 					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
1650 1650
 
1651 1651
 					/**
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 								}
1775 1775
 								if('post_type' in prev_attributes[props.id] && 'category' in prev_attributes[props.id] && $pt != term_query_type ){
1776 1776
 									term_query_type = $pt;
1777
-									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];}else{'/wp/v2/"+$value+"/categories';} ?>"}).then(terms => {
1777
+									wp.apiFetch({path: "<?php if(isset($this->arguments['post_type']['onchange_rest']['path'])){echo $this->arguments['post_type']['onchange_rest']['path'];} else{'/wp/v2/"+$value+"/categories';} ?>"}).then(terms => {
1778 1778
 										while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
1779 1779
 										taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
1780 1780
 									}
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
 									$panel_count ++;
1923 1923
 
1924 1924
 									}
1925
-									}else {
1925
+									} else {
1926 1926
 									?>
1927 1927
 									el(wp.components.PanelBody, {
1928 1928
 											title: '<?php esc_attr_e( "Settings" ); ?>',
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 								// If the user sets block-output array then build it
1947 1947
 								if ( ! empty( $this->options['block-output'] ) ) {
1948 1948
 								$this->block_element( $this->options['block-output'] );
1949
-							}else{
1949
+							} else{
1950 1950
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1951 1951
 								?>
1952 1952
 								el('div', {
@@ -2016,7 +2016,7 @@  discard block
 block discarded – undo
2016 2016
 							?>
2017 2017
 							return content;
2018 2018
 							<?php
2019
-							}else{
2019
+							} else{
2020 2020
 							?>
2021 2021
 							var block_wrap = 'div';
2022 2022
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -2121,8 +2121,7 @@  discard block
 block discarded – undo
2121 2121
                             $key: value
2122 2122
                         });
2123 2123
                     },";
2124
-			}
2125
-			elseif ( $args['type'] == 'checkbox' ) {
2124
+			} elseif ( $args['type'] == 'checkbox' ) {
2126 2125
 				$type = 'CheckboxControl';
2127 2126
 				$extra .= "checked: props.attributes.$key,";
2128 2127
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
@@ -2133,7 +2132,7 @@  discard block
 block discarded – undo
2133 2132
 
2134 2133
 				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
2135 2134
 					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
2136
-				}else {
2135
+				} else {
2137 2136
 
2138 2137
 					if ( ! empty( $args['options'] ) ) {
2139 2138
 						$options .= "options: [";
Please login to merge, or discard this patch.